| 1 | #ifndef TRACEFILE_H |
| 2 | #define TRACEFILE_H |
| 3 | |
| 4 | #include <ltt/ltt.h> |
| 5 | |
| 6 | /* A tracefile is specified as a pathname. Facilities must be added to the |
| 7 | tracefile to declare the type of the contained events. |
| 8 | |
| 9 | The ltt_tracefile_facility_add call increases the facility |
| 10 | usage count and also specifies the base of the numeric range |
| 11 | assigned to the event types in the facility for this tracefile. |
| 12 | This information is normally obtained through "facility used" events |
| 13 | stored in the tracefile. |
| 14 | |
| 15 | When a tracefile is closed, all the associated facilities may be |
| 16 | automatically closed as well, if their usage count is 0, when the |
| 17 | close_facilities argument is true. */ |
| 18 | |
| 19 | ltt_tracefile *ltt_tracefile_open(char *pathname); |
| 20 | |
| 21 | int ltt_tracefile_close(ltt_tracefile *t, int close_facilities); |
| 22 | |
| 23 | int ltt_tracefile_facility_add(ltt_tracefile *t, ltt_facility *f, int base_id); |
| 24 | |
| 25 | |
| 26 | /* A tracefile may be queried for its architecture type (e.g., "i386", |
| 27 | "powerpc", "powerpcle", "s390", "s390x"), its architecture variant |
| 28 | (e.g., "att" versus "sun" for m68k), its operating system (e.g., "linux", |
| 29 | "bsd"), its generic architecture, and the machine identity (e.g., system |
| 30 | host name). All character strings belong to the associated tracefile |
| 31 | and are freed when it is closed. */ |
| 32 | |
| 33 | |
| 34 | uint32_t ltt_tracefile_arch_type(ltt_tracefile *t); |
| 35 | |
| 36 | uint32_t ltt_tracefile_arch_variant(ltt_tracefile *t); |
| 37 | |
| 38 | ltt_arch_size ltt_tracefile_arch_size(ltt_tracefile *t); |
| 39 | |
| 40 | ltt_arch_endian ltt_tracefile_arch_endian(ltt_tracefile *t); |
| 41 | |
| 42 | uint32_t ltt_tracefile_system_type(ltt_tracefile *t); |
| 43 | |
| 44 | char *ltt_tracefile_system_name(ltt_tracefile *t); |
| 45 | |
| 46 | |
| 47 | /* SMP multi-processors have 2 or more CPUs */ |
| 48 | |
| 49 | unsigned ltt_tracefile_cpu_number(ltt_tracefile *t); |
| 50 | |
| 51 | |
| 52 | /* Does the tracefile contain events only for a single CPU? */ |
| 53 | |
| 54 | int ltt_tracefile_cpu_single(ltt_tracefile *t); |
| 55 | |
| 56 | |
| 57 | /* It this is the case, which CPU? */ |
| 58 | |
| 59 | unsigned ltt_tracefile_cpu_id(ltt_tracefile *t); |
| 60 | |
| 61 | |
| 62 | /* Start and end time of the trace and its duration */ |
| 63 | |
| 64 | ltt_time ltt_tracefile_time_start(ltt_tracefile *t); |
| 65 | |
| 66 | ltt_time ltt_tracefile_time_end(ltt_tracefile *t); |
| 67 | |
| 68 | ltt_time ltt_tracefile_duration(ltt_tracefile *t); |
| 69 | |
| 70 | |
| 71 | /* Functions to discover the facilities added to the tracefile */ |
| 72 | |
| 73 | unsigned ltt_tracefile_facility_number(ltt_tracefile *t); |
| 74 | |
| 75 | ltt_facility *ltt_tracefile_facility_get(ltt_tracefile *t, unsigned i); |
| 76 | |
| 77 | ltt_facility *ltt_tracefile_facility_get_by_name(ltt_tracefile *t, char *name); |
| 78 | |
| 79 | |
| 80 | /* Functions to discover all the event types in the facilities added to the |
| 81 | tracefile. The event type integer id, unique for the trace, is used. */ |
| 82 | |
| 83 | unsigned ltt_tracefile_eventtype_number(ltt_tracefile *t); |
| 84 | |
| 85 | ltt_eventtype *ltt_tracefile_eventtype_get(ltt_tracefile *t, unsigned i); |
| 86 | |
| 87 | |
| 88 | /* Given an event type, find its unique id within the tracefile */ |
| 89 | |
| 90 | unsigned ltt_tracefile_eventtype_id(ltt_tracefile *t, ltt_eventtype *et); |
| 91 | |
| 92 | |
| 93 | /* Get the root field associated with an event type for the tracefile */ |
| 94 | |
| 95 | ltt_field *ltt_tracefile_eventtype_root_field(ltt_tracefile *t, unsigned id); |
| 96 | |
| 97 | |
| 98 | /* Seek to the first event of the trace with time larger or equal to time */ |
| 99 | |
| 100 | int ltt_tracefile_seek_time(ltt_tracefile *t, ltt_time time); |
| 101 | |
| 102 | |
| 103 | /* Read the next event */ |
| 104 | |
| 105 | ltt_event *ltt_tracefile_read(ltt_tracefile *t); |
| 106 | |
| 107 | #endif // TRACEFILE_H |