4 * Babeltrace Trace Converter
6 * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
8 * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 #include <babeltrace/babeltrace.h>
30 #include <babeltrace/format.h>
31 #include <babeltrace/context.h>
32 #include <babeltrace/context-internal.h>
33 #include <babeltrace/ctf/types.h>
34 #include <babeltrace/ctf/events.h>
35 /* TODO: fix object model for format-agnostic callbacks */
36 #include <babeltrace/ctf/events-internal.h>
37 #include <babeltrace/ctf/iterator.h>
38 #include <babeltrace/ctf-text/types.h>
39 #include <babeltrace/debuginfo.h>
41 #include <babeltrace/iterator.h>
47 #include <sys/types.h>
54 #include <babeltrace/ctf-ir/metadata.h> /* for clocks */
56 #define PARTIAL_ERROR_SLEEP 3 /* 3 seconds */
58 #define DEFAULT_FILE_ARRAY_SIZE 1
60 #define NET_URL_PREFIX "net://"
61 #define NET4_URL_PREFIX "net4://"
62 #define NET6_URL_PREFIX "net6://"
64 static char *opt_input_format
, *opt_output_format
;
67 * We are not freeing opt_input_paths ipath elements when exiting from
68 * main() for backward compatibility with libpop 0.13, which does not
69 * allocate copies for arguments returned by poptGetArg(), and for
70 * general compatibility with the documented behavior. This is known to
71 * cause a small memory leak with libpop 0.16.
73 static GPtrArray
*opt_input_paths
;
74 static char *opt_output_path
;
75 static int opt_stream_intersection
;
77 static struct bt_format
*fmt_read
;
80 void strlower(char *str
)
83 *str
= tolower((int) *str
);
106 OPT_CLOCK_FORCE_CORRELATE
,
107 OPT_STREAM_INTERSECTION
,
112 * We are _not_ using POPT_ARG_STRING ability to store directly into
113 * variables, because we want to cast the return to non-const, which is
114 * not possible without using poptGetOptArg explicitly. This helps us
115 * controlling memory allocation correctly without making assumptions
116 * about undocumented behaviors. poptGetOptArg is documented as
117 * requiring the returned const char * to be freed by the caller.
119 static struct poptOption long_options
[] = {
120 /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
121 { "output", 'w', POPT_ARG_STRING
, NULL
, OPT_OUTPUT_PATH
, NULL
, NULL
},
122 { "input-format", 'i', POPT_ARG_STRING
, NULL
, OPT_INPUT_FORMAT
, NULL
, NULL
},
123 { "output-format", 'o', POPT_ARG_STRING
, NULL
, OPT_OUTPUT_FORMAT
, NULL
, NULL
},
124 { "help", 'h', POPT_ARG_NONE
, NULL
, OPT_HELP
, NULL
, NULL
},
125 { "list", 'l', POPT_ARG_NONE
, NULL
, OPT_LIST
, NULL
, NULL
},
126 { "verbose", 'v', POPT_ARG_NONE
, NULL
, OPT_VERBOSE
, NULL
, NULL
},
127 { "debug", 'd', POPT_ARG_NONE
, NULL
, OPT_DEBUG
, NULL
, NULL
},
128 { "names", 'n', POPT_ARG_STRING
, NULL
, OPT_NAMES
, NULL
, NULL
},
129 { "fields", 'f', POPT_ARG_STRING
, NULL
, OPT_FIELDS
, NULL
, NULL
},
130 { "no-delta", 0, POPT_ARG_NONE
, NULL
, OPT_NO_DELTA
, NULL
, NULL
},
131 { "clock-offset", 0, POPT_ARG_STRING
, NULL
, OPT_CLOCK_OFFSET
, NULL
, NULL
},
132 { "clock-offset-ns", 0, POPT_ARG_STRING
, NULL
, OPT_CLOCK_OFFSET_NS
, NULL
, NULL
},
133 { "clock-cycles", 0, POPT_ARG_NONE
, NULL
, OPT_CLOCK_CYCLES
, NULL
, NULL
},
134 { "clock-seconds", 0, POPT_ARG_NONE
, NULL
, OPT_CLOCK_SECONDS
, NULL
, NULL
},
135 { "clock-date", 0, POPT_ARG_NONE
, NULL
, OPT_CLOCK_DATE
, NULL
, NULL
},
136 { "clock-gmt", 0, POPT_ARG_NONE
, NULL
, OPT_CLOCK_GMT
, NULL
, NULL
},
137 { "clock-force-correlate", 0, POPT_ARG_NONE
, NULL
, OPT_CLOCK_FORCE_CORRELATE
, NULL
, NULL
},
138 { "stream-intersection", 0, POPT_ARG_NONE
, NULL
, OPT_STREAM_INTERSECTION
, NULL
, NULL
},
139 #ifdef ENABLE_DEBUGINFO
140 { "debug-info-dir", 0, POPT_ARG_STRING
, NULL
, OPT_DEBUG_DIR
, NULL
, NULL
},
142 { NULL
, 0, 0, NULL
, 0, NULL
, NULL
},
145 static void list_formats(FILE *fp
)
148 bt_fprintf_format_list(fp
);
151 static void usage(FILE *fp
)
153 fprintf(fp
, "BabelTrace Trace Viewer and Converter %s\n\n", VERSION
);
154 fprintf(fp
, "usage : babeltrace [OPTIONS] FILE...\n");
156 fprintf(fp
, " FILE Input trace file(s) and/or directory(ies)\n");
157 fprintf(fp
, " (space-separated)\n");
158 fprintf(fp
, " -w, --output OUTPUT Output trace path (default: stdout)\n");
160 fprintf(fp
, " -i, --input-format FORMAT Input trace format (default: ctf)\n");
161 fprintf(fp
, " -o, --output-format FORMAT Output trace format (default: text)\n");
163 fprintf(fp
, " -h, --help This help message\n");
164 fprintf(fp
, " -l, --list List available formats\n");
165 fprintf(fp
, " -v, --verbose Verbose mode\n");
166 fprintf(fp
, " (or set BABELTRACE_VERBOSE environment variable)\n");
167 fprintf(fp
, " -d, --debug Debug mode\n");
168 fprintf(fp
, " (or set BABELTRACE_DEBUG environment variable)\n");
169 fprintf(fp
, " --no-delta Do not print time delta between consecutive events\n");
170 fprintf(fp
, " -n, --names name1<,name2,...> Print field names:\n");
171 fprintf(fp
, " (payload OR args OR arg)\n");
172 fprintf(fp
, " none, all, scope, header, (context OR ctx)\n");
173 fprintf(fp
, " (default: payload,context)\n");
174 fprintf(fp
, " -f, --fields name1<,name2,...> Print additional fields:\n");
175 fprintf(fp
, " all, trace, trace:hostname, trace:domain,\n");
176 fprintf(fp
, " trace:procname, trace:vpid, loglevel, emf, callsite.\n");
177 fprintf(fp
, " (default: trace:hostname,trace:procname,trace:vpid)\n");
178 fprintf(fp
, " --clock-cycles Timestamp in cycles\n");
179 fprintf(fp
, " --clock-offset seconds Clock offset in seconds\n");
180 fprintf(fp
, " --clock-offset-ns ns Clock offset in nanoseconds\n");
181 fprintf(fp
, " --clock-seconds Print the timestamps as [sec.ns]\n");
182 fprintf(fp
, " (default is: [hh:mm:ss.ns])\n");
183 fprintf(fp
, " --clock-date Print clock date\n");
184 fprintf(fp
, " --clock-gmt Print clock in GMT time zone (default: local time zone)\n");
185 fprintf(fp
, " --clock-force-correlate Assume that clocks are inherently correlated\n");
186 fprintf(fp
, " across traces.\n");
187 fprintf(fp
, " --stream-intersection Only print events when all streams are active.\n");
188 #ifdef ENABLE_DEBUGINFO
189 fprintf(fp
, " --debug-info-dir Directory in which to look for debugging information\n");
190 fprintf(fp
, " files. (default: /usr/lib/debug/)\n");
196 static int get_names_args(poptContext
*pc
)
198 char *str
, *strlist
, *strctx
;
201 opt_payload_field_names
= 0;
202 opt_context_field_names
= 0;
203 strlist
= (char *) poptGetOptArg(*pc
);
207 str
= strtok_r(strlist
, ",", &strctx
);
209 if (!strcmp(str
, "all"))
210 opt_all_field_names
= 1;
211 else if (!strcmp(str
, "scope"))
212 opt_scope_field_names
= 1;
213 else if (!strcmp(str
, "context") || !strcmp(str
, "ctx"))
214 opt_context_field_names
= 1;
215 else if (!strcmp(str
, "header"))
216 opt_header_field_names
= 1;
217 else if (!strcmp(str
, "payload") || !strcmp(str
, "args") || !strcmp(str
, "arg"))
218 opt_payload_field_names
= 1;
219 else if (!strcmp(str
, "none")) {
220 opt_all_field_names
= 0;
221 opt_scope_field_names
= 0;
222 opt_context_field_names
= 0;
223 opt_header_field_names
= 0;
224 opt_payload_field_names
= 0;
226 fprintf(stderr
, "[error] unknown field name type %s\n", str
);
230 } while ((str
= strtok_r(NULL
, ",", &strctx
)));
236 static int get_fields_args(poptContext
*pc
)
238 char *str
, *strlist
, *strctx
;
241 strlist
= (char *) poptGetOptArg(*pc
);
245 str
= strtok_r(strlist
, ",", &strctx
);
247 opt_trace_default_fields
= 0;
248 if (!strcmp(str
, "all"))
250 else if (!strcmp(str
, "trace"))
252 else if (!strcmp(str
, "trace:hostname"))
253 opt_trace_hostname_field
= 1;
254 else if (!strcmp(str
, "trace:domain"))
255 opt_trace_domain_field
= 1;
256 else if (!strcmp(str
, "trace:procname"))
257 opt_trace_procname_field
= 1;
258 else if (!strcmp(str
, "trace:vpid"))
259 opt_trace_vpid_field
= 1;
260 else if (!strcmp(str
, "loglevel"))
261 opt_loglevel_field
= 1;
262 else if (!strcmp(str
, "emf"))
264 else if (!strcmp(str
, "callsite"))
265 opt_callsite_field
= 1;
267 fprintf(stderr
, "[error] unknown field type %s\n", str
);
271 } while ((str
= strtok_r(NULL
, ",", &strctx
)));
278 * Return 0 if caller should continue, < 0 if caller should return
279 * error, > 0 if caller should exit without reporting error.
281 static int parse_options(int argc
, char **argv
)
289 return 1; /* exit cleanly */
292 pc
= poptGetContext(NULL
, argc
, (const char **) argv
, long_options
, 0);
293 poptReadDefaultConfig(pc
, 0);
296 opt_context_field_names
= 1;
297 opt_payload_field_names
= 1;
299 while ((opt
= poptGetNextOpt(pc
)) != -1) {
301 case OPT_OUTPUT_PATH
:
302 opt_output_path
= (char *) poptGetOptArg(pc
);
303 if (!opt_output_path
) {
308 case OPT_INPUT_FORMAT
:
309 opt_input_format
= (char *) poptGetOptArg(pc
);
310 if (!opt_input_format
) {
315 case OPT_OUTPUT_FORMAT
:
316 opt_output_format
= (char *) poptGetOptArg(pc
);
317 if (!opt_output_format
) {
324 ret
= 1; /* exit cleanly */
327 list_formats(stdout
);
331 babeltrace_verbose
= 1;
334 if (get_names_args(&pc
)) {
340 if (get_fields_args(&pc
)) {
346 babeltrace_debug
= 1;
351 case OPT_CLOCK_CYCLES
:
352 opt_clock_cycles
= 1;
354 case OPT_CLOCK_OFFSET
:
359 str
= (char *) poptGetOptArg(pc
);
361 fprintf(stderr
, "[error] Missing --clock-offset argument\n");
366 opt_clock_offset
= strtoull(str
, &endptr
, 0);
367 if (*endptr
!= '\0' || str
== endptr
|| errno
!= 0) {
368 fprintf(stderr
, "[error] Incorrect --clock-offset argument: %s\n", str
);
376 case OPT_CLOCK_SECONDS
:
377 opt_clock_seconds
= 1;
379 case OPT_CLOCK_OFFSET_NS
:
384 str
= (char *) poptGetOptArg(pc
);
386 fprintf(stderr
, "[error] Missing --clock-offset-ns argument\n");
391 opt_clock_offset_ns
= strtoull(str
, &endptr
, 0);
392 if (*endptr
!= '\0' || str
== endptr
|| errno
!= 0) {
393 fprintf(stderr
, "[error] Incorrect --clock-offset-ns argument: %s\n", str
);
408 case OPT_CLOCK_FORCE_CORRELATE
:
409 opt_clock_force_correlate
= 1;
411 case OPT_STREAM_INTERSECTION
:
412 opt_stream_intersection
= 1;
415 opt_debug_dir
= (char *) poptGetOptArg(pc
);
416 if (!opt_debug_dir
) {
428 ipath
= poptGetArg(pc
);
430 g_ptr_array_add(opt_input_paths
, (gpointer
) ipath
);
432 if (opt_input_paths
->len
== 0) {
444 static GPtrArray
*traversed_paths
= 0;
447 * traverse_trace_dir() is the callback function for File Tree Walk (nftw).
448 * it receives the path of the current entry (file, dir, link..etc) with
449 * a flag to indicate the type of the entry.
450 * if the entry being visited is a directory and contains a metadata file,
451 * then add the path to a global list to be processed later in
452 * add_traces_recursive.
454 static int traverse_trace_dir(const char *fpath
, const struct stat
*sb
,
455 int tflag
, struct FTW
*ftwbuf
)
463 dirfd
= open(fpath
, 0);
465 fprintf(stderr
, "[error] [Context] Unable to open trace "
466 "directory file descriptor.\n");
467 return 0; /* partial error */
469 metafd
= openat(dirfd
, "metadata", O_RDONLY
);
471 closeret
= close(dirfd
);
476 /* No meta data, just return */
481 closeret
= close(metafd
);
486 closeret
= close(dirfd
);
495 /* Add path to the global list */
496 if (traversed_paths
== NULL
) {
497 fprintf(stderr
, "[error] [Context] Invalid open path array.\n");
500 g_ptr_array_add(traversed_paths
, g_string_new(fpath
));
507 * bt_context_add_traces_recursive: Open a trace recursively
509 * Find each trace present in the subdirectory starting from the given
510 * path, and add them to the context. The packet_seek parameter can be
511 * NULL: this specify to use the default format packet_seek.
513 * Return: 0 on success, < 0 on failure, > 0 on partial failure.
514 * Unable to open toplevel: failure.
515 * Unable to open some subdirectory or file: warn and continue (partial
518 int bt_context_add_traces_recursive(struct bt_context
*ctx
, const char *path
,
519 const char *format_str
,
520 void (*packet_seek
)(struct bt_stream_pos
*pos
,
521 size_t offset
, int whence
))
523 int ret
= 0, trace_ids
= 0;
525 if ((strncmp(path
, NET4_URL_PREFIX
, sizeof(NET4_URL_PREFIX
) - 1)) == 0 ||
526 (strncmp(path
, NET6_URL_PREFIX
, sizeof(NET6_URL_PREFIX
) - 1)) == 0 ||
527 (strncmp(path
, NET_URL_PREFIX
, sizeof(NET_URL_PREFIX
) - 1)) == 0) {
528 ret
= bt_context_add_trace(ctx
,
529 path
, format_str
, packet_seek
, NULL
, NULL
);
531 fprintf(stderr
, "[warning] [Context] cannot open trace \"%s\" "
532 "for reading.\n", path
);
536 /* Should lock traversed_paths mutex here if used in multithread */
538 traversed_paths
= g_ptr_array_new();
539 ret
= nftw(path
, traverse_trace_dir
, 10, 0);
541 /* Process the array if ntfw did not return a fatal error */
545 for (i
= 0; i
< traversed_paths
->len
; i
++) {
546 GString
*trace_path
= g_ptr_array_index(traversed_paths
,
548 int trace_id
= bt_context_add_trace(ctx
,
555 fprintf(stderr
, "[warning] [Context] cannot open trace \"%s\" from %s "
556 "for reading.\n", trace_path
->str
, path
);
557 /* Allow to skip erroneous traces. */
558 ret
= 1; /* partial error */
562 g_string_free(trace_path
, TRUE
);
566 g_ptr_array_free(traversed_paths
, TRUE
);
567 traversed_paths
= NULL
;
569 /* Should unlock traversed paths mutex here if used in multithread */
572 * Return an error if no trace can be opened.
574 if (trace_ids
== 0) {
575 fprintf(stderr
, "[error] Cannot open any trace for reading.\n\n");
576 ret
= -ENOENT
; /* failure */
582 int trace_pre_handler(struct bt_trace_descriptor
*td_write
,
583 struct bt_context
*ctx
)
585 struct ctf_text_stream_pos
*sout
;
586 struct trace_collection
*tc
;
589 sout
= container_of(td_write
, struct ctf_text_stream_pos
,
592 if (!sout
->parent
.pre_trace_cb
)
596 for (i
= 0; i
< tc
->array
->len
; i
++) {
597 struct bt_trace_descriptor
*td
=
598 g_ptr_array_index(tc
->array
, i
);
600 ret
= sout
->parent
.pre_trace_cb(&sout
->parent
, td
);
602 fprintf(stderr
, "[error] Writing to trace pre handler failed.\n");
612 int trace_post_handler(struct bt_trace_descriptor
*td_write
,
613 struct bt_context
*ctx
)
615 struct ctf_text_stream_pos
*sout
;
616 struct trace_collection
*tc
;
619 sout
= container_of(td_write
, struct ctf_text_stream_pos
,
622 if (!sout
->parent
.post_trace_cb
)
626 for (i
= 0; i
< tc
->array
->len
; i
++) {
627 struct bt_trace_descriptor
*td
=
628 g_ptr_array_index(tc
->array
, i
);
630 ret
= sout
->parent
.post_trace_cb(&sout
->parent
, td
);
632 fprintf(stderr
, "[error] Writing to trace post handler failed.\n");
642 struct bt_ctf_iter
*iter_create_intersect(struct bt_context
*ctx
,
643 struct bt_iter_pos
**inter_begin_pos
,
644 struct bt_iter_pos
**inter_end_pos
)
646 uint64_t begin
= 0, end
= ULLONG_MAX
;
649 ret
= ctf_find_packets_intersection(ctx
, &begin
, &end
);
651 fprintf(stderr
, "[error] No intersection found between trace files.\n");
654 } else if (ret
!= 0) {
657 *inter_begin_pos
= bt_iter_create_time_pos(NULL
, begin
);
658 if (!(*inter_begin_pos
)) {
661 *inter_end_pos
= bt_iter_create_time_pos(NULL
, end
);
662 if (!(*inter_end_pos
)) {
667 * bt_ctf_iter does not take ownership of begin and end positions,
668 * so we return them to the caller who must still assume their ownership
669 * until the iterator is destroyed.
671 return bt_ctf_iter_create(ctx
, *inter_begin_pos
,
678 int convert_trace(struct bt_trace_descriptor
*td_write
,
679 struct bt_context
*ctx
)
681 struct bt_ctf_iter
*iter
;
682 struct ctf_text_stream_pos
*sout
;
683 struct bt_iter_pos
*begin_pos
= NULL
, *end_pos
= NULL
;
684 struct bt_ctf_event
*ctf_event
;
687 sout
= container_of(td_write
, struct ctf_text_stream_pos
,
690 if (!sout
->parent
.event_cb
) {
694 if (opt_stream_intersection
) {
695 iter
= iter_create_intersect(ctx
, &begin_pos
, &end_pos
);
697 begin_pos
= bt_iter_create_time_pos(NULL
, 0);
698 begin_pos
->type
= BT_SEEK_BEGIN
;
699 iter
= bt_ctf_iter_create(ctx
, begin_pos
, NULL
);
705 while ((ctf_event
= bt_ctf_iter_read_event(iter
))) {
706 ret
= sout
->parent
.event_cb(&sout
->parent
, ctf_event
->parent
->stream
);
708 fprintf(stderr
, "[error] Writing event failed.\n");
711 ret
= bt_iter_next(bt_ctf_get_iter(iter
));
719 bt_ctf_iter_destroy(iter
);
721 bt_iter_free_pos(begin_pos
);
722 bt_iter_free_pos(end_pos
);
726 int main(int argc
, char **argv
)
728 int ret
, partial_error
= 0, open_success
= 0;
729 struct bt_format
*fmt_write
;
730 struct bt_trace_descriptor
*td_write
;
731 struct bt_context
*ctx
;
734 opt_input_paths
= g_ptr_array_new();
736 ret
= parse_options(argc
, argv
);
738 fprintf(stderr
, "Error parsing options.\n\n");
740 g_ptr_array_free(opt_input_paths
, TRUE
);
742 } else if (ret
> 0) {
743 g_ptr_array_free(opt_input_paths
, TRUE
);
746 printf_verbose("Verbose mode active.\n");
747 printf_debug("Debug mode active.\n");
749 if (opt_input_format
)
750 strlower(opt_input_format
);
751 if (opt_output_format
)
752 strlower(opt_output_format
);
754 printf_verbose("Converting from directory(ies):\n");
755 for (i
= 0; i
< opt_input_paths
->len
; i
++) {
756 const char *ipath
= g_ptr_array_index(opt_input_paths
, i
);
757 printf_verbose(" %s\n", ipath
);
759 printf_verbose("Converting from format: %s\n",
760 opt_input_format
? : "ctf <default>");
761 printf_verbose("Converting to target: %s\n",
762 opt_output_path
? : "<stdout>");
763 printf_verbose("Converting to format: %s\n",
764 opt_output_format
? : "text <default>");
766 if (!opt_input_format
) {
767 opt_input_format
= strdup("ctf");
768 if (!opt_input_format
) {
773 if (!opt_output_format
) {
774 opt_output_format
= strdup("text");
775 if (!opt_output_format
) {
780 fmt_read
= bt_lookup_format(g_quark_from_static_string(opt_input_format
));
782 fprintf(stderr
, "[error] Format \"%s\" is not supported.\n\n",
787 fmt_write
= bt_lookup_format(g_quark_from_static_string(opt_output_format
));
789 fprintf(stderr
, "[error] format \"%s\" is not supported.\n\n",
795 ctx
= bt_context_create();
800 for (i
= 0; i
< opt_input_paths
->len
; i
++) {
801 const char *ipath
= g_ptr_array_index(opt_input_paths
, i
);
802 ret
= bt_context_add_traces_recursive(ctx
, ipath
,
803 opt_input_format
, NULL
);
805 fprintf(stderr
, "[error] opening trace \"%s\" for reading.\n\n",
807 } else if (ret
> 0) {
808 fprintf(stderr
, "[warning] errors occurred when opening trace \"%s\" for reading, continuing anyway.\n\n",
810 open_success
= 1; /* some traces were OK */
813 open_success
= 1; /* all traces were OK */
817 fprintf(stderr
, "[error] none of the specified trace paths could be opened.\n\n");
821 td_write
= fmt_write
->open_trace(opt_output_path
, O_RDWR
, NULL
, NULL
);
823 fprintf(stderr
, "Error opening trace \"%s\" for writing.\n\n",
824 opt_output_path
? : "<none>");
829 * Errors happened when opening traces, but we continue anyway.
830 * sleep to let user see the stderr output before stdout.
833 sleep(PARTIAL_ERROR_SLEEP
);
835 ret
= trace_pre_handler(td_write
, ctx
);
837 fprintf(stderr
, "Error in trace pre handle.\n\n");
838 goto error_copy_trace
;
841 /* For now, we support only CTF iterators */
842 if (fmt_read
->name
== g_quark_from_static_string("ctf")) {
843 ret
= convert_trace(td_write
, ctx
);
845 fprintf(stderr
, "Error printing trace.\n\n");
846 goto error_copy_trace
;
850 ret
= trace_post_handler(td_write
, ctx
);
852 fprintf(stderr
, "Error in trace post handle.\n\n");
853 goto error_copy_trace
;
856 fmt_write
->close_trace(td_write
);
859 printf_verbose("finished converting. Output written to:\n%s\n",
860 opt_output_path
? : "<stdout>");
865 fmt_write
->close_trace(td_write
);
871 /* teardown and exit */
873 free(opt_input_format
);
874 free(opt_output_format
);
875 free(opt_output_path
);
877 g_ptr_array_free(opt_input_paths
, TRUE
);