]> git.cworth.org Git - apitrace/commitdiff
Merge branch 'os-path'
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 31 Oct 2011 15:41:14 +0000 (15:41 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 31 Oct 2011 15:41:14 +0000 (15:41 +0000)
.gitignore
CMakeLists.txt
README.markdown
cli/CMakeLists.txt [new file with mode: 0644]
cli/cli.hpp [new file with mode: 0644]
cli/cli_dump.cpp [new file with mode: 0644]
cli/cli_main.cpp [new file with mode: 0644]
gui/mainwindow.cpp
scripts/tracediff.sh
tracedump.cpp [deleted file]

index 95b78fec2d3d4e4198f71c75f44f36bcdce3702b..5699afc945d2c0e0d2b953402148bf891dad581f 100644 (file)
@@ -28,6 +28,7 @@ _CPack_Packages
 CMakeCache.txt
 CMakeFiles
 Makefile
+apitrace
 build
 cgltrace.cpp
 d3d10trace.cpp
@@ -42,6 +43,5 @@ glstate_params.cpp
 glxtrace.cpp
 install_manifest.txt
 qapitrace
-tracedump
 traces
 wgltrace.cpp
index 3066b62c3d06c90f8cf92bf7dc82a409ddc63eb1..0b4ab84f20c1c6e7aa59ba65b42ff97d3a530bdd 100755 (executable)
@@ -230,10 +230,6 @@ set_target_properties (common PROPERTIES
 
 link_libraries (common)
 
-add_executable (tracedump tracedump.cpp)
-install (TARGETS tracedump RUNTIME DESTINATION bin) 
-
-
 ##############################################################################
 # API tracers
 
@@ -447,6 +443,10 @@ endif ()
 
 install (TARGETS glretrace RUNTIME DESTINATION bin) 
 
+##############################################################################
+# CLI
+
+add_subdirectory(cli)
 
 ##############################################################################
 # GUI
index 01fb8b66fcde25be18ba09cf041afe4b8f49e890..d35f2c46d9c96dfa702d3bb29339712c4a9dd0f9 100644 (file)
@@ -29,7 +29,7 @@ directory.  You can specify the written trace filename by setting the
 
 View the trace with
 
-    /path/to/tracedump --color application.trace | less -R
+    /path/to/apitrace dump --color application.trace | less -R
 
 Replay the trace with
 
@@ -88,7 +88,7 @@ Windows
 
 * View the trace with
 
-        \path\to\tracedump application.trace
+        \path\to\apitrace dump application.trace
 
 * Replay the trace with
 
diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c41cdb4
--- /dev/null
@@ -0,0 +1,6 @@
+add_executable (apitrace
+    cli_main.cpp
+    cli_dump.cpp
+)
+
+install (TARGETS apitrace RUNTIME DESTINATION bin)
diff --git a/cli/cli.hpp b/cli/cli.hpp
new file mode 100644 (file)
index 0000000..0792aff
--- /dev/null
@@ -0,0 +1,47 @@
+/*********************************************************************
+ *
+ * Copyright 2011 Intel Corporation
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ *********************************************************************/
+
+#ifndef _APITRACE_CLI_HPP_
+#define _APITRACE_CLI_HPP_
+
+
+struct Command {
+    const char *name;
+    const char *synopsis;
+
+    typedef void (*Usage) (void);
+    Usage usage;
+
+    typedef int (*Function) (int argc, char *argv[]);
+    Function function;
+};
+
+
+extern const Command dump;
+
+
+#endif /* _APITRACE_CLI_HPP_ */
diff --git a/cli/cli_dump.cpp b/cli/cli_dump.cpp
new file mode 100644 (file)
index 0000000..2164518
--- /dev/null
@@ -0,0 +1,122 @@
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <string.h>
+
+#include "cli.hpp"
+
+#include "trace_parser.hpp"
+
+enum ColorOption {
+    COLOR_OPTION_NEVER = 0,
+    COLOR_OPTION_ALWAYS = 1,
+    COLOR_OPTION_AUTO = -1
+};
+
+static ColorOption color = COLOR_OPTION_AUTO;
+
+static const char *synopsis = "Dump given trace(s) to standard output.";
+
+static void
+usage(void)
+{
+    std::cout
+        << "usage: apitrace dump [OPTIONS] <trace-file>...\n"
+        << synopsis << "\n"
+        "\n"
+        "    --color=<WHEN>\n"
+        "    --colour=<WHEN>     Colored syntax highlighting\n"
+        "                        WHEN is 'auto', 'always', or 'never'\n";
+}
+
+static int
+command(int argc, char *argv[])
+{
+    int i;
+
+    for (i = 0; i < argc; ++i) {
+        const char *arg = argv[i];
+
+        if (arg[0] != '-') {
+            break;
+        }
+
+        if (!strcmp(arg, "--")) {
+            break;
+        } else if (!strcmp(arg, "--help")) {
+            usage();
+            return 0;
+        } else if (!strcmp(arg, "--color=auto") ||
+                   !strcmp(arg, "--colour=auto")) {
+            color = COLOR_OPTION_AUTO;
+        } else if (!strcmp(arg, "--color") ||
+                   !strcmp(arg, "--colour") ||
+                   !strcmp(arg, "--color=always") ||
+                   !strcmp(arg, "--colour=always")) {
+            color = COLOR_OPTION_ALWAYS;
+        } else if (!strcmp(arg, "--color=never") ||
+                   !strcmp(arg, "--colour=never") ||
+                   !strcmp(arg, "--no-color") ||
+                   !strcmp(arg, "--no-colour")) {
+            color = COLOR_OPTION_NEVER;
+        } else {
+            std::cerr << "error: unknown option " << arg << "\n";
+            usage();
+            return 1;
+        }
+    }
+
+    if (color == COLOR_OPTION_AUTO) {
+#ifdef _WIN32
+        color = COLOR_OPTION_ALWAYS;
+#else
+        color = isatty(1) ? COLOR_OPTION_ALWAYS : COLOR_OPTION_NEVER;
+#endif
+    }
+
+    for (; i < argc; ++i) {
+        trace::Parser p;
+
+        if (!p.open(argv[i])) {
+            std::cerr << "error: failed to open " << argv[i] << "\n";
+            return 1;
+        }
+
+        trace::Call *call;
+        while ((call = p.parse_call())) {
+            call->dump(std::cout, color);
+            delete call;
+        }
+    }
+
+    return 0;
+}
+
+const Command dump = {
+    "dump",
+    synopsis,
+    usage,
+    command
+};
diff --git a/cli/cli_main.cpp b/cli/cli_main.cpp
new file mode 100644 (file)
index 0000000..1731640
--- /dev/null
@@ -0,0 +1,184 @@
+/*********************************************************************
+ *
+ * Copyright 2011 Intel Corporation
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ *********************************************************************/
+
+
+/*
+ * Top-level application for accessing almost of apitrace
+ * functionality.
+ */
+
+#include <string.h>
+
+#include <iomanip>
+#include <iostream>
+
+#include "cli.hpp"
+
+#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
+
+static const char *help_synopsis = "Print detailed help for the given command.";
+
+static void list_commands(void);
+
+static void
+help_usage()
+{
+    std::cout
+        << "usage: apitrace help [<command>]\n"
+        << help_synopsis << "\n"
+        "\n";
+
+    list_commands();
+}
+
+static int
+help_command(int argc, char *argv[]);
+
+const Command help = {
+    "help",
+    help_synopsis,
+    help_usage,
+    help_command
+};
+
+static const Command * commands[] = {
+    &dump,
+    &help,
+};
+
+static void
+usage(void)
+{
+    std::cout <<
+        "Usage: apitrace <command> [<args> ...]\n"
+        "Top-level command line frontend to apitrace.\n"
+        "\n";
+
+    list_commands();
+}
+
+static void
+list_commands(void) {
+    const Command *command;
+    int i, max_width = 0;
+
+    std::cout << "The available commands are as follows:\n\n";
+
+    std::cout << std::setiosflags(std::ios::left);
+
+    for (i = 0; i < ARRAY_SIZE(commands); i++) {
+        command = commands[i];
+        if (strlen(command->name) > max_width) {
+            max_width = strlen(command->name);
+        }
+    }
+
+    for (i = 0; i < ARRAY_SIZE(commands); i++) {
+        command = commands[i];
+
+        std::cout << "    " << std::setw(max_width + 2) << command->name
+                  << " " << command->synopsis << "\n";
+    }
+
+    std::cout << "\n"
+        "Use \"apitrace help <command>\" for more details on each command.\n";
+}
+
+
+static int
+help_command(int argc, char *argv[])
+{
+    const Command *command;
+    int i;
+
+    if (argc != 1) {
+        help_usage();
+        return 0;
+    }
+
+    char *command_name = argv[0];
+
+    for (i = 0; i < ARRAY_SIZE(commands); i++) {
+        command = commands[i];
+
+        if (strcmp(command_name, command->name) == 0) {
+            (command->usage) ();
+            return 0;
+        }
+    }
+
+    std::cerr << "Error: Unknown command: " << command_name
+              << " (see \"apitrace help\").\n";
+
+    return 1;
+}
+
+int
+main(int argc, char **argv)
+{
+    const char *command_name;
+    const Command *command;
+    int i;
+
+    for (i = 1; i < argc; ++i) {
+        const char *arg = argv[i];
+
+        if (arg[0] != '-') {
+            break;
+        }
+
+        if (strcmp(arg, "--help") == 0) {
+            return help_command(0, NULL);
+        } else {
+            std::cerr << "Error: unknown option " << arg << "\n";
+            usage();
+            return 1;
+        }
+    }
+
+    if (i == argc) {
+        usage();
+        return 1;
+    }
+
+    command_name = argv[i++];
+
+    argc -= i;
+    argv = &argv[i];
+
+    for (i = 0; i < ARRAY_SIZE(commands); i++) {
+        command = commands[i];
+
+        if (strcmp(command_name, command->name) == 0)
+            return (command->function) (argc, argv);
+    }
+
+    std::cerr << "Error: unknown command " << command_name
+              << " (see \"apitrace help\").\n";
+
+    return 1;
+}
index 28dd6281a92602bb8dd44521e8cc83b8ad789331..f1678a879a07c7d5f1ca9ba7bbd93f3d98d1e0bc 100644 (file)
@@ -760,7 +760,7 @@ void MainWindow::initConnections()
     connect(m_ui.actionOptions, SIGNAL(triggered()),
             this, SLOT(showSettings()));
 
-    connect(m_ui.callView, SIGNAL(activated(const QModelIndex &)),
+    connect(m_ui.callView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
             this, SLOT(callItemSelected(const QModelIndex &)));
     connect(m_ui.callView, SIGNAL(customContextMenuRequested(QPoint)),
             this, SLOT(customContextMenuRequested(QPoint)));
@@ -798,7 +798,7 @@ void MainWindow::initConnections()
     connect(m_ui.actionShowErrorsDock, SIGNAL(triggered(bool)),
             m_ui.errorsDock, SLOT(setVisible(bool)));
     connect(m_ui.errorsTreeWidget,
-            SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
+            SIGNAL(itemActivated(QTreeWidgetItem*, int)),
             this, SLOT(slotErrorSelected(QTreeWidgetItem*)));
 }
 
index 61292346bbbf4115c08e85e594833fe8e23e5fd3..b3b9220f86c80c1aa3283da2212fa7fb85264eb0 100755 (executable)
 
 set -e
 
-TRACEDUMP=${TRACEDUMP:-`dirname "$0"`/../tracedump}
+APITRACE=${APITRACE:-`dirname "$0"`/../apitrace}
 
-$TRACEDUMP
+$APITRACE dump
 
 stripdump () {
-    $TRACEDUMP --color=never "$1" \
+    $APITRACE dump --color=never "$1" \
     | sed \
         -e 's/\r$//g' \
         -e 's/^[0-9]\+ //' \
diff --git a/tracedump.cpp b/tracedump.cpp
deleted file mode 100644 (file)
index 44ca609..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- **************************************************************************/
-
-
-/*
- * Simple utility to dump a trace to standard output.
- */
-
-
-#include <string.h>
-
-#include "trace_parser.hpp"
-
-
-enum ColorOption {
-    COLOR_OPTION_NEVER = 0,
-    COLOR_OPTION_ALWAYS = 1,
-    COLOR_OPTION_AUTO = -1
-};
-
-static ColorOption color = COLOR_OPTION_AUTO;
-
-
-static void usage(void) {
-    std::cout <<
-        "Usage: tracedump [OPTION] [TRACE]...\n"
-        "Dump TRACE to standard output.\n"
-        "\n"
-        "  --help               display this help and exit\n"
-        "  --color[=WHEN]\n"
-        "  --colour[=WHEN]      colored syntax highlighting;\n"
-        "                       WHEN is 'always', 'never', or 'auto'\n"
-    ;
-}
-
-
-int main(int argc, char **argv)
-{
-    int i;
-
-    for (i = 1; i < argc; ++i) {
-        const char *arg = argv[i];
-
-        if (arg[0] != '-') {
-            break;
-        }
-
-        if (!strcmp(arg, "--")) {
-            break;
-        } else if (!strcmp(arg, "--help")) {
-            usage();
-            return 0;
-        } else if (!strcmp(arg, "--color=auto") ||
-                   !strcmp(arg, "--colour=auto")) {
-            color = COLOR_OPTION_AUTO;
-        } else if (!strcmp(arg, "--color") ||
-                   !strcmp(arg, "--colour") ||
-                   !strcmp(arg, "--color=always") ||
-                   !strcmp(arg, "--colour=always")) {
-            color = COLOR_OPTION_ALWAYS;
-        } else if (!strcmp(arg, "--color=never") ||
-                   !strcmp(arg, "--colour=never") ||
-                   !strcmp(arg, "--no-color") ||
-                   !strcmp(arg, "--no-colour")) {
-            color = COLOR_OPTION_NEVER;
-        } else {
-            std::cerr << "error: unknown option " << arg << "\n";
-            usage();
-            return 1;
-        }
-    }
-
-    if (color == COLOR_OPTION_AUTO) {
-#ifdef _WIN32
-        color = COLOR_OPTION_ALWAYS;
-#else
-        color = isatty(1) ? COLOR_OPTION_ALWAYS : COLOR_OPTION_NEVER;
-#endif
-    }
-
-    for (; i < argc; ++i) {
-        trace::Parser p;
-
-        if (!p.open(argv[i])) {
-            std::cerr << "error: failed to open " << argv[i] << "\n";
-            return 1;
-        }
-
-        trace::Call *call;
-        while ((call = p.parse_call())) {
-            call->dump(std::cout, color);
-            delete call;
-        }
-    }
-
-    return 0;
-}