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 **************************************************************************/
29 #include <limits.h> // for CHAR_MAX
39 #include "os_string.hpp"
41 #include "trace_callset.hpp"
42 #include "trace_parser.hpp"
43 #include "trace_writer.hpp"
45 #define STRNCMP_LITERAL(var, literal) strncmp((var), (literal), sizeof (literal) -1)
47 static const char *synopsis = "Create a new trace by trimming an existing trace.";
53 << "usage: apitrace trim [OPTIONS] TRACE_FILE...\n"
56 " -h, --help Show detailed help for trim options and exit\n"
57 " --calls=CALLSET Include specified calls in the trimmed output.\n"
58 " --frames=FRAMESET Include specified frames in the trimmed output.\n"
59 " --deps Include additional calls to satisfy dependencies\n"
60 " --no-deps Do not include calls from dependency analysis\n"
61 " --prune Omit uninteresting calls from the trace output\n"
62 " --no-prune Do not prune uninteresting calls from the trace.\n"
63 " -x, --exact Trim exactly to calls specified in --calls/--frames\n"
64 " Equivalent to both --no-deps and --no-prune\n"
65 " --print-callset Print the final set of calls included in output\n"
66 " --thread=THREAD_ID Only retain calls from specified thread\n"
67 " -o, --output=TRACE_FILE Output trace file\n"
75 << "usage: apitrace trim [OPTIONS] TRACE_FILE...\n"
78 " -h, --help Show this help message and exit\n"
80 " --calls=CALLSET Include specified calls in the trimmed output.\n"
81 " --frames=FRAMESET Include specified frames in the trimmed output.\n"
82 " Note that due to dependency analysis and pruning\n"
83 " of uninteresting calls the resulting trace may\n"
84 " include more and less calls than specified.\n"
85 " See --no-deps, --no-prune, and --exact to change\n"
88 " --deps Perform dependency analysis and include dependent\n"
89 " calls as needed, (even if those calls were not\n"
90 " explicitly requested with --calls or --frames).\n"
91 " This is the default behavior. See --no-deps and\n"
92 " --exact to change the behavior.\n"
94 " --no-deps Do not perform dependency analysis. In this mode\n"
95 " the trimmed trace will never include calls from\n"
96 " outside what is specified in --calls or --frames.\n"
98 " --prune Omit calls with no side effects, even if the call\n"
99 " is within the range specified by --calls/--frames.\n"
100 " This is the default behavior. See --no-prune.\n"
102 " --no-prune Do not prune uninteresting calls from the trace.\n"
103 " In this mode the trimmed trace will never omit\n"
104 " any calls within the user-specified range.\n"
106 " -x, --exact Trim the trace to exactly the calls specified in\n"
107 " --calls and --frames. This option is equivalent\n"
108 " to passing both --no-deps and --no-prune.\n"
110 " --print-callset Print to stdout the final set of calls included\n"
111 " in the trim output. This can be useful for\n"
112 " debugging trim operations by using a modified\n"
113 " callset on the command-line along with --exact.\n"
114 " Use --calls=@<file> to read callset from a file.\n"
116 " --thread=THREAD_ID Only retain calls from specified thread\n"
118 " -o, --output=TRACE_FILE Output trace file\n"
124 CALLS_OPT = CHAR_MAX + 1,
135 shortOptions = "ho:x";
137 const static struct option
139 {"help", no_argument, 0, 'h'},
140 {"calls", required_argument, 0, CALLS_OPT},
141 {"frames", required_argument, 0, FRAMES_OPT},
142 {"deps", no_argument, 0, DEPS_OPT},
143 {"no-deps", no_argument, 0, NO_DEPS_OPT},
144 {"prune", no_argument, 0, PRUNE_OPT},
145 {"no-prune", no_argument, 0, NO_PRUNE_OPT},
146 {"exact", no_argument, 0, 'x'},
147 {"thread", required_argument, 0, THREAD_OPT},
148 {"output", required_argument, 0, 'o'},
149 {"print-callset", no_argument, 0, PRINT_CALLSET_OPT},
153 struct stringCompare {
154 bool operator() (const char *a, const char *b) const {
155 return strcmp(a, b) < 0;
159 class TraceAnalyzer {
160 /* Maps for tracking resource dependencies between calls. */
161 std::map<std::string, std::set<unsigned> > resources;
162 std::map<std::string, std::set<std::string> > dependencies;
164 /* Maps for tracking OpenGL state. */
165 std::map<GLenum, unsigned> texture_map;
167 /* The final set of calls required. This consists of calls added
168 * explicitly with the require() method as well as all calls
169 * implicitly required by those through resource dependencies. */
170 std::set<unsigned> required;
172 bool transformFeedbackActive;
173 bool framebufferObjectActive;
175 GLuint activeProgram;
177 /* Rendering often has no side effects, but it can in some cases,
178 * (such as when transform feedback is active, or when rendering
179 * targets a framebuffer object). */
180 bool renderingHasSideEffect() {
181 return transformFeedbackActive || framebufferObjectActive;
184 /* Provide: Record that the given call affects the given resource
185 * as a side effect. */
186 void provide(std::string resource, trace::CallNo call_no) {
187 resources[resource].insert(call_no);
190 /* Like provide, but with a simply-formatted string, (appending an
191 * integer to the given string). */
192 void providef(std::string resource, int resource_no, trace::CallNo call_no) {
193 std::stringstream ss;
194 ss << resource << resource_no;
195 provide(ss.str(), call_no);
198 /* Link: Establish a dependency between resource 'resource' and
199 * resource 'dependency'. This dependency is captured by name so
200 * that if the list of calls that provide 'dependency' grows
201 * before 'resource' is consumed, those calls will still be
203 void link(std::string resource, std::string dependency) {
204 dependencies[resource].insert(dependency);
207 /* Like link, but with a simply-formatted string, (appending an
208 * integer to the given string). */
209 void linkf(std::string resource, std::string dependency, int dep_no) {
211 std::stringstream ss;
212 ss << dependency << dep_no;
213 link(resource, ss.str());
216 /* Unlink: Remove dependency from 'resource' on 'dependency'. */
217 void unlink(std::string resource, std::string dependency) {
218 dependencies[resource].erase(dependency);
219 if (dependencies[resource].size() == 0) {
220 dependencies.erase(resource);
224 /* Like unlink, but with a simply-formated string, (appending an
225 * integer to the given string). */
226 void unlinkf(std::string resource, std::string dependency, int dep_no) {
228 std::stringstream ss;
229 ss << dependency << dep_no;
230 unlink(resource, ss.str());
233 /* Unlink all: Remove dependencies from 'resource' to all other
235 void unlinkAll(std::string resource) {
236 dependencies.erase(resource);
239 /* Resolve: Recursively compute all calls providing 'resource',
240 * (including linked dependencies of 'resource' on other
242 std::set<unsigned> resolve(std::string resource) {
243 std::set<std::string> *deps;
244 std::set<std::string>::iterator dep;
246 std::set<unsigned> *calls;
247 std::set<unsigned>::iterator call;
249 std::set<unsigned> result, deps_set;
251 /* Recursively chase dependencies. */
252 if (dependencies.count(resource)) {
253 deps = &dependencies[resource];
254 for (dep = deps->begin(); dep != deps->end(); dep++) {
255 deps_set = resolve(*dep);
256 for (call = deps_set.begin(); call != deps_set.end(); call++) {
257 result.insert(*call);
262 /* Also look for calls that directly provide 'resource' */
263 if (resources.count(resource)) {
264 calls = &resources[resource];
265 for (call = calls->begin(); call != calls->end(); call++) {
266 result.insert(*call);
273 /* Consume: Resolve all calls that provide the given resource, and
274 * add them to the required list. Then clear the call list for
275 * 'resource' along with any dependencies. */
276 void consume(std::string resource) {
278 std::set<unsigned> calls;
279 std::set<unsigned>::iterator call;
281 calls = resolve(resource);
283 dependencies.erase(resource);
284 resources.erase(resource);
286 for (call = calls.begin(); call != calls.end(); call++) {
287 required.insert(*call);
291 void stateTrackPreCall(trace::Call *call) {
293 const char *name = call->name();
295 if (strcmp(name, "glBegin") == 0) {
296 insideBeginEnd = true;
300 if (strcmp(name, "glBeginTransformFeedback") == 0) {
301 transformFeedbackActive = true;
305 if (strcmp(name, "glBindTexture") == 0) {
309 target = static_cast<GLenum>(call->arg(0).toSInt());
310 texture = call->arg(1).toUInt();
313 texture_map.erase(target);
315 texture_map[target] = texture;
321 if (strcmp(name, "glUseProgram") == 0) {
322 activeProgram = call->arg(0).toUInt();
325 if (strcmp(name, "glBindFramebuffer") == 0) {
329 target = static_cast<GLenum>(call->arg(0).toSInt());
330 framebuffer = call->arg(1).toUInt();
332 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) {
333 if (framebuffer == 0) {
334 framebufferObjectActive = false;
336 framebufferObjectActive = true;
343 void stateTrackPostCall(trace::Call *call) {
345 const char *name = call->name();
347 if (strcmp(name, "glEnd") == 0) {
348 insideBeginEnd = false;
352 if (strcmp(name, "glEndTransformFeedback") == 0) {
353 transformFeedbackActive = false;
357 /* If this swapbuffers was included in the trace then it will
358 * have already consumed all framebuffer dependencies. If not,
359 * then clear them now so that they don't carry over into the
361 if (call->flags & trace::CALL_FLAG_SWAP_RENDERTARGET &&
362 call->flags & trace::CALL_FLAG_END_FRAME) {
363 dependencies.erase("framebuffer");
364 resources.erase("framebuffer");
369 void recordSideEffects(trace::Call *call) {
371 const char *name = call->name();
373 /* If call is flagged as no side effects, then we are done here. */
374 if (call->flags & trace::CALL_FLAG_NO_SIDE_EFFECTS) {
378 /* Similarly, swap-buffers calls don't have interesting side effects. */
379 if (call->flags & trace::CALL_FLAG_SWAP_RENDERTARGET &&
380 call->flags & trace::CALL_FLAG_END_FRAME) {
384 if (strcmp(name, "glGenTextures") == 0) {
385 const trace::Array *textures = dynamic_cast<const trace::Array *>(&call->arg(1));
390 for (i = 0; i < textures->size(); i++) {
391 texture = textures->values[i]->toUInt();
392 providef("texture-", texture, call->no);
398 if (strcmp(name, "glBindTexture") == 0) {
402 std::stringstream ss_target, ss_texture;
404 target = static_cast<GLenum>(call->arg(0).toSInt());
405 texture = call->arg(1).toUInt();
407 ss_target << "texture-target-" << target;
408 ss_texture << "texture-" << texture;
410 resources.erase(ss_target.str());
411 provide(ss_target.str(), call->no);
413 unlinkAll(ss_target.str());
414 link(ss_target.str(), ss_texture.str());
419 /* FIXME: Need to handle glMultTexImage and friends. */
420 if (STRNCMP_LITERAL(name, "glTexImage") == 0 ||
421 STRNCMP_LITERAL(name, "glTexSubImage") == 0 ||
422 STRNCMP_LITERAL(name, "glCopyTexImage") == 0 ||
423 STRNCMP_LITERAL(name, "glCopyTexSubImage") == 0 ||
424 STRNCMP_LITERAL(name, "glCompressedTexImage") == 0 ||
425 STRNCMP_LITERAL(name, "glCompressedTexSubImage") == 0 ||
426 strcmp(name, "glInvalidateTexImage") == 0 ||
427 strcmp(name, "glInvalidateTexSubImage") == 0) {
429 std::set<unsigned> *calls;
430 std::set<unsigned>::iterator c;
431 std::stringstream ss_target, ss_texture;
433 GLenum target = static_cast<GLenum>(call->arg(0).toSInt());
435 ss_target << "texture-target-" << target;
436 ss_texture << "texture-" << texture_map[target];
438 /* The texture resource depends on this call and any calls
439 * providing the given texture target. */
440 provide(ss_texture.str(), call->no);
442 if (resources.count(ss_target.str())) {
443 calls = &resources[ss_target.str()];
444 for (c = calls->begin(); c != calls->end(); c++) {
445 provide(ss_texture.str(), *c);
452 if (strcmp(name, "glEnable") == 0) {
455 cap = static_cast<GLenum>(call->arg(0).toSInt());
457 if (cap == GL_TEXTURE_1D ||
458 cap == GL_TEXTURE_2D ||
459 cap == GL_TEXTURE_3D ||
460 cap == GL_TEXTURE_CUBE_MAP)
462 linkf("render-state", "texture-target-", cap);
465 provide("state", call->no);
469 if (strcmp(name, "glDisable") == 0) {
472 cap = static_cast<GLenum>(call->arg(0).toSInt());
474 if (cap == GL_TEXTURE_1D ||
475 cap == GL_TEXTURE_2D ||
476 cap == GL_TEXTURE_3D ||
477 cap == GL_TEXTURE_CUBE_MAP)
479 unlinkf("render-state", "texture-target-", cap);
482 provide("state", call->no);
486 if (strcmp(name, "glCreateShader") == 0 ||
487 strcmp(name, "glCreateShaderObjectARB") == 0) {
489 GLuint shader = call->ret->toUInt();
490 providef("shader-", shader, call->no);
494 if (strcmp(name, "glShaderSource") == 0 ||
495 strcmp(name, "glShaderSourceARB") == 0 ||
496 strcmp(name, "glCompileShader") == 0 ||
497 strcmp(name, "glCompileShaderARB") == 0 ||
498 strcmp(name, "glGetShaderiv") == 0 ||
499 strcmp(name, "glGetShaderInfoLog") == 0) {
501 GLuint shader = call->arg(0).toUInt();
502 providef("shader-", shader, call->no);
506 if (strcmp(name, "glCreateProgram") == 0 ||
507 strcmp(name, "glCreateProgramObjectARB") == 0) {
509 GLuint program = call->ret->toUInt();
510 providef("program-", program, call->no);
514 if (strcmp(name, "glAttachShader") == 0 ||
515 strcmp(name, "glAttachObjectARB") == 0) {
517 GLuint program, shader;
518 std::stringstream ss_program, ss_shader;
520 program = call->arg(0).toUInt();
521 shader = call->arg(1).toUInt();
523 ss_program << "program-" << program;
524 ss_shader << "shader-" << shader;
526 link(ss_program.str(), ss_shader.str());
527 provide(ss_program.str(), call->no);
532 if (strcmp(name, "glDetachShader") == 0 ||
533 strcmp(name, "glDetachObjectARB") == 0) {
535 GLuint program, shader;
536 std::stringstream ss_program, ss_shader;
538 program = call->arg(0).toUInt();
539 shader = call->arg(1).toUInt();
541 ss_program << "program-" << program;
542 ss_shader << "shader-" << shader;
544 unlink(ss_program.str(), ss_shader.str());
549 if (strcmp(name, "glUseProgram") == 0 ||
550 strcmp(name, "glUseProgramObjectARB") == 0) {
554 program = call->arg(0).toUInt();
556 unlinkAll("render-program-state");
559 unlink("render-state", "render-program-state");
560 provide("state", call->no);
562 std::stringstream ss;
564 ss << "program-" << program;
566 link("render-state", "render-program-state");
567 link("render-program-state", ss.str());
569 provide(ss.str(), call->no);
575 if (strcmp(name, "glGetUniformLocation") == 0 ||
576 strcmp(name, "glGetUniformLocationARB") == 0 ||
577 strcmp(name, "glGetFragDataLocation") == 0 ||
578 strcmp(name, "glGetFragDataLocationEXT") == 0 ||
579 strcmp(name, "glGetSubroutineUniformLocation") == 0 ||
580 strcmp(name, "glGetProgramResourceLocation") == 0 ||
581 strcmp(name, "glGetProgramResourceLocationIndex") == 0 ||
582 strcmp(name, "glGetVaryingLocationNV") == 0) {
584 GLuint program = call->arg(0).toUInt();
586 providef("program-", program, call->no);
591 /* For any call that accepts 'location' as its first argument,
592 * perform a lookup in our location->program map and add a
593 * dependence on the program we find there. */
594 if (call->sig->num_args > 0 &&
595 strcmp(call->sig->arg_names[0], "location") == 0) {
597 providef("program-", activeProgram, call->no);
601 /* FIXME: We cut a huge swath by assuming that any unhandled
602 * call that has a first argument named "program" should not
603 * be included in the trimmed output unless the program of
604 * that number is also included.
606 * This heuristic is correct for many cases, but we should
607 * actually carefully verify if this includes some calls
608 * inappropriately, or if it misses some.
610 if (strcmp(name, "glLinkProgram") == 0 ||
611 strcmp(name, "glLinkProgramARB") == 0 ||
612 (call->sig->num_args > 0 &&
613 (strcmp(call->sig->arg_names[0], "program") == 0 ||
614 strcmp(call->sig->arg_names[0], "programObj") == 0))) {
616 GLuint program = call->arg(0).toUInt();
617 providef("program-", program, call->no);
621 /* Handle all rendering operations, (even though only glEnd is
622 * flagged as a rendering operation we treat everything from
623 * glBegin through glEnd as a rendering operation). */
624 if (call->flags & trace::CALL_FLAG_RENDER ||
627 std::set<unsigned> calls;
628 std::set<unsigned>::iterator c;
630 provide("framebuffer", call->no);
632 calls = resolve("render-state");
634 for (c = calls.begin(); c != calls.end(); c++) {
635 provide("framebuffer", *c);
638 /* In some cases, rendering has side effects beyond the
639 * framebuffer update. */
640 if (renderingHasSideEffect()) {
641 provide("state", call->no);
642 for (c = calls.begin(); c != calls.end(); c++) {
643 provide("state", *c);
650 /* By default, assume this call affects the state somehow. */
651 resources["state"].insert(call->no);
654 void requireDependencies(trace::Call *call) {
656 /* Swap-buffers calls depend on framebuffer state. */
657 if (call->flags & trace::CALL_FLAG_SWAP_RENDERTARGET &&
658 call->flags & trace::CALL_FLAG_END_FRAME) {
659 consume("framebuffer");
662 /* By default, just assume this call depends on generic state. */
668 TraceAnalyzer(): transformFeedbackActive(false),
669 framebufferObjectActive(false),
670 insideBeginEnd(false)
675 /* Analyze this call by tracking state and recording all the
676 * resources provided by this call as side effects.. */
677 void analyze(trace::Call *call) {
679 stateTrackPreCall(call);
681 recordSideEffects(call);
683 stateTrackPostCall(call);
686 /* Require this call and all of its dependencies to be included in
687 * the final trace. */
688 void require(trace::Call *call) {
690 /* First, find and insert all calls that this call depends on. */
691 requireDependencies(call);
693 /* Then insert this call itself. */
694 required.insert(call->no);
697 /* Return a set of all the required calls, (both those calls added
698 * explicitly with require() and those implicitly depended
700 std::set<unsigned> *get_required(void) {
705 struct trim_options {
706 /* Calls to be included in trace. */
707 trace::CallSet calls;
709 /* Frames to be included in trace. */
710 trace::CallSet frames;
712 /* Whether dependency analysis should be performed. */
713 bool dependency_analysis;
715 /* Whether uninteresting calls should be pruned.. */
716 bool prune_uninteresting;
718 /* Output filename */
721 /* Emit only calls from this thread (-1 == all threads) */
724 /* Print resulting callset */
729 trim_trace(const char *filename, struct trim_options *options)
731 trace::ParseBookmark beginning;
733 TraceAnalyzer analyzer;
734 std::set<unsigned> *required;
736 int call_range_first, call_range_last;
738 if (!p.open(filename)) {
739 std::cerr << "error: failed to open " << filename << "\n";
743 /* Mark the beginning so we can return here for pass 2. */
744 p.getBookmark(beginning);
746 /* In pass 1, analyze which calls are needed. */
749 while ((call = p.parse_call())) {
751 /* There's no use doing any work past the last call or frame
752 * requested by the user. */
753 if (call->no > options->calls.getLast() ||
754 frame > options->frames.getLast()) {
760 /* If requested, ignore all calls not belonging to the specified thread. */
761 if (options->thread != -1 && call->thread_id != options->thread) {
765 /* Also, prune if uninteresting (unless the user asked for no pruning. */
766 if (options->prune_uninteresting && call->flags & trace::CALL_FLAG_UNINTERESTING) {
770 /* If this call is included in the user-specified call set,
771 * then require it (and all dependencies) in the trimmed
773 if (options->calls.contains(*call) ||
774 options->frames.contains(frame, call->flags)) {
776 analyzer.require(call);
779 /* Regardless of whether we include this call or not, we do
780 * some dependency tracking (unless disabled by the user). We
781 * do this even for calls we have included in the output so
782 * that any state updates get performed. */
783 if (options->dependency_analysis) {
784 analyzer.analyze(call);
788 if (call->flags & trace::CALL_FLAG_END_FRAME)
794 /* Prepare output file and writer for output. */
795 if (options->output.empty()) {
796 os::String base(filename);
797 base.trimExtension();
799 options->output = std::string(base.str()) + std::string("-trim.trace");
802 trace::Writer writer;
803 if (!writer.open(options->output.c_str())) {
804 std::cerr << "error: failed to create " << filename << "\n";
808 /* Reset bookmark for pass 2. */
809 p.setBookmark(beginning);
811 /* In pass 2, emit the calls that are required. */
812 required = analyzer.get_required();
815 call_range_first = -1;
816 call_range_last = -1;
817 while ((call = p.parse_call())) {
819 /* There's no use doing any work past the last call or frame
820 * requested by the user. */
821 if (call->no > options->calls.getLast() ||
822 frame > options->frames.getLast()) {
827 if (required->find(call->no) != required->end()) {
828 writer.writeCall(call);
830 if (options->print_callset) {
831 if (call_range_first < 0) {
832 call_range_first = call->no;
833 printf ("%d", call_range_first);
834 } else if (call->no != call_range_last + 1) {
835 if (call_range_last != call_range_first)
836 printf ("-%d", call_range_last);
837 call_range_first = call->no;
838 printf (",%d", call_range_first);
840 call_range_last = call->no;
844 if (call->flags & trace::CALL_FLAG_END_FRAME) {
851 if (options->print_callset) {
852 if (call_range_last != call_range_first)
853 printf ("-%d\n", call_range_last);
856 std::cout << "Trimmed trace is available as " << options->output << "\n";
862 command(int argc, char *argv[])
864 struct trim_options options;
866 options.calls = trace::CallSet(trace::FREQUENCY_NONE);
867 options.frames = trace::CallSet(trace::FREQUENCY_NONE);
868 options.dependency_analysis = true;
869 options.prune_uninteresting = true;
872 options.print_callset = 0;
875 while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) {
881 options.calls = trace::CallSet(optarg);
884 options.frames = trace::CallSet(optarg);
887 options.dependency_analysis = true;
890 options.dependency_analysis = false;
893 options.prune_uninteresting = true;
896 options.prune_uninteresting = false;
899 options.dependency_analysis = false;
900 options.prune_uninteresting = false;
903 options.thread = atoi(optarg);
906 options.output = optarg;
908 case PRINT_CALLSET_OPT:
909 options.print_callset = 1;
912 std::cerr << "error: unexpected option `" << opt << "`\n";
918 /* If neither of --calls nor --frames was set, default to the
919 * entire set of calls. */
920 if (options.calls.empty() && options.frames.empty()) {
921 options.calls = trace::CallSet(trace::FREQUENCY_ALL);
924 if (optind >= argc) {
925 std::cerr << "error: apitrace trim requires a trace file as an argument.\n";
930 if (argc > optind + 1) {
931 std::cerr << "error: extraneous arguments:";
932 for (int i = optind + 1; i < argc; i++) {
933 std::cerr << " " << argv[i];
940 return trim_trace(argv[optind], &options);
943 const Command trim_command = {