X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=cli%2Fcli_dump.cpp;h=3f6bea2e0fd03d0463e74edf1d599b435cbb53ce;hb=225193db0f50a8f3a1d59d7cff351c9be31e8044;hp=adecb22e4abd1d0178f0f25d64a13f8d669756fe;hpb=7a6a32e2271a34d530c6914b0ad2bc95700f2cb2;p=apitrace diff --git a/cli/cli_dump.cpp b/cli/cli_dump.cpp index adecb22..3f6bea2 100644 --- a/cli/cli_dump.cpp +++ b/cli/cli_dump.cpp @@ -32,6 +32,7 @@ #include "trace_parser.hpp" #include "trace_dump.hpp" +#include "trace_callset.hpp" enum ColorOption { @@ -44,6 +45,8 @@ static ColorOption color = COLOR_OPTION_AUTO; static bool verbose = false; +static trace::CallSet calls(trace::FREQUENCY_ALL); + static const char *synopsis = "Dump given trace(s) to standard output."; static void @@ -54,6 +57,7 @@ usage(void) << synopsis << "\n" "\n" " -v, --verbose verbose output\n" + " --calls Only dump specified calls\n" " --color=\n" " --colour= Colored syntax highlighting\n" " WHEN is 'auto', 'always', or 'never'\n" @@ -70,13 +74,15 @@ command(int argc, char *argv[]) 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")) { @@ -85,6 +91,8 @@ command(int argc, char *argv[]) } 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; @@ -132,12 +140,14 @@ command(int argc, char *argv[]) trace::Call *call; while ((call = p.parse_call())) { - if (verbose || - !(call->flags & trace::CALL_FLAG_VERBOSE)) { - if (dumpThreadIds) { - std::cout << std::hex << call->thread_id << std::dec << " "; + 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); } - trace::dump(*call, std::cout, dumpFlags); } delete call; }