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 Support live trace processing
114 \begin_layout Itemize
115 Allow merging of traces of different formats
118 \begin_layout Itemize
119 Design with both command line utilities (C language) and graphical interfaces
120 (Java and others) in mind, sharing code and standardizing interfaces as
125 \begin_layout Standard
126 Both command-line interfaces and graphical interfaces have an important
127 role to play in trace analysis.
128 While graphical interfaces allow for complex views, command-line utilities
129 can be used quickly in more environments; they can also be more convenient
130 in some circumstances.
131 A good design should be such that they can share code and APIs.
135 \begin_layout Section
139 \begin_layout Itemize
140 All data structures must be accessed through API methods, in order to allow
141 for internal change without breaking compatibility.
144 \begin_layout Itemize
145 The APIs in this document are described as C functions and datatypes.
146 When an operation applies to an abstraction that should be an object in
147 an object-oriented language, it is specified as the first argument of the
149 In such languages, this first argument should be removed, as it will be
153 \begin_layout Subsection
157 \begin_layout Standard
158 The framework needs to represent points in the time line and time ranges.
159 This is done by two data structures, respectively:
162 \begin_layout Itemize
166 \begin_layout Itemize
167 struct trace_time_range
170 \begin_layout Standard
171 The preferred representation for times is seconds.
174 \begin_layout Standard
175 Ranges are a span between two points in time.
176 They are represented as these two points.
177 One or both of them can have the special value
184 \begin_layout Section
188 \begin_layout Subsection
192 \begin_layout Subsubsection
196 \begin_layout Standard
197 Timestamps, at the framework level, should be in an architecture-independent
199 One possibility would be to have them stored in seconds (with decimals).
200 Offsetting, if necessary, could be handled by the traceset (trace merging)
202 An uncertainty value should accompany the timestamp.
203 Timestamps in cycles should be available if they are provided by the tracer.
206 \begin_layout Subsection
207 Low-level trace reading API
210 \begin_layout Standard
211 The goal of this API is to provide a uniform way for the framework to access
212 the events recorded in a trace, in an encoding-independant way.
215 \begin_layout Subsubsection
219 \begin_layout Itemize
220 void get_supported_formats(void)
224 \begin_layout Standard
228 \begin_layout Standard
232 \begin_layout Itemize
233 a list of supported formats
237 \begin_layout Itemize
242 \begin_layout Standard
246 \begin_layout Itemize
251 \begin_layout Itemize
255 \begin_layout Itemize
256 other special url to establish a network connection
259 \begin_layout Itemize
264 \begin_layout Itemize
265 trace format (optional, for cases where auto detection would not work or
269 \begin_layout Standard
273 \begin_layout Itemize
278 \begin_layout Subsubsection
282 \begin_layout Itemize
283 bool close(struct trace *tr)
286 \begin_layout Itemize
287 struct event *current_event(struct trace *)
291 \begin_layout Standard
295 \begin_layout Standard
299 \begin_layout Itemize
300 the event currently pointed by the position pointer
304 \begin_layout Itemize
305 bool advance(struct trace *tr)
309 \begin_layout Standard
310 Advance the position pointer to the next event in the trace.
313 \begin_layout Standard
317 \begin_layout Standard
321 \begin_layout Itemize
326 \begin_layout Itemize
330 \begin_layout Itemize
331 Final end of trace (end of a non-live trace or of a completed live trace)
334 \begin_layout Itemize
335 No more events for now (end of a still running live trace)
340 \begin_layout Itemize
341 bool seek_time(struct trace *tr, struct trace_cursor *cur)
345 \begin_layout Standard
349 \begin_layout Itemize
353 \begin_layout Standard
358 \begin_layout Itemize
359 struct trace_cursor *trace_new_cursor_beginning(struct trace *tr)
363 \begin_layout Standard
364 Return a new cursor associated to the trace, positioned at its beginning
368 \begin_layout Itemize
369 struct trace_cursor *trace_cursor_copy(struct trace_cursor *cur)
372 \begin_layout Itemize
373 void trace_cursor_destroy(struct trace_cursor_destroy *)
376 \begin_layout Itemize
377 struct trace_time get_time_start(struct trace *tr)
381 \begin_layout Standard
385 \begin_layout Standard
389 \begin_layout Itemize
390 the timestamp of the first event in the trace
394 \begin_layout Itemize
395 struct trace_time get_time_end(struct trace *tr)
399 \begin_layout Standard
403 \begin_layout Standard
407 \begin_layout Itemize
408 the timestamp of the last event in the trace
412 \begin_layout Itemize
413 register_callback_new_event(struct trace *tr, struct trace_time after, void
418 \begin_layout Standard
419 Register a callback that is called when a new event becomes available in
421 It is also called when the live trace ends.
424 \begin_layout Standard
428 \begin_layout Itemize
429 after (timestamp) : call only if the event occurent later than
434 \begin_layout Itemize
435 cb: the callback function
436 \begin_inset Note Note
439 \begin_layout Standard
440 specify its args and return val
448 \begin_layout Standard
452 \begin_layout Itemize
453 Result (success or failure)
457 \begin_layout Subsection
458 High-level trace reading API
461 \begin_layout Standard
462 The goal of this API is to provide a uniform way for analyses and views
463 to obtain trace events from a traceset (merge of many traces or a single
464 trace), regardless of the system they were recorded on and of the tracer
468 \begin_layout Itemize
469 struct request_handle *traceset_new_event_request(struct traceset *tr, struct
470 trace_time t1, struct trace_time t2, struct event_filter *filter, void
471 (*cb)(void *data, ), void *data)
475 \begin_layout Standard
476 Request a range of events
479 \begin_layout Standard
483 \begin_layout Itemize
487 \begin_layout Itemize
491 \begin_layout Itemize
492 t2: stop timestamp (special value for infinity, for live traces)
495 \begin_layout Itemize
496 filter: filter with complex expressions
499 \begin_layout Itemize
500 data: private pointer to be passed to the callback
503 \begin_layout Standard
507 \begin_layout Itemize
508 handle to the request for cancelling it
512 \begin_layout Itemize
513 void event_request_cancel(struct request_handle *req)
517 \begin_layout Standard
521 \begin_layout Itemize
522 req: the handle to the request
526 \begin_layout Subsection
530 \begin_layout Standard
531 States are key/value pairs associated with a time range.
532 Keys can be (and generally are) duplicated as long as they do not apply
533 to overlapping ranges.
536 \begin_layout Standard
537 Keys are character strings.
540 \begin_layout Standard
541 Values may be of various types:
544 \begin_layout Itemize
548 \begin_layout Itemize
552 \begin_layout Itemize
556 \begin_layout Itemize
557 blob (binary block of arbitrary length)
560 \begin_layout Itemize
564 \begin_layout Itemize
568 \begin_layout Standard
569 The state information must be persistent between executions of the framework.
572 \begin_layout Standard
573 It is possible to assign a state to the range -infinity..infinity to indicate
574 that it is global to the trace, regardless of .
577 \begin_layout Standard
578 The key names should be hierarchical.
581 \begin_layout Subsubsection
585 \begin_layout Itemize
586 struct state_value *state_get_value_at_time(char *key, struct trace_time
591 \begin_layout Standard
592 Request the value of a given key at a point in time
595 \begin_layout Standard
599 \begin_layout Itemize
600 var: the state variables (string)
603 \begin_layout Itemize
607 \begin_layout Standard
611 \begin_layout Itemize
616 \begin_layout Itemize
617 struct state_value_range **state_get_values_in_range(char *key, struct state_val
618 ue *val, struct trace_time_range range)
622 \begin_layout Standard
623 Request all the states changes of a given set of state variables between
627 \begin_layout Standard
631 \begin_layout Itemize
635 \begin_layout Itemize
636 range: the time range
640 \begin_layout Itemize
641 Other functions for getting values for a set of keys at once?
644 \begin_layout Subsubsection
648 \begin_layout Itemize
649 set a particular state
652 \begin_layout Itemize
656 \begin_layout Section
657 Describing event types
660 \begin_layout Subsection
664 \begin_layout Standard
665 Because tracepoints may be created dynamically, information about the descriptio
666 n of events is just as dynamic.
667 In this context, one simple way to communicate the event description informatio
668 n to upper layers would be to send them as events, as it is done in recent
670 The core events used to describe other events are the only ones whose descripti
671 on is hardcoded in the framework.
674 \begin_layout Standard
675 These event-type-describing events could then be received and interpreted
676 by the Event Description Service, which would be a client to the high-level
677 tracing API at the same level as normal views and analyses.
678 It would store the information and allow the other views and analyses to
679 access it via this API.
682 \begin_layout Standard
683 Each event has a timestamp, a name and arguments of various types.
684 The framework should support the following types:
687 \begin_layout Itemize
691 \begin_layout Itemize
695 \begin_layout Itemize
699 \begin_layout Itemize
703 \begin_layout Itemize
707 \begin_layout Subsection
708 Events-describing events
711 \begin_layout Itemize
712 Event type declaration event
716 \begin_layout Standard
717 Announce the existence of an event type
720 \begin_layout Itemize
725 \begin_layout Itemize
726 Argument declaration event
730 \begin_layout Standard
731 Announce the existence of an event argument
734 \begin_layout Itemize
738 \begin_layout Itemize
742 \begin_layout Itemize
747 \begin_layout Itemize
752 \begin_layout Standard
753 Announce that an event type ceased to exist
756 \begin_layout Itemize
761 \begin_layout Subsection
762 Event type description API
765 \begin_layout Standard
766 The event type description service provides the following functions.
769 \begin_layout Itemize
770 GArray<struct event_type *> *traceset_get_all_event_types(struct traceset
775 \begin_layout Standard
776 Get the list of all the event types
779 \begin_layout Standard
783 \begin_layout Itemize
784 ts: the traceset of which we want the event types
787 \begin_layout Standard
791 \begin_layout Itemize
792 A GArray of of struct event_type.
793 The GArray must be gfree()'d by the caller when it is done reading it.
797 \begin_layout Itemize
798 struct event_type *traceset_get_event_type_by_name(struct traceset *ts,
803 \begin_layout Standard
804 Find an event type by name
807 \begin_layout Standard
811 \begin_layout Itemize
812 ts: the traceset of which we want the event type
815 \begin_layout Itemize
816 name: the name of the of the event type we are looking for
819 \begin_layout Standard
823 \begin_layout Itemize
824 A pointer to the event type (must not be free'd) or NULL if not found
828 \begin_layout Itemize
829 GArray<struct event arg *> *event_type_get_all_args(struct event_type *evtype)
833 \begin_layout Standard
834 Get the list of arguments of an event
837 \begin_layout Standard
841 \begin_layout Itemize
842 eventype: the event type of which we want the arguments
845 \begin_layout Standard
849 \begin_layout Itemize
850 A GArray of struct event_args.
851 The GArray must be gfree()'d by the caller when it is done reading it.
855 \begin_layout Itemize
856 struct event_arg *event_type_get_arg_by_name(struct event_type *evtype)
860 \begin_layout Standard
861 Find an argument by name
865 \begin_layout Itemize
866 Functions for accessing struct event_arg fields
869 \begin_layout Section
873 \begin_layout Subsection
877 \begin_layout Standard
878 Events contain the following information.
881 \begin_layout Itemize
885 \begin_layout Itemize
886 Event type identifier - an event id (integer) - hidden to the API users,
887 manipulated as pointers/references to struct event_type
890 \begin_layout Itemize
891 A reference to the trace it was in
894 \begin_layout Subsection
898 \begin_layout Itemize
899 struct event_type *event_get_type(struct traceset *ts, struct event *ev)
903 \begin_layout Standard
904 get the event type corresponding to an event
907 \begin_layout Standard
911 \begin_layout Itemize
915 \begin_layout Itemize
919 \begin_layout Standard
923 \begin_layout Itemize
924 The event type or NULL if no information
928 \begin_layout Itemize
929 struct trace_time event_get_time(struct event *ev)
933 \begin_layout Standard
938 \begin_layout Itemize
939 struct trace *event_get_trace(struct event *ev)
942 \begin_layout Itemize
943 get the name of the machine on which the event occured or other location
947 \begin_layout Itemize
948 get information on the type of tracing technology that was used
951 \begin_layout Itemize
952 get the corresponding tracepoint (machine/tracing technology/name/location
953 in code(if available))
956 \begin_layout Itemize
957 uint32 event_read_arg_uint32(struct event *ev, struct event_arg *arg)
960 \begin_layout Itemize
961 int32 event_read_arg_int32(struct event *ev, struct event_arg *arg)
964 \begin_layout Itemize
965 uint64 event_read_arg_uint64(struct event *ev, struct event_arg *arg)
968 \begin_layout Itemize
969 int64 event_read_arg_int64(struct event *ev, struct event_arg *arg)
972 \begin_layout Itemize
973 float32 event_read_arg_float32(struct event *ev, struct event_arg *arg)
976 \begin_layout Itemize
977 float64 event_read_arg_float64(struct event *ev, struct event_arg *arg)
980 \begin_layout Section
984 \begin_layout Standard
985 A filtering API is proposed.
988 \begin_layout Section
989 Controlling the tracing of a system
992 \begin_layout Subsection
996 \begin_layout Standard
997 The goal of this API is to provide a portable way of controlling tracing
998 of heterogenous systems.
1001 \begin_layout Standard
1002 It should enable to do the following actions.
1005 \begin_layout Itemize
1006 Set the parameters of a trace (channels, buffering, destination of data
1007 (file, network, process)...)
1010 \begin_layout Itemize
1011 Control the recording of events (start, stop, pause the trace)
1014 \begin_layout Itemize
1015 Create tracepoints (on dynamic tracers) and control which tracepoints are
1016 activated (some may be at trace level, others might only permit system
1020 \begin_layout Subsection
1024 \begin_layout Itemize
1025 List the static tracepoints available on a system
1029 \begin_layout Standard
1030 These may be static tracepoints (active or inactive) or dynamic tracepoints
1031 (active or proposed).
1035 \begin_layout Itemize
1036 Add a new dynamic tracepoint
1039 \begin_layout Itemize
1040 Activate a tracepoint
1043 \begin_layout Itemize
1044 Deactivate a tracepoint
1047 \begin_layout Itemize
1048 List available probes
1051 \begin_layout Itemize
1052 Connect a probe to a tracepoint
1055 \begin_layout Itemize
1059 \begin_layout Itemize
1063 \begin_layout Itemize
1064 \begin_inset Note Greyedout
1067 \begin_layout Standard