summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-01-19 13:54:09 +0000
committerJose Fonseca <jfonseca@vmware.com>2016-01-22 22:37:46 +0000
commitc4343f12297177d558dc58e2a38921c2ec671f6a (patch)
treef237d71f34ced1a2962f64ccbc4d76a4de4b0d29 /cli
parent731cccef4cf1e85c954b7b1849374fb085a5b800 (diff)
cli: Add a leaks sub-command.
Merely invokes leaks.py
Diffstat (limited to 'cli')
-rw-r--r--cli/CMakeLists.txt1
-rw-r--r--cli/cli.hpp1
-rw-r--r--cli/cli_leaks.cpp85
-rw-r--r--cli/cli_main.cpp1
4 files changed, 88 insertions, 0 deletions
diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt
index 4c13c213..31d7fdf2 100644
--- a/cli/CMakeLists.txt
+++ b/cli/CMakeLists.txt
@@ -19,6 +19,7 @@ add_executable (apitrace
cli_diff.cpp
cli_diff_state.cpp
cli_diff_images.cpp
+ cli_leaks.cpp
cli_dump.cpp
cli_dump_images.cpp
cli_pager.cpp
diff --git a/cli/cli.hpp b/cli/cli.hpp
index 55ded732..f777122c 100644
--- a/cli/cli.hpp
+++ b/cli/cli.hpp
@@ -44,6 +44,7 @@ extern const Command diff_state_command;
extern const Command diff_images_command;
extern const Command dump_command;
extern const Command dump_images_command;
+extern const Command leaks_command;
extern const Command pickle_command;
extern const Command repack_command;
extern const Command retrace_command;
diff --git a/cli/cli_leaks.cpp b/cli/cli_leaks.cpp
new file mode 100644
index 00000000..1d28ec58
--- /dev/null
+++ b/cli/cli_leaks.cpp
@@ -0,0 +1,85 @@
+/*********************************************************************
+ *
+ * Copyright 2016 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 <iostream>
+
+#include "cli.hpp"
+#include "os_string.hpp"
+#include "os_process.hpp"
+#include "cli_resources.hpp"
+
+static const char *synopsis = "Check trace for object leaks.";
+
+static os::String
+find_command(void)
+{
+ return findScript("leaks.py");
+}
+
+static void
+usage(void)
+{
+ os::String command = find_command();
+
+ char *args[4];
+ args[0] = (char *) APITRACE_PYTHON_EXECUTABLE;
+ args[1] = (char *) command.str();
+ args[2] = (char *) "--help";
+ args[3] = NULL;
+
+ os::execute(args);
+}
+
+static int
+command(int argc, char *argv[])
+{
+ int i;
+
+ os::String command = find_command();
+
+ os::String apitracePath = os::getProcessName();
+
+ std::vector<const char *> args;
+ args.push_back("python");
+ args.push_back(command.str());
+ args.push_back("--apitrace");
+ args.push_back(apitracePath.str());
+ for (i = 1; i < argc; i++) {
+ args.push_back(argv[i]);
+ }
+ args.push_back(NULL);
+
+ return os::execute((char * const *)&args[0]);
+}
+
+const Command leaks_command = {
+ "leaks",
+ synopsis,
+ usage,
+ command
+};
diff --git a/cli/cli_main.cpp b/cli/cli_main.cpp
index 2317be28..b475bd3b 100644
--- a/cli/cli_main.cpp
+++ b/cli/cli_main.cpp
@@ -71,6 +71,7 @@ static const Command * commands[] = {
&diff_images_command,
&dump_command,
&dump_images_command,
+ &leaks_command,
&pickle_command,
&sed_command,
&repack_command,