| 1 | #ifndef TRACE_H |
| 2 | #define TRACE_H |
| 3 | |
| 4 | #include <ltt/ltt.h> |
| 5 | |
| 6 | /* A trace is specified as a pathname to the directory containing all the |
| 7 | associated data (control tracefiles, per cpu tracefiles, event |
| 8 | descriptions...). |
| 9 | |
| 10 | When a trace is closed, all the associated facilities, types and fields |
| 11 | are released as well. */ |
| 12 | |
| 13 | LttTrace *ltt_trace_open(const char *pathname); |
| 14 | |
| 15 | /* copy reopens a trace */ |
| 16 | LttTrace *ltt_trace_copy(LttTrace *self); |
| 17 | |
| 18 | void ltt_trace_close(LttTrace *t); |
| 19 | |
| 20 | |
| 21 | /* The characteristics of the system on which the trace was obtained |
| 22 | is described in a LttSystemDescription structure. */ |
| 23 | |
| 24 | struct _LttSystemDescription { |
| 25 | char *description; |
| 26 | char *node_name; |
| 27 | char *domain_name; |
| 28 | unsigned nb_cpu; |
| 29 | LttArchSize size; |
| 30 | LttArchEndian endian; |
| 31 | char *kernel_name; |
| 32 | char *kernel_release; |
| 33 | char *kernel_version; |
| 34 | char *machine; |
| 35 | char *processor; |
| 36 | char *hardware_platform; |
| 37 | char *operating_system; |
| 38 | unsigned ltt_major_version; |
| 39 | unsigned ltt_minor_version; |
| 40 | unsigned ltt_block_size; |
| 41 | LttTime trace_start; |
| 42 | LttTime trace_end; |
| 43 | }; |
| 44 | |
| 45 | LttSystemDescription *ltt_trace_system_description(LttTrace *t); |
| 46 | |
| 47 | |
| 48 | /* Functions to discover the facilities in the trace. Once the number |
| 49 | of facilities is known, they may be accessed by position. Multiple |
| 50 | versions of a facility (same name, different checksum) have consecutive |
| 51 | positions. */ |
| 52 | |
| 53 | unsigned ltt_trace_facility_number(LttTrace *t); |
| 54 | |
| 55 | LttFacility *ltt_trace_facility_get(LttTrace *t, unsigned i); |
| 56 | |
| 57 | |
| 58 | /* Look for a facility by name. It returns the number of facilities found |
| 59 | and sets the position argument to the first found. Returning 0, the named |
| 60 | facility is unknown, returning 1, the named facility is at the specified |
| 61 | position, returning n, the facilities are from position to |
| 62 | position + n - 1. */ |
| 63 | |
| 64 | unsigned ltt_trace_facility_find(LttTrace *t, char *name, unsigned *position); |
| 65 | |
| 66 | |
| 67 | /* Functions to discover all the event types in the trace */ |
| 68 | |
| 69 | unsigned ltt_trace_eventtype_number(LttTrace *t); |
| 70 | |
| 71 | LttEventType *ltt_trace_eventtype_get(LttTrace *t, unsigned i); |
| 72 | |
| 73 | |
| 74 | /* There is one "per cpu" tracefile for each CPU, numbered from 0 to |
| 75 | the maximum number of CPU in the system. When the number of CPU installed |
| 76 | is less than the maximum, some positions are unused. There are also a |
| 77 | number of "control" tracefiles (facilities, interrupts...). */ |
| 78 | |
| 79 | unsigned ltt_trace_control_tracefile_number(LttTrace *t); |
| 80 | |
| 81 | unsigned ltt_trace_per_cpu_tracefile_number(LttTrace *t); |
| 82 | |
| 83 | |
| 84 | /* It is possible to search for the tracefiles by name or by CPU position. |
| 85 | The index within the tracefiles of the same type is returned if found |
| 86 | and a negative value otherwise. */ |
| 87 | |
| 88 | int ltt_trace_control_tracefile_find(LttTrace *t, char *name); |
| 89 | |
| 90 | int ltt_trace_per_cpu_tracefile_find(LttTrace *t, unsigned i); |
| 91 | |
| 92 | |
| 93 | /* Get a specific tracefile */ |
| 94 | |
| 95 | LttTracefile *ltt_trace_control_tracefile_get(LttTrace *t, unsigned i); |
| 96 | |
| 97 | LttTracefile *ltt_trace_per_cpu_tracefile_get(LttTrace *t, unsigned i); |
| 98 | |
| 99 | |
| 100 | /* Get the start time and end time of the trace */ |
| 101 | |
| 102 | void ltt_trace_time_span_get(LttTrace *t, LttTime *start, LttTime *end); |
| 103 | |
| 104 | |
| 105 | /* Get the name of a tracefile */ |
| 106 | |
| 107 | char *ltt_tracefile_name(LttTracefile *tf); |
| 108 | |
| 109 | |
| 110 | /* Get the number of blocks in the tracefile */ |
| 111 | |
| 112 | unsigned ltt_tracefile_block_number(LttTracefile *tf); |
| 113 | |
| 114 | |
| 115 | /* Seek to the first event of the trace with time larger or equal to time */ |
| 116 | |
| 117 | void ltt_tracefile_seek_time(LttTracefile *t, LttTime time); |
| 118 | |
| 119 | /* Seek to the first event with position equal or larger to ep */ |
| 120 | |
| 121 | void ltt_tracefile_seek_position(LttTracefile *t, |
| 122 | LttEventPosition *ep); |
| 123 | |
| 124 | /* Read the next event */ |
| 125 | |
| 126 | LttEvent *ltt_tracefile_read(LttTracefile *t); |
| 127 | |
| 128 | #endif // TRACE_H |