1 /**************************************************************************
3 * Copyright 2010 VMware, Inc.
4 * Copyright 2011 Intel corporation
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 **************************************************************************/
31 #include "os_string.hpp"
33 #include "trace_parser.hpp"
34 #include "trace_copier.hpp"
36 static const char *synopsis = "Create a new trace by trimming an existing trace.";
42 << "usage: apitrace trim <trace-file>\n"
47 command(int argc, char *argv[])
51 for (i = 0; i < argc; ++i) {
52 const char *arg = argv[i];
58 if (!strcmp(arg, "--")) {
60 } else if (!strcmp(arg, "--help")) {
64 std::cerr << "error: unknown option " << arg << "\n";
71 std::cerr << "Error: apitrace trim requires a trace file as an argument.\n";
78 if (!p.open(argv[i])) {
79 std::cerr << "error: failed to open " << argv[i] << "\n";
83 os::String base(argv[i]);
86 std::string output = std::string(base.str()) + std::string("-trim.trace");
88 trace::Copier copier(output.c_str());
91 while ((call = p.parse_call())) {
96 std::cout << "Trimmed trace is available as " << output << "\n";
101 const Command trim_command = {