/**************************************************************************
*
+ * Copyright 2011 Jose Fonseca
* Copyright 2010 VMware, Inc.
* All Rights Reserved.
*
*
**************************************************************************/
+
#include <string.h>
#include "cli.hpp"
+#include "cli_pager.hpp"
#include "trace_parser.hpp"
+#include "trace_dump.hpp"
+
enum ColorOption {
COLOR_OPTION_NEVER = 0,
static ColorOption color = COLOR_OPTION_AUTO;
+static bool verbose = false;
+
static const char *synopsis = "Dump given trace(s) to standard output.";
static void
<< "usage: apitrace dump [OPTIONS] <trace-file>...\n"
<< synopsis << "\n"
"\n"
+ " -v, --verbose verbose output\n"
" --color=<WHEN>\n"
" --colour=<WHEN> Colored syntax highlighting\n"
- " WHEN is 'auto', 'always', or 'never'\n";
+ " WHEN is 'auto', 'always', or 'never'\n"
+ " --no-arg-names Don't dump argument names\n"
+ ;
}
static int
command(int argc, char *argv[])
{
+ trace::DumpFlags dumpFlags = 0;
+
int i;
for (i = 0; i < argc; ++i) {
} else if (!strcmp(arg, "--help")) {
usage();
return 0;
+ } else if (strcmp(arg, "-v") == 0 ||
+ strcmp(arg, "--verbose") == 0) {
+ verbose = true;
} else if (!strcmp(arg, "--color=auto") ||
!strcmp(arg, "--colour=auto")) {
color = COLOR_OPTION_AUTO;
!strcmp(arg, "--no-color") ||
!strcmp(arg, "--no-colour")) {
color = COLOR_OPTION_NEVER;
+ } else if (!strcmp(arg, "--no-arg-names")) {
+ dumpFlags |= trace::DUMP_FLAG_NO_ARG_NAMES;
} else {
std::cerr << "error: unknown option " << arg << "\n";
usage();
color = COLOR_OPTION_ALWAYS;
#else
color = isatty(1) ? COLOR_OPTION_ALWAYS : COLOR_OPTION_NEVER;
+ pipepager();
#endif
}
+ if (color == COLOR_OPTION_NEVER) {
+ dumpFlags |= trace::DUMP_FLAG_NO_COLOR;
+ }
+
for (; i < argc; ++i) {
trace::Parser p;
trace::Call *call;
while ((call = p.parse_call())) {
- call->dump(std::cout, color);
+ if (verbose ||
+ !(call->flags & trace::CALL_FLAG_VERBOSE)) {
+ trace::dump(*call, std::cout, dumpFlags);
+ }
delete call;
}
}
return 0;
}
-const Command dump = {
+const Command dump_command = {
"dump",
synopsis,
usage,