]> git.cworth.org Git - apitrace/blobdiff - cli/cli_dump.cpp
First stab at tracing thread IDs.
[apitrace] / cli / cli_dump.cpp
index ebb92d8606c49fa24004ccd928e4e700bb8fc551..adecb22e4abd1d0178f0f25d64a13f8d669756fe 100644 (file)
@@ -1,5 +1,6 @@
 /**************************************************************************
  *
+ * 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,
@@ -52,12 +56,18 @@ usage(void)
         "    -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"
+        "    --thread-ids        Dump thread ids\n"
+    ;
 }
 
 static int
 command(int argc, char *argv[])
 {
+    trace::DumpFlags dumpFlags = 0;
+    bool dumpThreadIds = false;
+
     int i;
 
     for (i = 0; i < argc; ++i) {
@@ -88,6 +98,10 @@ command(int argc, char *argv[])
                    !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 if (!strcmp(arg, "--thread-ids")) {
+            dumpThreadIds = true;
         } else {
             std::cerr << "error: unknown option " << arg << "\n";
             usage();
@@ -104,6 +118,10 @@ command(int argc, char *argv[])
 #endif
     }
 
+    if (color == COLOR_OPTION_NEVER) {
+        dumpFlags |= trace::DUMP_FLAG_NO_COLOR;
+    }
+
     for (; i < argc; ++i) {
         trace::Parser p;
 
@@ -116,7 +134,10 @@ command(int argc, char *argv[])
         while ((call = p.parse_call())) {
             if (verbose ||
                 !(call->flags & trace::CALL_FLAG_VERBOSE)) {
-                call->dump(std::cout, color);
+                if (dumpThreadIds) {
+                    std::cout << std::hex << call->thread_id << std::dec << " ";
+                }
+                trace::dump(*call, std::cout, dumpFlags);
             }
             delete call;
         }