]> git.cworth.org Git - apitrace/blobdiff - cli/cli_trace.cpp
Add "apitrace trim" command.
[apitrace] / cli / cli_trace.cpp
index 0d1f740084d1a765984d617b3c8e9fd6261161e9..92251b4bef0ad6cd10b4d9b924a0414f27b9e67b 100644 (file)
@@ -41,22 +41,26 @@ static const char *synopsis = "Generate a new trace by executing the given progr
 static void
 usage(void)
 {
-    std::cout << "usage: apitrace trace <program> [<args> ...]\n"
+    std::cout << "usage: apitrace trace PROGRAM [ARGS ...]\n"
         << synopsis << "\n"
         "\n"
         "    The given program will be executed with the given arguments.\n"
         "    During execution, all OpenGL calls will be captured to a trace\n"
-        "    file named <program>.trace. That trace file can then be used\n"
+        "    file. That trace file can then be used\n"
         "    with other apitrace utilities for replay or analysis.\n"
         "\n"
         "    -v, --verbose       verbose output\n"
-        "    -o, --output TRACE  specify output trace file\n";
+        "    -a, --api API       specify API to trace (gl or egl);\n"
+        "                        default is `gl`\n"
+        "    -o, --output TRACE  specify output trace file;\n"
+        "                        default is `PROGRAM.trace`\n";
 }
 
 static int
 command(int argc, char *argv[])
 {
     bool verbose = false;
+    trace::API api = trace::API_GL;
     const char *output = NULL;
     int i;
 
@@ -77,6 +81,18 @@ command(int argc, char *argv[])
         } else if (strcmp(arg, "-v") == 0 ||
                    strcmp(arg, "--verbose") == 0) {
             verbose = true;
+        } else if (strcmp(arg, "-a") == 0 ||
+                   strcmp(arg, "--api") == 0) {
+            arg = argv[i++];
+            if (strcmp(arg, "gl") == 0) {
+                api = trace::API_GL;
+            } else if (strcmp(arg, "egl") == 0) {
+                api = trace::API_EGL;
+            } else {
+                std::cerr << "error: unknown API `" << arg << "`\n";
+                usage();
+                return 1;
+            }
         } else if (strcmp(arg, "-o") == 0 ||
                    strcmp(arg, "--output") == 0) {
             output = argv[i++];
@@ -94,7 +110,7 @@ command(int argc, char *argv[])
     }
 
     assert(argv[argc] == 0);
-    return trace::traceProgram(argv + i, output, verbose);
+    return trace::traceProgram(api, argv + i, output, verbose);
 }
 
 const Command trace_command = {