1 /* This file is part of the Linux Trace Toolkit trace reading library
2 * Copyright (C) 2003-2004 Michel Dagenais
3 * 2005 Mathieu Desnoyers
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.
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.
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.
24 #include <ltt/ltt-private.h>
29 GQuark pathname
; //the pathname of the trace
30 //LttSystemDescription * system_description;//system description
37 guint8 ltt_major_version
;
38 guint8 ltt_minor_version
;
39 guint8 flight_recorder
;
43 uint64_t start_monotonic
;
47 LttTime start_time_from_tsc
;
49 GData
*tracefiles
; //tracefiles groups
52 static inline guint
ltt_trace_get_num_cpu(LttTrace
*t
)
57 /* A trace is specified as a pathname to the directory containing all the
58 associated data (control tracefiles, per cpu tracefiles, event
61 When a trace is closed, all the associated facilities, types and fields
64 return value is NULL if there is an error when opening the trace.
68 LttTrace
*ltt_trace_open(const gchar
*pathname
);
70 /* copy reopens a trace
72 * return value NULL if error while opening the trace
74 LttTrace
*ltt_trace_copy(LttTrace
*self
);
76 static inline GQuark
ltt_trace_name(const LttTrace
*t
)
82 void ltt_trace_close(LttTrace
*t
);
84 LttSystemDescription
*ltt_trace_system_description(LttTrace
*t
);
87 /* Get the start time and end time of the trace */
89 void ltt_trace_time_span_get(LttTrace
*t
, LttTime
*start
, LttTime
*end
);
92 /* Get the name of a tracefile */
94 static inline GQuark
ltt_tracefile_name(const LttTracefile
*tf
)
99 static inline GQuark
ltt_tracefile_long_name(const LttTracefile
*tf
)
101 return tf
->long_name
;
104 /* get the cpu number of the tracefile */
106 static inline guint
ltt_tracefile_cpu(LttTracefile
*tf
)
112 static inline guint
ltt_tracefile_tid(LttTracefile
*tf
)
117 static inline guint
ltt_tracefile_pgid(LttTracefile
*tf
)
122 static inline guint64
ltt_tracefile_creation(LttTracefile
*tf
)
127 static inline LttTrace
*ltt_tracefile_get_trace(LttTracefile
*tf
)
132 /* Get the number of blocks in the tracefile */
134 static inline guint
ltt_tracefile_block_number(LttTracefile
*tf
)
136 return tf
->num_blocks
;
140 /* Seek to the first event of the trace with time larger or equal to time */
142 int ltt_tracefile_seek_time(LttTracefile
*t
, LttTime time
);
144 /* Seek to the first event with position equal or larger to ep */
146 int ltt_tracefile_seek_position(LttTracefile
*t
,
147 const LttEventPosition
*ep
);
149 /* Read the next event */
151 int ltt_tracefile_read(LttTracefile
*t
);
153 /* ltt_tracefile_read cut down in pieces */
154 int ltt_tracefile_read_seek(LttTracefile
*t
);
155 int ltt_tracefile_read_update_event(LttTracefile
*t
);
156 int ltt_tracefile_read_op(LttTracefile
*t
);
158 /* Get the current event of the tracefile : valid until the next read */
159 LttEvent
*ltt_tracefile_get_event(LttTracefile
*tf
);
161 /* get the data type size and endian type of the local machine */
163 void getDataEndianType(LttArchSize
* size
, LttArchEndian
* endian
);
165 /* get an integer number */
166 gint64
get_int(gboolean reverse_byte_order
, gint size
, void *data
);
168 /* get the node name of the system */
170 gchar
* ltt_trace_system_description_node_name (LttSystemDescription
* s
);
173 /* get the domain name of the system */
175 gchar
* ltt_trace_system_description_domain_name (LttSystemDescription
* s
);
178 /* get the description of the system */
180 gchar
* ltt_trace_system_description_description (LttSystemDescription
* s
);
183 /* get the NTP start time of the trace */
185 LttTime
ltt_trace_start_time(LttTrace
*t
);
187 /* get the monotonic start time of the trace */
189 LttTime
ltt_trace_start_time_monotonic(LttTrace
*t
);
191 void get_absolute_pathname(const gchar
*pathname
, gchar
* abs_pathname
);
193 /* May return a NULL tracefile group */
194 GData
**ltt_trace_get_tracefiles_groups(LttTrace
*trace
);
196 typedef void (*ForEachTraceFileFunc
)(LttTracefile
*tf
, gpointer func_args
);
198 struct compute_tracefile_group_args
{
199 ForEachTraceFileFunc func
;
203 void compute_tracefile_group(GQuark key_id
,
205 struct compute_tracefile_group_args
*args
);
208 gint64
ltt_get_int(gboolean reverse_byte_order
, gint size
, void *data
);
210 guint64
ltt_get_uint(gboolean reverse_byte_order
, gint size
, void *data
);
212 guint64
tsc_to_uint64(guint32 freq_scale
, uint64_t start_freq
, guint64 tsc
);
214 LttTime
ltt_interpolate_time_from_tsc(LttTracefile
*tf
, guint64 tsc
);
216 /* Set to enable event debugging output */
217 void ltt_event_debug(int state
);
219 /* A structure representing the version number of the trace */
220 struct LttTraceVersion
{
221 guint8 ltt_major_version
;
222 guint8 ltt_minor_version
;
225 /* To get the version number of a trace */
226 int ltt_get_trace_version(const gchar
*pathname
, struct LttTraceVersion
* version_number
);