1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
#ifndef MEMFAULT_H
#define MEMFAULT_H
#include <gtk/gtk.h>
G_BEGIN_DECLS
typedef struct _app App;
typedef struct _allocator Allocator;
typedef struct _allocator_time AllocatorTime;
typedef struct _block Block;
typedef struct _chunk Chunk;
typedef struct _thread_faults ThreadFaults;
typedef struct _frames Frames;
typedef struct _allocators Allocators;
typedef struct _block_map BlockMap;
typedef struct _call_graph CallGraph;
typedef struct _procmap Procmap;
typedef struct _timeline Timeline;
typedef struct _call_graph_frame CallGraphFrame;
typedef struct _call_graph_store CallGraphStore;
typedef struct _call_graph_store_class CallGraphStoreClass;
struct _block {
Block *next;
guint addr;
gsize size;
guint age;
Allocator *allocator;
};
struct _chunk {
struct _chunk *next;
guint used, size;
gchar mem[0];
};
struct _thread_faults {
guint tid;
guint fault_cnt;
guint n_faults;
ThreadFaults *next;
};
struct _allocator {
guint key;
Allocator *next, *ht_next;
guint n_frames;
const gchar **functions;
const gchar **functions_srcloc;
const gchar *alloc_fn;
guint *ips;
struct _allocator_time {
guint time;
guint64 bytes;
guint64 freed;
gsize max_size;
guint size_allocs[32];
guint max_size_alloc;
guint n_allocs;
guint n_reallocs;
guint n_frees;
guint n_realloced_blocks;
guint peak_blocks;
gsize peak_bytes;
ThreadFaults faults;
AllocatorTime *next, *prev;
} time[1];
AllocatorTime *time_tail;
};
typedef enum {
ALLOC,
REALLOC,
DEALLOC
} EventType;
typedef struct _event_base {
EventType type;
guint time;
guint tid;
Allocator *allocator;
} EventBase;
typedef struct _event_alloc {
EventType type;
guint time;
guint tid;
Allocator *allocator;
guint addr;
gsize size;
} EventAlloc;
typedef struct _event_realloc {
EventType type;
guint time;
guint tid;
Allocator *allocator;
guint old_addr;
gsize old_size;
guint new_addr;
gsize new_size;
} EventRealloc;
typedef struct _event_dealloc {
EventType type;
guint time;
guint tid;
Allocator *allocator;
guint addr;
gsize size;
} EventDealloc;
typedef union _event {
EventType type;
EventBase base;
EventAlloc alloc;
EventRealloc realloc;
EventDealloc dealloc;
} Event;
App *
app_get (GtkWidget *widget);
gpointer
app_perm_alloc (App *app, guint size);
gboolean
app_add_alloc_fn (App *app, const gchar *pattern, GError **error);
gboolean
app_is_alloc_fn (App *app, guint ip);
guint
app_get_alloc_fns_serial (App *app);
const gchar *
app_get_main_function (App *app);
guint
app_get_number_of_frames (App *app);
guint
app_get_number_of_allocators (App *app);
GtkWidget *
block_map_new (void);
void
block_map_set_highlight (BlockMap *block_map, GSList *blocks);
GtkWidget *
timeline_new (void);
void
timeline_add_datum (Timeline *tl, guint time, Allocator *A);
GtkWidget *
allocators_new (void);
GSList *
allocators_get_blocks_for_iter (Allocators *self,
GtkTreeIter *iter,
GSList *blocks);
void
allocators_select_blocks (Allocators *self, GSList *blocks);
gboolean
allocators_add_alloc_fn (Allocators *self,
const gchar *pattern,
GError **error);
GtkWidget *
call_graph_new (void);
void
call_graph_update_view (CallGraph *self);
GtkWidget *
call_graph_tree_map_new (void);
GtkWidget *
call_graph_ring_new (void);
GtkWidget *
procmap_new (void);
G_CONST_RETURN Event *
app_find_prev_event_for_addr_range (App *app, guint time, guint min, guint max);
void
pretty_print_number (const char *number, gint len, char *output);
void
cell_layout_pretty_print_uint (GtkCellLayout *layout,
GtkCellRenderer *cell,
GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data);
void
cell_layout_pretty_print_uint64 (GtkCellLayout *layout,
GtkCellRenderer *cell,
GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data);
gdouble
median_double (gdouble *v, guint n);
G_END_DECLS
#endif /* MEMFAULT_H */
|