Rework about dialog by using gtk_show_about_dialog
[lttv.git] / ltt / ltt-private.h
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Xiangxiu Yang
3 * 2006 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 LTT_PRIVATE_H
21 #define LTT_PRIVATE_H
22
23 #include <glib.h>
24 #include <sys/types.h>
25 #include <ltt/ltt.h>
26 #include <endian.h>
27 #include <ltt/event.h>
28
29 #ifndef max
30 #define max(a,b) ((a)>(b)?(a):(b))
31 #endif
32
33 #ifndef min
34 #define min(a,b) ((a)<(b)?(a):(b))
35 #endif
36
37
38
39 #define LTT_MAGIC_NUMBER 0x00D6B7ED
40 #define LTT_REV_MAGIC_NUMBER 0xEDB7D600
41
42 #define NSEC_PER_USEC 1000
43
44 /* Byte ordering */
45 #define LTT_GET_BO(t) ((t)->reverse_bo)
46
47 #define LTT_HAS_FLOAT(t) ((t)->float_word_order ! =0)
48 #define LTT_GET_FLOAT_BO(t) \
49 (((t)->float_word_order == __BYTE_ORDER) ? 0 : 1)
50
51 #define SEQUENCE_AVG_ELEMENTS 1000
52
53 /*
54 * offsetof taken from Linux kernel.
55 */
56 #undef offsetof
57 #ifdef __compiler_offsetof
58 #define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
59 #else
60 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
61 #endif
62
63 typedef guint8 uint8_t;
64 typedef guint16 uint16_t;
65 typedef guint32 uint32_t;
66 typedef guint64 uint64_t;
67
68 /* Subbuffer header */
69 struct ltt_subbuffer_header_2_6 {
70 uint64_t cycle_count_begin; /* Cycle count at subbuffer start */
71 uint64_t cycle_count_end; /* Cycle count at subbuffer end */
72 uint32_t magic_number; /*
73 * Trace magic number.
74 * contains endianness information.
75 */
76 uint8_t major_version;
77 uint8_t minor_version;
78 uint8_t arch_size; /* Architecture pointer size */
79 uint8_t alignment; /* LTT data alignment */
80 uint64_t start_time_sec; /* NTP-corrected start time */
81 uint64_t start_time_usec;
82 uint64_t start_freq; /*
83 * Frequency at trace start,
84 * used all along the trace.
85 */
86 uint32_t freq_scale; /* Frequency scaling (divide freq) */
87 uint32_t data_size; /* Size of data in subbuffer */
88 uint32_t sb_size; /* Subbuffer size (page aligned) */
89 uint32_t events_lost; /*
90 * Events lost in this subbuffer since
91 * the beginning of the trace.
92 * (may overflow)
93 */
94 uint32_t subbuf_corrupt; /*
95 * Corrupted (lost) subbuffers since
96 * the begginig of the trace.
97 * (may overflow)
98 */
99 char header_end[0]; /* End of header */
100 };
101
102 typedef struct ltt_subbuffer_header_2_6 ltt_subbuffer_header_t;
103
104 /*
105 * Return header size without padding after the structure. Don't use packed
106 * structure because gcc generates inefficient code on some architectures
107 * (powerpc, mips..)
108 */
109 static inline size_t ltt_subbuffer_header_size(void)
110 {
111 return offsetof(ltt_subbuffer_header_t, header_end);
112 }
113
114 enum field_status { FIELD_UNKNOWN, FIELD_VARIABLE, FIELD_FIXED };
115
116 typedef struct _LttBuffer {
117 void * head;
118 guint64 offset; /* Offset of the current subbuffer */
119 guint32 size; /* The size of the current subbuffer */
120 unsigned int index;
121 uint32_t data_size; /* Size of data in the subbuffer */
122
123 struct {
124 LttTime timestamp;
125 uint64_t cycle_count;
126 uint64_t freq; /* Frequency in khz */
127 } begin;
128 struct {
129 LttTime timestamp;
130 uint64_t cycle_count;
131 uint64_t freq; /* Frequency in khz */
132 } end;
133
134 /* Timekeeping */
135 uint64_t tsc; /* Current timestamp counter */
136 uint64_t freq; /* Frequency in khz */
137 guint32 cyc2ns_scale;
138 } LttBuffer;
139
140 struct LttTracefile {
141 gboolean cpu_online; //is the cpu online ?
142 GQuark long_name; //tracefile complete filename
143 GQuark name; //tracefile name
144 guint cpu_num; //cpu number of the tracefile
145 guint tid; //Usertrace tid, else 0
146 guint pgid; //Usertrace pgid, else 0
147 guint64 creation; //Usertrace creation, else 0
148 LttTrace * trace; //trace containing the tracefile
149 struct marker_data *mdata; // marker id/name/fields mapping
150 int fd; //file descriptor
151 off_t file_size; //file size
152 //unsigned block_size; //block_size
153 guint num_blocks; //number of blocks in the file
154 gboolean reverse_bo; //must we reverse byte order ?
155 gboolean float_word_order; //what is the byte order of floats ?
156 size_t alignment; //alignment of events in the tracefile.
157 // 0 or the architecture size in bytes.
158
159 size_t buffer_header_size;
160 uint8_t tscbits;
161 uint8_t eventbits;
162 uint64_t tsc_mask;
163 uint64_t tsc_mask_next_bit; //next MSB after the mask<
164 uint32_t events_lost;
165 uint32_t subbuf_corrupt;
166
167 GArray *buf_index; /* index mapping buffer index to offset */
168 uint64_t end_timestamp; /* Last timestamp of file */
169 /* Current event */
170 LttEvent event; //Event currently accessible in the trace
171
172 /* Current block */
173 LttBuffer buffer; //current buffer
174 };
175
176 /* The characteristics of the system on which the trace was obtained
177 is described in a LttSystemDescription structure. */
178
179 struct LttSystemDescription {
180 gchar *description;
181 gchar *node_name;
182 gchar *domain_name;
183 unsigned nb_cpu;
184 LttArchSize size;
185 LttArchEndian endian;
186 gchar *kernel_name;
187 gchar *kernel_release;
188 gchar *kernel_version;
189 gchar *machine;
190 gchar *processor;
191 gchar *hardware_platform;
192 gchar *operating_system;
193 LttTime trace_start;
194 LttTime trace_end;
195 };
196
197 /*
198 * Calculate the offset needed to align the type.
199 * If alignment is 0, alignment is deactivated.
200 * else, the function returns the offset needed to
201 * align align_drift on the alignment value.
202 *
203 * align align_drift on the alignment value (should be
204 * the size of the architecture).
205 */
206 static inline unsigned int ltt_align(size_t align_drift,
207 size_t size_of_type,
208 size_t alignment)
209 {
210 size_t align_offset = min(alignment, size_of_type);
211
212 if(!alignment)
213 return 0;
214
215 g_assert(size_of_type != 0);
216 return ((align_offset - align_drift) & (align_offset-1));
217 }
218
219
220 #endif /* LTT_PRIVATE_H */
This page took 0.038758 seconds and 4 git commands to generate.