1 #LyX 1.5.5 created this file. For more info see http://www.lyx.org/
10 \font_typewriter default
11 \font_default_family default
17 \paperfontsize default
25 \paperorientation portrait
28 \paragraph_separation skip
30 \quotes_language english
33 \paperpagestyle default
34 \tracking_changes false
43 A Set of APIs for a Third-Generation Trace Viewer
48 Pierre-Marc Fournier, Michel Dagenais, Mathieu Desnoyers
53 <pierre-marc.fournier _at_ polymtl.ca>
62 École Polytechnique de Montréal
73 \begin_layout Standard
74 This document proposes some APIs for a trace viewing and analysis infrastructure.
77 \begin_layout Standard
78 Design choices were made based on the experience acquired by the design,
79 development and use of two previous generations of trace viewers, respectively
80 the Trace Visualizer from the Linux Trace Toolkit and its successor, the
81 LTTV from the LTTng tracing toolkit.
89 Provide an infrastructure for fast, interactive visualization and analysis
90 of huge traces (>10 GB) on standard workstations
94 \begin_layout Standard
95 Efficiency is of great importance.
96 It is tempting to think that as computers get faster, it will be possible
97 to run more complex analyses on traces in a shorter time.
98 In fact, the size of the traces grows as computers get more powerful, because
99 they do more operations than before in the same amount of time and therefore
100 generate more events.
101 The current tendency to parallelize systems is another factor that results
110 \begin_layout Itemize
111 Allow efficient manipulation of traces that are larger than the system memory
114 \begin_layout Itemize
115 Support processing of live traces
118 \begin_layout Itemize
119 Allow merging of traces of different formats
122 \begin_layout Itemize
123 Design with both command line utilities (C language) and graphical interfaces
124 (Java and others) in mind, sharing code and standardizing interfaces as
129 \begin_layout Standard
130 Both command-line interfaces and graphical interfaces have an important
131 role to play in trace analysis.
132 While graphical interfaces allow for complex views, command-line utilities
133 can be used quickly in more environments; they can also be more convenient
134 in some circumstances.
135 A good design should be such that they can share code and APIs.
139 \begin_layout Section
143 \begin_layout Itemize
144 All data structures must be accessed through API methods, in order to allow
145 for internal change without breaking compatibility.
148 \begin_layout Itemize
149 The APIs in this document are described as C functions and datatypes.
150 When an operation applies to an abstraction that could be an object in
151 an object-oriented language, it is specified as the first argument of the
155 \begin_layout Subsection
159 \begin_layout Standard
160 The framework needs to represent points in the time line and time ranges.
161 This is done by two data structures, respectively:
164 \begin_layout Itemize
168 \begin_layout Itemize
169 struct trace_time_range
172 \begin_layout Standard
173 The preferred representation for times is seconds.
176 \begin_layout Standard
177 Ranges are a span between two points in time.
178 They are represented as these two points.
179 One or both of them can have the special value
186 \begin_layout Standard
187 Each time is accompanied by an uncertainty value.
190 \begin_layout Section
191 Low level reading of traces
194 \begin_layout Subsection
198 \begin_layout Standard
199 This API presents a uniform way of accessing traces at a low level, that
200 is to access randomly the events of the trace in an physical-encoding-independa
204 \begin_layout Standard
205 \begin_inset Note Note
208 \begin_layout Subsubsection
212 \begin_layout Standard
213 Timestamps, at the framework level, should be in an architecture-independent
215 One possibility would be to have them stored in seconds (with decimals).
216 Offsetting, if necessary, could be handled by the traceset (trace merging)
218 An uncertainty value should accompany the timestamp.
219 Timestamps in cycles should be available if they are provided by the tracer.
227 \begin_layout Standard
228 \begin_inset Note Note
231 \begin_layout Subsubsection
235 \begin_layout Itemize
236 void get_supported_formats(void)
240 \begin_layout Standard
244 \begin_layout Standard
248 \begin_layout Itemize
249 a list of supported formats
253 \begin_layout Itemize
258 \begin_layout Standard
262 \begin_layout Itemize
267 \begin_layout Itemize
271 \begin_layout Itemize
272 other special url to establish a network connection
275 \begin_layout Itemize
280 \begin_layout Itemize
281 trace format (optional, for cases where auto detection would not work or
285 \begin_layout Standard
289 \begin_layout Itemize
298 \begin_layout Subsection
299 Methods of the Low Level Trace Reading API
302 \begin_layout Itemize
303 void close(struct trace *tr)
307 \begin_layout Standard
308 Close the trace and unallocate all resources associated to this struct trace
309 including the handle.
310 After this call, tr is invalid and its memory is freed.
313 \begin_layout Standard
317 \begin_layout Itemize
321 \begin_layout Standard
326 \begin_layout Itemize
327 struct event *current_event(struct trace *tr, struct cursor *cur)
331 \begin_layout Standard
332 Return the event pointed by the cursor cur.
335 \begin_layout Standard
339 \begin_layout Itemize
343 \begin_layout Itemize
344 cur: the cursor indicating the position of the wanted event
347 \begin_layout Standard
351 \begin_layout Itemize
352 the event currently pointed by the position pointer
355 \begin_layout Itemize
356 NULL, if current_event is called on a new cursor that is positioned before
357 the beginning of the trace
361 \begin_layout Itemize
362 int advance(struct trace *tr, struct trace_cursor *cur)
366 \begin_layout Standard
367 Advance the cursor to the next event in the trace.
370 \begin_layout Standard
374 \begin_layout Itemize
378 \begin_layout Itemize
379 cur: the cursor that should be advanced
382 \begin_layout Standard
386 \begin_layout Itemize
391 \begin_layout Itemize
392 Success (TRACE_ADVANCE_OK)
395 \begin_layout Itemize
396 The cursor was not advanced because the end of trace is reached (end of
397 a non-live trace or of a completed live trace) (TRACE_ADVANCE_END)
400 \begin_layout Itemize
401 The cursor was not advanced because no new events are available at this
402 time (with a live trace that is still running) (TRACE_ADVANCE_TRY_AGAIN)
407 \begin_layout Itemize
408 int seek_time(struct trace *tr, struct trace_cursor *cur, struct trace_time
413 \begin_layout Standard
414 Place a cursor at a particular time index in a trace.
417 \begin_layout Standard
421 \begin_layout Itemize
422 tr: the trace that should be seeked
425 \begin_layout Itemize
426 cur: the cursor to seek
429 \begin_layout Itemize
430 time: the time to seek to
433 \begin_layout Standard
437 \begin_layout Itemize
441 \begin_layout Itemize
442 != 0: time out of range
446 \begin_layout Itemize
447 struct trace_cursor *trace_new_cursor(struct trace *tr)
451 \begin_layout Standard
452 Return a new cursor associated to the trace.
453 The position of this new cursor is just before the first event, therefore
454 advance() must be called before reading the first event.
457 \begin_layout Standard
461 \begin_layout Itemize
465 \begin_layout Standard
469 \begin_layout Itemize
474 \begin_layout Itemize
475 struct trace_cursor *trace_cursor_copy(struct trace_cursor *cur)
479 \begin_layout Standard
483 \begin_layout Standard
487 \begin_layout Itemize
488 cur: the cursor to copy
491 \begin_layout Standard
495 \begin_layout Itemize
496 a new cursor that is at the same location as cur
500 \begin_layout Itemize
501 void trace_cursor_destroy(struct trace_cursor *cur)
505 \begin_layout Standard
506 Free all resources associated to a cursor.
507 After this call, cur is invalid.
510 \begin_layout Standard
514 \begin_layout Itemize
515 cur: the cursor to destroy
518 \begin_layout Standard
523 \begin_layout Itemize
524 struct trace_time get_time_start(struct trace *tr)
528 \begin_layout Standard
532 \begin_layout Itemize
536 \begin_layout Standard
540 \begin_layout Itemize
541 the timestamp of the first event in the trace
545 \begin_layout Itemize
546 struct trace_time get_time_end(struct trace *tr)
550 \begin_layout Standard
554 \begin_layout Standard
558 \begin_layout Itemize
559 the timestamp of the last event in the trace
563 \begin_layout Itemize
564 register_callback_new_event(struct trace *tr, struct trace_time after, void
565 (*cb)(struct trace *, void *priv), void *private)
569 \begin_layout Standard
570 Register a callback that is called when a new event becomes available in
572 It is also called when the live trace ends.
575 \begin_layout Standard
579 \begin_layout Itemize
580 after (timestamp) : call only if the timestamp of the event is later than
586 \begin_layout Itemize
587 cb: the callback function
588 \begin_inset Note Note
591 \begin_layout Standard
592 specify its args and return val
600 \begin_layout Standard
604 \begin_layout Itemize
605 Result (success or failure)
609 \begin_layout Section
610 High level reading of traces
613 \begin_layout Standard
614 When reading/analyzing/viewing several traces of heterogenous types, these
615 traces are read by translator modules, which export the Low Level Trace
617 The traceset service then uses this API to read each of these traces individual
618 ly, merging them along the way.
619 It may apply timestamp offsetting or other synchronization techniques.
620 To allow views and analyses to access events, it in turn exports the High
621 Level Trace Reading API.
624 \begin_layout Standard
625 The goal of this API is to provide a uniform way for analyses and views
626 to obtain large sets of trace events from a traceset (merge of many traces
630 \begin_layout Subsection
631 Methods of the high-level trace reading API
634 \begin_layout Itemize
635 struct request_handle *traceset_new_event_request(struct traceset *tr, struct
636 trace_time t1, struct trace_time t2, struct event_filter *filter, void
637 (*cb)(void *priv, ), void *private)
641 \begin_layout Standard
642 Request a range of events from a traceset
645 \begin_layout Standard
649 \begin_layout Itemize
653 \begin_layout Itemize
657 \begin_layout Itemize
658 t2: stop timestamp (special value for infinity, for live traces)
661 \begin_layout Itemize
662 filter: filter with complex expressions
665 \begin_layout Itemize
666 private: private pointer to be passed to the callback
669 \begin_layout Standard
673 \begin_layout Itemize
674 handle to the request for cancelling it
678 \begin_layout Itemize
679 void event_request_cancel(struct request_handle *req)
683 \begin_layout Standard
687 \begin_layout Standard
691 \begin_layout Itemize
692 req: the handle to the request
696 \begin_layout Subsection
700 \begin_layout Standard
701 States are key/value pairs associated with a time range.
702 Keys can be (and generally are) duplicated as long as they do not apply
703 to overlapping ranges.
706 \begin_layout Standard
707 Keys are character strings.
710 \begin_layout Standard
711 Values may be of various types:
714 \begin_layout Itemize
718 \begin_layout Itemize
722 \begin_layout Itemize
726 \begin_layout Itemize
727 blob (binary block of arbitrary length)
730 \begin_layout Itemize
734 \begin_layout Itemize
738 \begin_layout Standard
739 The state information must be persistent between executions of the framework.
742 \begin_layout Standard
743 It is possible to assign a state to the range -infinity..infinity to indicate
744 that it is global to the trace.
747 \begin_layout Standard
748 The key names should be hierarchical.
751 \begin_layout Subsubsection
755 \begin_layout Itemize
756 struct state_value *state_get_value_at_time(char *key, struct trace_time
761 \begin_layout Standard
762 Request the value of a given key at a point in time
765 \begin_layout Standard
769 \begin_layout Itemize
770 var: the state variables (string)
773 \begin_layout Itemize
777 \begin_layout Standard
781 \begin_layout Itemize
786 \begin_layout Itemize
787 struct state_value_range **state_get_values_in_range(char *key, struct state_val
788 ue *val, struct trace_time_range range)
792 \begin_layout Standard
793 Request all the states changes of a given set of state variables between
797 \begin_layout Standard
801 \begin_layout Itemize
805 \begin_layout Itemize
806 range: the time range
810 \begin_layout Itemize
811 Other functions for getting values for a set of keys at once?
814 \begin_layout Subsubsection
818 \begin_layout Itemize
819 set a particular state
822 \begin_layout Itemize
826 \begin_layout Section
827 Describing event types
830 \begin_layout Subsection
834 \begin_layout Standard
835 Because tracepoints may be created dynamically, information about the descriptio
836 n of events is just as dynamic.
837 In this context, one simple way to communicate the event description informatio
838 n to upper layers would be to send them as events, as it is done in recent
840 The core events used to describe other events are the only ones whose descripti
841 on is hardcoded in the framework.
844 \begin_layout Standard
845 These event-type-describing events could then be received and interpreted
846 by the Event Description Service, which would be a client to the high-level
847 tracing API at the same level as normal views and analyses.
848 It would store the information and allow the other views and analyses to
849 access it via this API.
852 \begin_layout Standard
853 Each event has a timestamp, a name and arguments of various types.
854 The framework should support the following types:
857 \begin_layout Itemize
861 \begin_layout Itemize
865 \begin_layout Itemize
869 \begin_layout Itemize
873 \begin_layout Itemize
877 \begin_layout Subsection
878 Events-describing events
881 \begin_layout Itemize
882 Event type declaration event
886 \begin_layout Standard
887 Announce the existence of an event type
890 \begin_layout Itemize
895 \begin_layout Itemize
896 Argument declaration event
900 \begin_layout Standard
901 Announce the existence of an event argument
904 \begin_layout Itemize
908 \begin_layout Itemize
912 \begin_layout Itemize
917 \begin_layout Itemize
922 \begin_layout Standard
923 Announce that an event type ceased to exist
926 \begin_layout Itemize
931 \begin_layout Subsection
932 Event type description API
935 \begin_layout Standard
936 The event type description service provides the following functions.
939 \begin_layout Itemize
940 GArray<struct event_type *> *traceset_get_all_event_types(struct traceset
945 \begin_layout Standard
946 Get the list of all the event types
949 \begin_layout Standard
953 \begin_layout Itemize
954 ts: the traceset of which we want the event types
957 \begin_layout Standard
961 \begin_layout Itemize
962 A GArray of of struct event_type.
963 The GArray must be gfree()'d by the caller when it is done reading it.
967 \begin_layout Itemize
968 struct event_type *traceset_get_event_type_by_name(struct traceset *ts,
973 \begin_layout Standard
974 Find an event type by name
977 \begin_layout Standard
981 \begin_layout Itemize
982 ts: the traceset of which we want the event type
985 \begin_layout Itemize
986 name: the name of the of the event type we are looking for
989 \begin_layout Standard
993 \begin_layout Itemize
994 A pointer to the event type (must not be free'd) or NULL if not found
998 \begin_layout Itemize
999 GArray<struct event arg *> *event_type_get_all_args(struct event_type *evtype)
1003 \begin_layout Standard
1004 Get the list of arguments of an event
1007 \begin_layout Standard
1011 \begin_layout Itemize
1012 eventype: the event type of which we want the arguments
1015 \begin_layout Standard
1019 \begin_layout Itemize
1020 A GArray of struct event_args.
1021 The GArray must be gfree()'d by the caller when it is done reading it.
1025 \begin_layout Itemize
1026 struct event_arg *event_type_get_arg_by_name(struct event_type *evtype)
1030 \begin_layout Standard
1031 Find an argument by name
1035 \begin_layout Itemize
1036 Functions for accessing struct event_arg fields
1039 \begin_layout Section
1043 \begin_layout Subsection
1047 \begin_layout Standard
1048 Events contain the following information.
1051 \begin_layout Itemize
1055 \begin_layout Itemize
1056 Event type identifier - an event id (integer) - hidden to the API users,
1057 manipulated as pointers/references to struct event_type
1060 \begin_layout Itemize
1061 A reference to the trace it was in
1064 \begin_layout Subsection
1065 Event inspecting API
1068 \begin_layout Itemize
1069 struct event_type *event_get_type(struct traceset *ts, struct event *ev)
1073 \begin_layout Standard
1074 get the event type corresponding to an event
1077 \begin_layout Standard
1081 \begin_layout Itemize
1085 \begin_layout Itemize
1089 \begin_layout Standard
1093 \begin_layout Itemize
1094 The event type or NULL if no information
1098 \begin_layout Itemize
1099 struct trace_time event_get_time(struct event *ev)
1103 \begin_layout Standard
1108 \begin_layout Itemize
1109 struct trace *event_get_trace(struct event *ev)
1112 \begin_layout Itemize
1113 get the name of the machine on which the event occured or other location
1117 \begin_layout Itemize
1118 get information on the type of tracing technology that was used
1121 \begin_layout Itemize
1122 get the corresponding tracepoint (machine/tracing technology/name/location
1123 in code(if available))
1126 \begin_layout Itemize
1127 uint32 event_read_arg_uint32(struct event *ev, struct event_arg *arg)
1130 \begin_layout Itemize
1131 int32 event_read_arg_int32(struct event *ev, struct event_arg *arg)
1134 \begin_layout Itemize
1135 uint64 event_read_arg_uint64(struct event *ev, struct event_arg *arg)
1138 \begin_layout Itemize
1139 int64 event_read_arg_int64(struct event *ev, struct event_arg *arg)
1142 \begin_layout Itemize
1143 float32 event_read_arg_float32(struct event *ev, struct event_arg *arg)
1146 \begin_layout Itemize
1147 float64 event_read_arg_float64(struct event *ev, struct event_arg *arg)
1150 \begin_layout Section
1154 \begin_layout Standard
1155 A filtering API is proposed.
1158 \begin_layout Section
1159 Controlling the tracing of a system
1162 \begin_layout Subsection
1166 \begin_layout Standard
1167 The goal of this API is to provide a portable way of controlling tracing
1168 of heterogenous systems.
1171 \begin_layout Standard
1172 It should enable to do the following actions.
1175 \begin_layout Itemize
1176 Set the parameters of a trace (channels, buffering, destination of data
1177 (file, network, process)...)
1180 \begin_layout Itemize
1181 Control the recording of events (start, stop, pause the trace)
1184 \begin_layout Itemize
1185 Create tracepoints (on dynamic tracers) and control which tracepoints are
1186 activated (some may be at trace level, others might only permit system
1190 \begin_layout Subsection
1194 \begin_layout Itemize
1195 List the static tracepoints available on a system
1199 \begin_layout Standard
1200 These may be static tracepoints (active or inactive) or dynamic tracepoints
1201 (active or proposed).
1205 \begin_layout Itemize
1206 Add a new dynamic tracepoint
1209 \begin_layout Itemize
1210 Activate a tracepoint
1213 \begin_layout Itemize
1214 Deactivate a tracepoint
1217 \begin_layout Itemize
1218 List available probes
1221 \begin_layout Itemize
1222 Connect a probe to a tracepoint
1225 \begin_layout Itemize
1229 \begin_layout Itemize
1233 \begin_layout Itemize
1234 \begin_inset Note Greyedout
1237 \begin_layout Standard