| 1 | /* This file is part of the Linux Trace Toolkit trace reading library |
| 2 | * Copyright (C) 2003-2004 Michel Dagenais |
| 3 | * 2005 Mathieu Desnoyers |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License Version 2.1 as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library; if not, write to the |
| 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 17 | * Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifndef TRACE_H |
| 21 | #define TRACE_H |
| 22 | |
| 23 | #include <ltt/ltt.h> |
| 24 | #include <stdint.h> |
| 25 | #include <glib.h> |
| 26 | |
| 27 | struct LttTrace { |
| 28 | GQuark pathname; //the pathname of the trace |
| 29 | //LttSystemDescription * system_description;//system description |
| 30 | |
| 31 | guint num_cpu; |
| 32 | |
| 33 | guint32 arch_type; |
| 34 | guint32 arch_variant; |
| 35 | guint8 arch_size; |
| 36 | guint8 ltt_major_version; |
| 37 | guint8 ltt_minor_version; |
| 38 | guint8 flight_recorder; |
| 39 | guint32 freq_scale; |
| 40 | uint64_t start_freq; |
| 41 | uint64_t start_tsc; |
| 42 | uint64_t start_monotonic; |
| 43 | LttTime start_time; |
| 44 | LttTime start_time_from_tsc; |
| 45 | |
| 46 | GData *tracefiles; //tracefiles groups |
| 47 | /* Support for markers */ |
| 48 | GArray *markers; //indexed by marker ID |
| 49 | GHashTable *markers_hash; //indexed by name hash |
| 50 | GHashTable *markers_format_hash; //indexed by name hash |
| 51 | }; |
| 52 | |
| 53 | |
| 54 | |
| 55 | extern GQuark LTT_FACILITY_NAME_HEARTBEAT, |
| 56 | LTT_EVENT_NAME_HEARTBEAT, |
| 57 | LTT_EVENT_NAME_HEARTBEAT_FULL; |
| 58 | |
| 59 | /* A trace is specified as a pathname to the directory containing all the |
| 60 | associated data (control tracefiles, per cpu tracefiles, event |
| 61 | descriptions...). |
| 62 | |
| 63 | When a trace is closed, all the associated facilities, types and fields |
| 64 | are released as well. |
| 65 | |
| 66 | return value is NULL if there is an error when opening the trace. |
| 67 | |
| 68 | */ |
| 69 | |
| 70 | LttTrace *ltt_trace_open(const gchar *pathname); |
| 71 | |
| 72 | /* copy reopens a trace |
| 73 | * |
| 74 | * return value NULL if error while opening the trace |
| 75 | */ |
| 76 | LttTrace *ltt_trace_copy(LttTrace *self); |
| 77 | |
| 78 | GQuark ltt_trace_name(const LttTrace *t); |
| 79 | |
| 80 | void ltt_trace_close(LttTrace *t); |
| 81 | |
| 82 | guint ltt_trace_get_num_cpu(LttTrace *t); |
| 83 | |
| 84 | LttSystemDescription *ltt_trace_system_description(LttTrace *t); |
| 85 | |
| 86 | |
| 87 | /* Get the start time and end time of the trace */ |
| 88 | |
| 89 | void ltt_trace_time_span_get(LttTrace *t, LttTime *start, LttTime *end); |
| 90 | |
| 91 | |
| 92 | /* Get the name of a tracefile */ |
| 93 | |
| 94 | GQuark ltt_tracefile_name(const LttTracefile *tf); |
| 95 | GQuark ltt_tracefile_long_name(const LttTracefile *tf); |
| 96 | |
| 97 | /* get the cpu number of the tracefile */ |
| 98 | |
| 99 | guint ltt_tracefile_cpu(LttTracefile *tf); |
| 100 | |
| 101 | /* For usertrace */ |
| 102 | guint ltt_tracefile_tid(LttTracefile *tf); |
| 103 | guint ltt_tracefile_pgid(LttTracefile *tf); |
| 104 | guint64 ltt_tracefile_creation(LttTracefile *tf); |
| 105 | |
| 106 | |
| 107 | LttTrace *ltt_tracefile_get_trace(LttTracefile *tf); |
| 108 | |
| 109 | /* Get the number of blocks in the tracefile */ |
| 110 | |
| 111 | unsigned ltt_tracefile_block_number(LttTracefile *tf); |
| 112 | |
| 113 | |
| 114 | /* Seek to the first event of the trace with time larger or equal to time */ |
| 115 | |
| 116 | int ltt_tracefile_seek_time(LttTracefile *t, LttTime time); |
| 117 | |
| 118 | /* Seek to the first event with position equal or larger to ep */ |
| 119 | |
| 120 | int ltt_tracefile_seek_position(LttTracefile *t, |
| 121 | const LttEventPosition *ep); |
| 122 | |
| 123 | /* Read the next event */ |
| 124 | |
| 125 | int ltt_tracefile_read(LttTracefile *t); |
| 126 | |
| 127 | /* ltt_tracefile_read cut down in pieces */ |
| 128 | int ltt_tracefile_read_seek(LttTracefile *t); |
| 129 | int ltt_tracefile_read_update_event(LttTracefile *t); |
| 130 | int ltt_tracefile_read_op(LttTracefile *t); |
| 131 | |
| 132 | /* Get the current event of the tracefile : valid until the next read */ |
| 133 | LttEvent *ltt_tracefile_get_event(LttTracefile *tf); |
| 134 | |
| 135 | /* open tracefile */ |
| 136 | |
| 137 | gint ltt_tracefile_open(LttTrace *t, gchar * fileName, LttTracefile *tf); |
| 138 | |
| 139 | /* get the data type size and endian type of the local machine */ |
| 140 | |
| 141 | void getDataEndianType(LttArchSize * size, LttArchEndian * endian); |
| 142 | |
| 143 | /* get an integer number */ |
| 144 | gint64 get_int(gboolean reverse_byte_order, gint size, void *data); |
| 145 | |
| 146 | /* get the node name of the system */ |
| 147 | |
| 148 | gchar * ltt_trace_system_description_node_name (LttSystemDescription * s); |
| 149 | |
| 150 | |
| 151 | /* get the domain name of the system */ |
| 152 | |
| 153 | gchar * ltt_trace_system_description_domain_name (LttSystemDescription * s); |
| 154 | |
| 155 | |
| 156 | /* get the description of the system */ |
| 157 | |
| 158 | gchar * ltt_trace_system_description_description (LttSystemDescription * s); |
| 159 | |
| 160 | |
| 161 | /* get the NTP start time of the trace */ |
| 162 | |
| 163 | LttTime ltt_trace_start_time(LttTrace *t); |
| 164 | |
| 165 | /* get the monotonic start time of the trace */ |
| 166 | |
| 167 | LttTime ltt_trace_start_time_monotonic(LttTrace *t); |
| 168 | |
| 169 | /* copy tracefile info over another. Used for sync. */ |
| 170 | LttTracefile *ltt_tracefile_new(); |
| 171 | void ltt_tracefile_destroy(LttTracefile *tf); |
| 172 | void ltt_tracefile_copy(LttTracefile *dest, const LttTracefile *src); |
| 173 | |
| 174 | void get_absolute_pathname(const gchar *pathname, gchar * abs_pathname); |
| 175 | |
| 176 | /* May return a NULL tracefile group */ |
| 177 | GData **ltt_trace_get_tracefiles_groups(LttTrace *trace); |
| 178 | |
| 179 | typedef void (*ForEachTraceFileFunc)(LttTracefile *tf, gpointer func_args); |
| 180 | |
| 181 | struct compute_tracefile_group_args { |
| 182 | ForEachTraceFileFunc func; |
| 183 | gpointer func_args; |
| 184 | }; |
| 185 | |
| 186 | |
| 187 | void compute_tracefile_group(GQuark key_id, |
| 188 | GArray *group, |
| 189 | struct compute_tracefile_group_args *args); |
| 190 | |
| 191 | |
| 192 | gint64 ltt_get_int(gboolean reverse_byte_order, gint size, void *data); |
| 193 | |
| 194 | guint64 ltt_get_uint(gboolean reverse_byte_order, gint size, void *data); |
| 195 | |
| 196 | LttTime ltt_interpolate_time_from_tsc(LttTracefile *tf, guint64 tsc); |
| 197 | |
| 198 | /* Set to enable event debugging output */ |
| 199 | void ltt_event_debug(int state); |
| 200 | |
| 201 | #endif // TRACE_H |