Dbg:Add CallableTracer for callables post()ed to boost.asio
This class and its macro allow us to trace the invocation of callbacks as they're invoked by Boost.asio.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <asynchronousContinuation.h>
|
||||
#include <asynchronousLoop.h>
|
||||
#include <callback.h>
|
||||
#include <callableTracer.h>
|
||||
#include <body/body.h>
|
||||
#include <componentThread.h>
|
||||
#include <mind.h>
|
||||
@@ -158,9 +159,9 @@ void Body::initializeReq(Callback<bodyLifetimeMgmtOpCbFn> callback)
|
||||
parent, mrntt, callback);
|
||||
|
||||
thread->getIoService().post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&InitializeReq::initializeReq1_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void Body::finalizeReq(Callback<bodyLifetimeMgmtOpCbFn> callback)
|
||||
@@ -187,9 +188,9 @@ void Body::finalizeReq(Callback<bodyLifetimeMgmtOpCbFn> callback)
|
||||
parent, mrntt, callback);
|
||||
|
||||
thread->getIoService().post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&FinalizeReq::finalizeReq1_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
} // namespace body
|
||||
|
||||
+18
-12
@@ -8,6 +8,7 @@
|
||||
#include <opts.h>
|
||||
#include <asynchronousContinuation.h>
|
||||
#include <callback.h>
|
||||
#include <callableTracer.h>
|
||||
#include <mind.h>
|
||||
#include <mindManager/mindManager.h>
|
||||
#include <componentThread.h>
|
||||
@@ -33,6 +34,11 @@ void MindThread::initializeTls(void)
|
||||
thisComponentThread = shared_from_this();
|
||||
}
|
||||
|
||||
bool ComponentThread::tlsInitialized(void)
|
||||
{
|
||||
return thisComponentThread != nullptr;
|
||||
}
|
||||
|
||||
const std::shared_ptr<ComponentThread> ComponentThread::getSelf(void)
|
||||
{
|
||||
if (!thisComponentThread)
|
||||
@@ -240,9 +246,9 @@ void MindThread::joltThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
||||
mrntt, target, callback);
|
||||
|
||||
this->getIoService().post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&ThreadLifetimeMgmtOp::joltThreadReq1_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
// Thread management method implementations
|
||||
@@ -253,9 +259,9 @@ void MindThread::startThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
||||
caller, shared_from_this(), callback);
|
||||
|
||||
this->getIoService().post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&ThreadLifetimeMgmtOp::startThreadReq1_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void MindThread::exitThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
||||
@@ -265,14 +271,14 @@ void MindThread::exitThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
||||
caller, shared_from_this(), callback);
|
||||
|
||||
this->getIoService().post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&ThreadLifetimeMgmtOp::exitThreadReq1_mainQueue_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
|
||||
pause_io_service.post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&ThreadLifetimeMgmtOp::exitThreadReq1_pauseQueue_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void MindThread::pauseThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
||||
@@ -288,9 +294,9 @@ void MindThread::pauseThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
||||
caller, shared_from_this(), callback);
|
||||
|
||||
this->getIoService().post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&ThreadLifetimeMgmtOp::pauseThreadReq1_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void MindThread::resumeThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
||||
@@ -307,9 +313,9 @@ void MindThread::resumeThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
|
||||
caller, shared_from_this(), callback);
|
||||
|
||||
pause_io_service.post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&ThreadLifetimeMgmtOp::resumeThreadReq1_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
// CPU management method implementations
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <asynchronousContinuation.h>
|
||||
#include <serializedAsynchronousContinuation.h>
|
||||
#include <callback.h>
|
||||
#include <callableTracer.h>
|
||||
#include <componentThread.h>
|
||||
#include <deviceManager/deviceManager.h>
|
||||
#include <deviceManager/deviceReattacher.h>
|
||||
@@ -626,10 +627,10 @@ void DeviceManager::attachAllUnattachedDevicesFromReq(
|
||||
specs->size(), specs, caller, std::move(cb));
|
||||
|
||||
mrntt::mrntt.thread->getIoService().post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&AttachAllUnattachedDevicesFromReq
|
||||
::attachAllUnattachedDevicesFromReq1_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void DeviceManager::attachAllUnattachedDevicesFromCmdlineReq(
|
||||
@@ -807,9 +808,9 @@ void DeviceManager::detachAllAttachedDeviceRoles(
|
||||
caller, std::move(cb));
|
||||
|
||||
mrntt::mrntt.thread->getIoService().post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&DetachAllAttachedDeviceRoles::detachAllAttachedDeviceRoles1_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void DeviceManager::initializeDeviceReattacher()
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
boost::asio::io_service& getIoService(void) { return io_service; }
|
||||
|
||||
static const std::shared_ptr<ComponentThread> getSelf(void);
|
||||
static bool tlsInitialized(void);
|
||||
static std::shared_ptr<MarionetteThread> getMrntt();
|
||||
|
||||
typedef void (mainFn)(ComponentThread &self);
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
class OptionParser
|
||||
{
|
||||
public:
|
||||
OptionParser() : verbose(false), printUsage(false) {}
|
||||
OptionParser() : verbose(false), printUsage(false), traceCallables(false)
|
||||
{}
|
||||
~OptionParser() = default;
|
||||
|
||||
void parseArguments(int argc, char *argv[], char **envp);
|
||||
@@ -38,7 +39,7 @@ public:
|
||||
std::vector<std::string> senseApiLibs;
|
||||
std::string dapSpecs;
|
||||
std::vector<std::string> dapSpecFiles;
|
||||
bool verbose, printUsage;
|
||||
bool verbose, printUsage, traceCallables;
|
||||
|
||||
static struct option longOptions[];
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <asynchronousContinuation.h>
|
||||
#include <asynchronousLoop.h>
|
||||
#include <callback.h>
|
||||
#include <callableTracer.h>
|
||||
#include <component.h>
|
||||
#include <componentThread.h>
|
||||
#include <deviceManager/deviceManager.h>
|
||||
@@ -131,9 +132,9 @@ void MarionetteComponent::initializeReq(
|
||||
*this, mrntt, callback);
|
||||
|
||||
mrntt->getIoService().post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&MrnttLifetimeMgmtOp::initializeReq1_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void MarionetteComponent::finalizeReq(
|
||||
@@ -151,9 +152,9 @@ void MarionetteComponent::finalizeReq(
|
||||
*this, mrntt, callback);
|
||||
|
||||
mrntt->getIoService().post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&MrnttLifetimeMgmtOp::finalizeReq1_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
} // namespace mrntt
|
||||
|
||||
+5
-4
@@ -3,6 +3,7 @@
|
||||
#include <asynchronousContinuation.h>
|
||||
#include <asynchronousLoop.h>
|
||||
#include <callback.h>
|
||||
#include <callableTracer.h>
|
||||
#include <mind.h>
|
||||
#include <componentThread.h>
|
||||
#include <director/director.h>
|
||||
@@ -215,9 +216,9 @@ void Mind::initializeReq(Callback<mindLifetimeMgmtOpCbFn> callback)
|
||||
*this, caller, callback);
|
||||
|
||||
mrntt::mrntt.thread->getIoService().post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&MindLifetimeMgmtOp::initializeReq1_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void Mind::finalizeReq(Callback<mindLifetimeMgmtOpCbFn> callback)
|
||||
@@ -227,9 +228,9 @@ void Mind::finalizeReq(Callback<mindLifetimeMgmtOpCbFn> callback)
|
||||
*this, caller, callback);
|
||||
|
||||
mrntt::mrntt.thread->getIoService().post(
|
||||
std::bind(
|
||||
STC(std::bind(
|
||||
&MindLifetimeMgmtOp::finalizeReq1_posted,
|
||||
request.get(), request));
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void Mind::distributeAndPinThreadsAcrossCpus()
|
||||
|
||||
+12
-1
@@ -43,6 +43,9 @@ struct option OptionParser::longOptions[] = {
|
||||
{"apipath", required_argument, 0, 'p'},
|
||||
{"libpath", required_argument, 0, 'p'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"trace-callables", no_argument, 0, 't'},
|
||||
{"call-trace", no_argument, 0, 't'},
|
||||
{"calltrace", no_argument, 0, 't'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
@@ -58,7 +61,7 @@ void OptionParser::parseArguments(int argc, char *argv[], char **envp)
|
||||
optind = 1; // Reset optind to 1 before parsing
|
||||
opterr = 0;
|
||||
while ((opt = getopt_long(
|
||||
argc, argv, "s:d:a:p:vh?", longOptions, &optionIndex)) != -1)
|
||||
argc, argv, "s:d:a:p:vht?", longOptions, &optionIndex)) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
@@ -91,6 +94,9 @@ void OptionParser::parseArguments(int argc, char *argv[], char **envp)
|
||||
case 'v':
|
||||
verbose = true;
|
||||
break;
|
||||
case 't':
|
||||
traceCallables = true;
|
||||
break;
|
||||
case 'h':
|
||||
throw JustPrintUsageNoError(*this);
|
||||
case '?':
|
||||
@@ -108,6 +114,7 @@ std::string OptionParser::getUsage() const
|
||||
"[-a|--api-lib|--apilib|--api|--lib <filename>] "
|
||||
"[-p|--api-lib-path|--apipath|--libpath <directory>] "
|
||||
"[-v|--verbose] "
|
||||
"[-t|--trace-callables|--call-trace|--calltrace] "
|
||||
"[-h|--help]\n\n"
|
||||
"Example DAP spec:\n"
|
||||
" -s '+edev|my-cam|video-qualeiface|v4l2-video(fps-hz=30)|v4l2()|/dev/video0'";
|
||||
@@ -121,6 +128,10 @@ std::string OptionParser::stringifyOptions(void) const
|
||||
oss << "Verbose mode is on" << std::endl;
|
||||
}
|
||||
|
||||
if (traceCallables) {
|
||||
oss << "Callable tracing is enabled" << std::endl;
|
||||
}
|
||||
|
||||
oss << "Cmdline DAP Specs: " << dapSpecs << std::endl;
|
||||
|
||||
oss << "DAP Spec Files: ";
|
||||
|
||||
Reference in New Issue
Block a user