5 * Marker support header.
7 * Mathieu Desnoyers, August 2007
12 #include <ltt/trace.h>
13 #include <ltt/compiler.h>
14 #include <ltt/marker-field.h>
15 #include <ltt/trace.h>
17 #define LTT_ATTRIBUTE_NETWORK_BYTE_ORDER (1<<1)
19 /* static ids 0-7 reserved for internal use. */
20 #define MARKER_CORE_IDS 8
27 long size
; /* size if known statically, else -1 */
28 guint8 largest_align
; /* Size of the largest alignment needed in the
30 GArray
*fields
; /* Array of struct marker_field */
31 guint8 int_size
, long_size
, pointer_size
, size_t_size
;
32 guint8 alignment
; /* Size on which the architecture alignment must be
33 done. Useful to encapsulate x86_32 events on
35 struct marker_info
*next
; /* Linked list of markers with the same name */
39 GArray
*markers
; //indexed by marker id
40 GHashTable
*markers_hash
; //indexed by name hash
41 GHashTable
*markers_format_hash
; //indexed by name hash
45 MARKER_ID_SET_MARKER_ID
= 0, /* Static IDs available (range 0-7) */
46 MARKER_ID_SET_MARKER_FORMAT
,
49 static inline guint16
marker_get_id_from_info(struct marker_data
*data
,
50 struct marker_info
*info
)
52 return ((unsigned long)info
- (unsigned long)data
->markers
->data
)
53 / sizeof(struct marker_info
);
56 static inline struct marker_info
*marker_get_info_from_id(
57 struct marker_data
*data
, guint16 id
)
59 if (unlikely(data
->markers
->len
<= id
))
61 return &g_array_index(data
->markers
, struct marker_info
, id
);
65 * Returns the head of the marker info list for that name.
67 static inline struct marker_info
*marker_get_info_from_name(
68 struct marker_data
*data
, GQuark name
)
70 gpointer orig_key
, value
;
73 res
= g_hash_table_lookup_extended(data
->markers_hash
,
74 (gconstpointer
)(gulong
)name
, &orig_key
, &value
);
77 return marker_get_info_from_id(data
, (guint16
)(gulong
)value
);
80 static inline char *marker_get_format_from_name(struct marker_data
*data
,
83 gpointer orig_key
, value
;
86 res
= g_hash_table_lookup_extended(data
->markers_format_hash
,
87 (gconstpointer
)(gulong
)name
, &orig_key
, &value
);
93 static inline struct marker_field
*marker_get_field(struct marker_info
*info
,
96 return &g_array_index(info
->fields
, struct marker_field
, i
);
99 static inline unsigned int marker_get_num_fields(struct marker_info
*info
)
101 return info
->fields
->len
;
105 * for_each_marker_field - iterate over fields of a marker
106 * @field: struct marker_field * to use as iterator
107 * @info: marker info pointer
109 #define for_each_marker_field(field, info) \
110 for (field = marker_get_field(info, 0); \
111 field != marker_get_field(info, marker_get_num_fields(info)); \
114 int marker_format_event(LttTrace
*trace
, GQuark channel
, GQuark name
,
116 int marker_id_event(LttTrace
*trace
, GQuark channel
, GQuark name
, guint16 id
,
117 uint8_t int_size
, uint8_t long_size
, uint8_t pointer_size
,
118 uint8_t size_t_size
, uint8_t alignment
);
119 struct marker_data
*allocate_marker_data(void);
120 void destroy_marker_data(struct marker_data
*data
);
122 #endif //_LTT_MARKERS_H