1LIBTRACECMD(3)                 libtracefs Manual                LIBTRACECMD(3)
2
3
4

NAME

6       tracecmd_buffer_instances, tracecmd_buffer_instance_name,
7       tracecmd_buffer_instance_handle - Read tracing instances from a trace
8       file.
9

SYNOPSIS

11       #include <trace-cmd.h>
12
13       int tracecmd_buffer_instances(struct tracecmd_input *handle);
14       const char *tracecmd_buffer_instance_name(struct tracecmd_input *handle, int indx);
15       struct tracecmd_input *tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx);
16

DESCRIPTION

18       This set of APIs can be used to get information and read tracing data
19       from tracing instances stored in a trace file.
20
21       The tracecmd_buffer_instances() function gets the number of tracing
22       instances recorded in a trace file. The top instance is not counted.
23       The handle is a tracecmd_input handler returned by
24       tracecmd_open_head().
25
26       The tracecmd_buffer_instance_name() function gets the name of the
27       tracing instance with given index indx, recorded in a trace file. The
28       indx is a number in the interval [0 .. count-1], where count is the
29       number returned by tracecmd_buffer_instances(). The handle is a
30       tracecmd_input handler returned by tracecmd_open_head().
31
32       The tracecmd_buffer_instance_handle() allocates and initializes a
33       tracecmd_input handle, associated with trace instance with index indx
34       from a trace file. The handle is a tracecmd_input handler returned by
35       tracecmd_open_head(). The indx is a number in the interval [0 ..
36       count-1], where count is the number returned by
37       tracecmd_buffer_instances().
38

RETURN VALUE

40       The tracecmd_buffer_instances() function returns the number of tracing
41       instances recorded in a trace file.
42
43       The tracecmd_buffer_instance_name() function returns a string, the name
44       of a tracing instance, or NULL in case of an error The string must not
45       be freed.
46
47       The tracecmd_buffer_instance_handle() function returns a pointer to
48       newly allocated tracecmd_input handler or NULL in case if an error. The
49       returned handler must be closed by tracecmd_close()(3)
50

EXAMPLE

52           #include <trace-cmd.h>
53           ...
54           struct tracecmd_input *handle = tracecmd_open_head("trace.dat");
55                   if (!handle) {
56                           /* Failed to open trace.dat file */
57                   }
58           ...
59           int num = tracecmd_buffer_instances(handle);
60
61                   while(num) {
62                           struct tracecmd_input *h;
63                           char *name;
64
65                           name = tracecmd_buffer_instance_name(handle, num);
66                           if (!name) {
67                                   /* Failed to get name of instance num */
68                           }
69                           h = tracecmd_buffer_instance_handle(handle, num);
70                           if (!h) {
71                                   /* Failed to initialize handler for instance num */
72                           }
73
74                           ...
75                           tracecmd_close(h);
76                           num--;
77                   }
78           ...
79                   tracecmd_close(handle);
80

FILES

82           trace-cmd.h
83                   Header file to include in order to have access to the library APIs.
84           -ltracecmd
85                   Linker switch to add when building a program that uses the library.
86

SEE ALSO

88       libtracefs(3), libtraceevent(3), trace-cmd(1) trace-cmd.dat(5)
89

AUTHOR

91           Steven Rostedt <rostedt@goodmis.org[1]>
92           Tzvetomir Stoyanov <tz.stoyanov@gmail.com[2]>
93

REPORTING BUGS

95       Report bugs to <linux-trace-devel@vger.kernel.org[3]>
96

LICENSE

98       libtracecmd is Free Software licensed under the GNU LGPL 2.1
99

RESOURCES

101       https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/
102

COPYING

104       Copyright (C) 2020 VMware, Inc. Free use of this software is granted
105       under the terms of the GNU Public License (GPL).
106

NOTES

108        1. rostedt@goodmis.org
109           mailto:rostedt@goodmis.org
110
111        2. tz.stoyanov@gmail.com
112           mailto:tz.stoyanov@gmail.com
113
114        3. linux-trace-devel@vger.kernel.org
115           mailto:linux-trace-devel@vger.kernel.org
116
117
118
119libtracefs                        07/22/2021                    LIBTRACECMD(3)
Impressum