#ifndef MEMFAULT_H #define MEMFAULT_H #include 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 */