update compat
[lttv.git] / ltt / branches / poly / ltt / markers.h
CommitLineData
3c165eaf 1#ifndef _LTT_MARKERS_H
2#define _LTT_MARKERS_H
3
d2007fbd 4/*
5 * Marker support header.
6 *
3c165eaf 7 * Mathieu Desnoyers, August 2007
d2007fbd 8 * License: LGPL.
9 */
10
3c165eaf 11#include <glib.h>
d2007fbd 12#include <ltt/trace.h>
13#include <ltt/compiler.h>
3c165eaf 14#include <ltt/ltt-private.h>
15
16enum ltt_type {
17 LTT_TYPE_SIGNED_INT,
18 LTT_TYPE_UNSIGNED_INT,
19 LTT_TYPE_STRING,
20 LTT_TYPE_COMPACT,
21 LTT_TYPE_NONE,
22};
23
24#define LTT_ATTRIBUTE_COMPACT (1<<0)
25#define LTT_ATTRIBUTE_NETWORK_BYTE_ORDER (1<<1)
26
27/* static ids 0-7 reserved for internal use. */
28#define MARKER_CORE_IDS 8
29/* dynamic ids 8-127 reserved for compact events. */
30#define MARKER_COMPACT_IDS 128
31
32struct marker_info;
d2007fbd 33
34struct marker_info {
3c165eaf 35 GQuark name;
36 char *format;
37 long size; /* size if known statically, else -1 */
38 GArray *fields; /* Array of struct marker_field */
39 guint8 int_size, long_size, pointer_size, size_t_size, alignment;
40 struct marker_info *next; /* Linked list of markers with the same name */
41};
42
43struct marker_field {
44 GQuark name;
45 enum ltt_type type;
46 unsigned long offset; /* offset in the event data */
47 unsigned long size;
48 unsigned long alignment;
49 unsigned long attributes;
50 int static_offset;
d2007fbd 51};
52
53enum marker_id {
54 MARKER_ID_SET_MARKER_ID = 0, /* Static IDs available (range 0-7) */
55 MARKER_ID_SET_MARKER_FORMAT,
56 MARKER_ID_HEARTBEAT_32,
57 MARKER_ID_HEARTBEAT_64,
58 MARKER_ID_COMPACT, /* Compact IDs (range: 8-127) */
59 MARKER_ID_DYNAMIC, /* Dynamic IDs (range: 128-65535) */
60};
61
3c165eaf 62static inline guint16 marker_get_id_from_info(LttTrace *trace,
d2007fbd 63 struct marker_info *info)
64{
65 return ((unsigned long)info - (unsigned long)trace->markers->data)
66 / sizeof(struct marker_info);
67}
68
69static inline struct marker_info *marker_get_info_from_id(LttTrace *trace,
3c165eaf 70 guint16 id)
d2007fbd 71{
72 if (unlikely(trace->markers->len < id))
73 return NULL;
74 return &g_array_index(trace->markers, struct marker_info, id);
75}
76
3c165eaf 77/*
78 * Returns the head of the marker info list for that name.
79 */
80static inline struct marker_info *marker_get_info_from_name(LttTrace *trace,
81 GQuark name)
82{
83 return g_hash_table_lookup(trace->markers_hash, (gconstpointer)name);
84}
85
86int marker_format_event(LttTrace *trace, GQuark name, const char *format);
87int marker_id_event(LttTrace *trace, GQuark name, guint16 id,
88 uint8_t int_size, uint8_t long_size, uint8_t pointer_size,
89 uint8_t size_t_size, uint8_t alignment);
d2007fbd 90int allocate_marker_data(LttTrace *trace);
3c165eaf 91void destroy_marker_data(LttTrace *trace);
92
93#endif //_LTT_MARKERS_H
This page took 0.026458 seconds and 4 git commands to generate.