#include "trace_parser.hpp"
#include "trace_dump.hpp"
+#include "trace_callset.hpp"
enum ColorOption {
static bool verbose = false;
+static trace::CallSet calls(trace::FREQUENCY_ALL);
+
static const char *synopsis = "Dump given trace(s) to standard output.";
static void
<< synopsis << "\n"
"\n"
" -v, --verbose verbose output\n"
+ " --calls <CALLSET> Only dump specified calls\n"
" --color=<WHEN>\n"
" --colour=<WHEN> Colored syntax highlighting\n"
" WHEN is 'auto', 'always', or 'never'\n"
" --no-arg-names Don't dump argument names\n"
+ " --thread-ids Dump thread ids\n"
;
}
command(int argc, char *argv[])
{
trace::DumpFlags dumpFlags = 0;
+ bool dumpThreadIds = false;
int i;
- for (i = 0; i < argc; ++i) {
+ for (i = 0; i < argc;) {
const char *arg = argv[i];
if (arg[0] != '-') {
break;
}
+ ++i;
+
if (!strcmp(arg, "--")) {
break;
} else if (!strcmp(arg, "--help")) {
} else if (strcmp(arg, "-v") == 0 ||
strcmp(arg, "--verbose") == 0) {
verbose = true;
+ } else if (!strcmp(arg, "--calls")) {
+ calls = trace::CallSet(argv[i++]);
} else if (!strcmp(arg, "--color=auto") ||
!strcmp(arg, "--colour=auto")) {
color = COLOR_OPTION_AUTO;
color = COLOR_OPTION_NEVER;
} else if (!strcmp(arg, "--no-arg-names")) {
dumpFlags |= trace::DUMP_FLAG_NO_ARG_NAMES;
+ } else if (!strcmp(arg, "--thread-ids")) {
+ dumpThreadIds = true;
} else {
std::cerr << "error: unknown option " << arg << "\n";
usage();
trace::Call *call;
while ((call = p.parse_call())) {
- if (verbose ||
- !(call->flags & trace::CALL_FLAG_VERBOSE)) {
- trace::dump(*call, std::cout, dumpFlags);
+ if (calls.contains(*call)) {
+ if (verbose ||
+ !(call->flags & trace::CALL_FLAG_VERBOSE)) {
+ if (dumpThreadIds) {
+ std::cout << std::hex << call->thread_id << std::dec << " ";
+ }
+ trace::dump(*call, std::cout, dumpFlags);
+ }
}
delete call;
}