diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2007-12-05 21:45:28 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2007-12-05 21:50:40 +0000 |
commit | 540272705790811627f15a787d094f5a57f67d92 (patch) | |
tree | 4664f63eeeecf44f9a38bfdbfa884c269031e586 | |
parent | 653848770d2e975ce418028cce72b4e36cb183de (diff) |
Store the array of Frames in the Allocator (rather than 3 arrays).
-rw-r--r-- | src/allocators.c | 12 | ||||
-rw-r--r-- | src/app.c | 40 | ||||
-rw-r--r-- | src/blockmap.c | 21 | ||||
-rw-r--r-- | src/callgraph-ring.c | 59 | ||||
-rw-r--r-- | src/callgraph-store.c | 83 | ||||
-rw-r--r-- | src/callgraph-treemap.c | 19 | ||||
-rw-r--r-- | src/callgraph.c | 22 | ||||
-rw-r--r-- | src/callgraph.h | 13 | ||||
-rw-r--r-- | src/frames.c | 7 | ||||
-rw-r--r-- | src/frames.h | 3 | ||||
-rw-r--r-- | src/odin.h | 8 | ||||
-rw-r--r-- | src/summary-chart.c | 9 | ||||
-rw-r--r-- | src/summary-view.c | 8 |
13 files changed, 151 insertions, 153 deletions
diff --git a/src/allocators.c b/src/allocators.c index 4ac3a71..4037f47 100644 --- a/src/allocators.c +++ b/src/allocators.c @@ -28,6 +28,7 @@ #include "odin.h" #include "allocators.h" #include "block.h" +#include "frames.h" #define _(x) x @@ -236,6 +237,7 @@ allocators_query_tooltip (GtkWidget *widget, GtkTreeIter iter; gint cell_x, cell_y; GString *string; + const gchar *main_fn; gchar *text; guint n, m; gchar calls[80]; @@ -269,14 +271,18 @@ allocators_query_tooltip (GtkWidget *widget, g_string_append (string, A->time_tail->n_allocs > 1 ? " calls:" : " call:"); for (n = 0; n < A->n_frames; n++) - if (A->alloc_fn == A->functions[n]) + if (A->frames[n]->function == A->alloc_fn) break; + main_fn = app_get_main_function (app_get ((GtkWidget *) self)); for (m = n; m < MIN (n + 8, A->n_frames); m++) { - if (strcmp (A->functions_srcloc[m], A->functions_srcloc[m-1])) { + if (A->frames[m]->function_srcloc != + A->frames[m-1]->function_srcloc) { g_string_append_c (string, '\n'); g_string_append_c (string, '\t'); - g_string_append (string, A->functions_srcloc[m]); + g_string_append (string, A->frames[m]->function_srcloc); + if (A->frames[m]->function == main_fn) + break; } else n++; } @@ -307,20 +307,16 @@ read_allocator (App *app, int fd, guint time) if (! readn (fd, &A->n_frames, sizeof (A->n_frames))) return NULL; - A->ips = client_perm_alloc (&app->client, - sizeof (gulong) * A->n_frames + - sizeof (const gchar *) * 2 * A->n_frames); - A->functions = (const gchar **) (A->ips + A->n_frames); - A->functions_srcloc = A->functions + A->n_frames; + A->frames = client_perm_alloc (&app->client, + sizeof (Frame *) * A->n_frames); - if (! readn (fd, A->ips, A->n_frames * sizeof (gulong))) + if (! readn (fd, A->frames, A->n_frames * sizeof (gulong))) return NULL; for (n = 0; n < A->n_frames; n++) { - Frame *frame = frames_get (&app->client.frames, A->ips[n]); - g_return_val_if_fail (frame != NULL, NULL); - A->functions[n] = frame->function; - A->functions_srcloc[n] = frame->function_srcloc; + A->frames[n] = frames_get (&app->client.frames, + ((gulong *) A->frames)[n]); + g_return_val_if_fail (A->frames[n] != NULL, NULL); } A->alloc_fn_serial = 0; @@ -622,11 +618,11 @@ _client_update_alloc_fn (Client *client) break; for (n = 0; n < A->n_frames - 1; n++) { - if (! frames_is_alloc_fn (&client->frames, A->ips[n])) + if (! frames_is_alloc_fn (&client->frames, A->frames[n])) break; } - A->alloc_fn = A->functions[n]; + A->alloc_fn = A->frames[n]->function; A->alloc_fn_serial = serial; } } @@ -1581,20 +1577,16 @@ lwp_read (GIOChannel *io, App *app) if (! readn (fd, &A->n_frames, sizeof (A->n_frames))) return FALSE; - A->ips = client_perm_alloc (&app->client, - sizeof (gulong) * A->n_frames + - sizeof (const gchar *) * 2 * A->n_frames); - A->functions = (const gchar **) (A->ips + A->n_frames); - A->functions_srcloc = A->functions + A->n_frames; + A->frames = client_perm_alloc (&app->client, + sizeof (Frame *) * A->n_frames); - if (! readn (fd, A->ips, A->n_frames * sizeof (gulong))) + if (! readn (fd, A->frames, A->n_frames * sizeof (gulong))) return FALSE; for (n = 0; n < A->n_frames; n++) { - Frame *frame = frames_get (&app->client.frames, A->ips[n]); - g_return_val_if_fail (frame != NULL, FALSE); - A->functions[n] = frame->function; - A->functions_srcloc[n] = frame->function_srcloc; + A->frames[n] = frames_get (&app->client.frames, + ((gulong *)A->frames)[n]); + g_return_val_if_fail (A->frames[n] != NULL, FALSE); } A->alloc_fn_serial = 0; @@ -1838,9 +1830,9 @@ vg_log_server_cb (GIOChannel *source, } gboolean -app_is_alloc_fn (App *app, gulong ip) +app_is_alloc_fn (App *app, Frame *f) { - return frames_is_alloc_fn (&app->client.frames, ip); + return frames_is_alloc_fn (&app->client.frames, f); } gboolean diff --git a/src/blockmap.c b/src/blockmap.c index 5a3a61a..ca9864b 100644 --- a/src/blockmap.c +++ b/src/blockmap.c @@ -25,6 +25,7 @@ #include <string.h> #include "odin.h" +#include "frames.h" #define _(x) x @@ -582,17 +583,17 @@ block_map_query_tooltip (GtkWidget *widget, "%s: %s bytes over %s calls\nCalled from:", count->function, bytes, blocks); for (n = 0; n < A->n_frames - 1; n++) { - if (A->functions[n] == A->alloc_fn) + if (A->frames[n]->function == A->alloc_fn) break; } for (m = n + 1; m < MIN (n + 9, A->n_frames); m++) { - if (strcmp (A->functions_srcloc[m], - A->functions_srcloc[m-1])) + if (A->frames[m]->function_srcloc != + A->frames[m-1]->function_srcloc) { g_string_append_c (string, '\n'); g_string_append_c (string, '\t'); - g_string_append (string, A->functions_srcloc[m]); - if (A->functions[n] == main_fn) + g_string_append (string, A->frames[m]->function_srcloc); + if (A->frames[m]->function == main_fn) break; } else n++; @@ -640,17 +641,17 @@ block_map_query_tooltip (GtkWidget *widget, string = g_string_new ( "Last allocated by:"); for (n = 0; n < A->n_frames - 1; n++) { - if (A->functions[n] == A->alloc_fn) + if (A->frames[n]->function == A->alloc_fn) break; } for (m = n + 1; m < MIN (n + 9, A->n_frames); m++) { - if (strcmp (A->functions_srcloc[m], - A->functions_srcloc[m-1])) + if (A->frames[m]->function_srcloc == + A->frames[m-1]->function_srcloc) { g_string_append_c (string, '\n'); g_string_append_c (string, '\t'); - g_string_append (string, A->functions_srcloc[m]); - if (A->functions[n] == main_fn) + g_string_append (string, A->frames[m]->function_srcloc); + if (A->frames[m]->function == main_fn) break; } else n++; diff --git a/src/callgraph-ring.c b/src/callgraph-ring.c index 067e7a2..4dcc74c 100644 --- a/src/callgraph-ring.c +++ b/src/callgraph-ring.c @@ -26,6 +26,7 @@ #include "odin.h" #include "callgraph.h" +#include "frames.h" #define _(x) x @@ -107,7 +108,7 @@ layout_alloc (CallGraphRing *self) static CallGraphRingLayout * _call_graph_ring_get_parents (CallGraphRing *self, - gulong ip, + Frame *frame, const gchar *exclude1, const gchar *exclude2, gdouble angle1, @@ -120,34 +121,34 @@ _call_graph_ring_get_parents (CallGraphRing *self, CallGraphRingLayout *accum, *eol = frames; guint sum_allocs; - if (ip == 0) + if (frame == NULL) return frames; - list = call_graph_store_get_parents (store, ip); + list = call_graph_store_get_parents (store, frame); frames_ht = g_hash_table_new (NULL, NULL); function_ht = g_hash_table_new (NULL, NULL); sum_allocs = 0; for (l = list; l != NULL; l = g_list_next (l)) { CallGraphFrame *frame = l->data; - if (frame->function == exclude1 || frame->function == exclude2) + if (frame->frame->function == exclude1 || frame->frame->function == exclude2) continue; - if (g_hash_table_lookup (frames_ht, GUINT_TO_POINTER (frame->ip))) + if (g_hash_table_lookup (frames_ht, frame->frame)) continue; - accum = g_hash_table_lookup (function_ht, frame->function); + accum = g_hash_table_lookup (function_ht, frame->frame->function); if (accum == NULL) { accum = layout_alloc (self); accum->frame = frame; - accum->function = frame->function; + accum->function = frame->frame->function; accum->first = FALSE; accum->allocs = 0; accum->bytes = 0; accum->next = frames; frames = accum; g_hash_table_insert (function_ht, - (gpointer) frame->function, accum); + (gpointer) accum->function, accum); } if (frame->allocs > accum->frame->allocs) @@ -157,7 +158,7 @@ _call_graph_ring_get_parents (CallGraphRing *self, accum->bytes += frame->bytes; sum_allocs += frame->allocs; - g_hash_table_insert (frames_ht, GUINT_TO_POINTER (frame->ip), frame); + g_hash_table_insert (frames_ht, frame->frame, frame); } g_hash_table_destroy (frames_ht); g_hash_table_destroy (function_ht); @@ -180,7 +181,7 @@ _call_graph_ring_get_parents (CallGraphRing *self, static CallGraphRingLayout * _call_graph_ring_get_children (CallGraphRing *self, - gulong ip, + const Frame *frame, const gchar *exclude1, const gchar *exclude2, gdouble angle1, @@ -193,31 +194,31 @@ _call_graph_ring_get_children (CallGraphRing *self, CallGraphRingLayout *accum, *eol = frames; guint sum_allocs; - list = call_graph_store_get_children (store, ip); + list = call_graph_store_get_children (store, frame); frames_ht = g_hash_table_new (NULL, NULL); function_ht = g_hash_table_new (NULL, NULL); sum_allocs = 0; for (l = list; l != NULL; l = g_list_next (l)) { CallGraphFrame *frame = l->data; - if (frame->function == exclude1 || frame->function == exclude2) + if (frame->frame->function == exclude1 || frame->frame->function == exclude2) continue; - if (g_hash_table_lookup (frames_ht, GUINT_TO_POINTER (frame->ip))) + if (g_hash_table_lookup (frames_ht, frame->frame)) continue; - accum = g_hash_table_lookup (function_ht, frame->function); + accum = g_hash_table_lookup (function_ht, frame->frame->function); if (accum == NULL) { accum = layout_alloc (self); accum->frame = frame; accum->first = FALSE; - accum->function = frame->function; + accum->function = frame->frame->function; accum->allocs = 0; accum->bytes = 0; accum->next = frames; frames = accum; g_hash_table_insert (function_ht, - (gpointer) frame->function, accum); + (gpointer) accum->function, accum); } if (frame->allocs > accum->frame->allocs) @@ -227,7 +228,7 @@ _call_graph_ring_get_children (CallGraphRing *self, accum->bytes += frame->bytes; sum_allocs += frame->allocs; - g_hash_table_insert (frames_ht, GUINT_TO_POINTER (frame->ip), frame); + g_hash_table_insert (frames_ht, frame->frame, frame); } g_hash_table_destroy (function_ht); g_hash_table_destroy (frames_ht); @@ -497,7 +498,7 @@ call_graph_ring_expose (GtkWidget *widget, GdkEventExpose *ev) layout = pango_layout_new (ctx); g_object_unref (ctx); - pango_layout_set_text (layout, frame->function, -1); + pango_layout_set_text (layout, frame->frame->function, -1); pango_layout_get_pixel_size (layout, &width, &height); cairo_save (cr); cairo_translate (cr, ww, hh); @@ -516,19 +517,19 @@ call_graph_ring_expose (GtkWidget *widget, GdkEventExpose *ev) if (self->layout_dirty) { g_assert (self->parents == NULL); - if (self->frame->ip) { + if (self->frame->frame->ip) { self->parents = _call_graph_ring_get_parents (self, - self->frame->ip, - self->frame->function, + self->frame->frame, + self->frame->frame->function, NULL, -2 * G_PI / 3., -4 * G_PI / 3., self->parents); for (frames = self->parents; frames != NULL; frames = frames->next) { self->parents2 = _call_graph_ring_get_parents (self, - frames->frame->ip, - self->frame->function, - frames->frame->function, + frames->frame->frame, + self->frame->frame->function, + frames->frame->frame->function, frames->angle1, frames->angle2, self->parents2); @@ -537,17 +538,17 @@ call_graph_ring_expose (GtkWidget *widget, GdkEventExpose *ev) g_assert (self->children == NULL); self->children = _call_graph_ring_get_children (self, - self->frame->ip, - self->frame->function, + self->frame->frame, + self->frame->frame->function, NULL, - G_PI / 3., G_PI / 3., self->children); for (frames = self->children; frames != NULL; frames = frames->next) { self->children2 = _call_graph_ring_get_children (self, - frames->frame->ip, - self->frame->function, - frames->frame->function, + frames->frame->frame, + self->frame->frame->function, + frames->frame->frame->function, frames->angle1, frames->angle2, self->children2); diff --git a/src/callgraph-store.c b/src/callgraph-store.c index e777198..e91f48a 100644 --- a/src/callgraph-store.c +++ b/src/callgraph-store.c @@ -27,11 +27,17 @@ #include "odin.h" #include "callgraph.h" +#include "frames.h" #define _(x) x typedef gboolean (*TraverseFunc) (CallGraphStore *, CallGraphFrame *, gpointer); +static const Frame _Everything = { + .function = "Everything", + .function_srcloc = "Everything", +}; + enum { INSERTED = 1 << 0, @@ -291,11 +297,11 @@ _tree_foreach (TreeNode *node, } inline CallGraphFrame * -call_graph_store_lookup_by_ip (CallGraphStore *store, gulong ip) +call_graph_store_lookup_by_frame (CallGraphStore *store, const Frame *f) { - guint index = (ip ^ 6017773UL) % store->frames_by_ip.size; + guint index = (f->ip ^ 6017773UL) % store->frames_by_ip.size; CallGraphFrame *node = store->frames_by_ip.nodes[index]; - while (node != NULL && node->ip != ip) + while (node != NULL && node->frame != f) node = node->ht_next_by_ip; return node; } @@ -305,7 +311,7 @@ call_graph_store_lookup_by_fn (CallGraphStore *store, const gchar *function) { guint index = ((gulong) function ^ 6017773UL) % store->frames_by_fn.size; CallGraphFrame *node = store->frames_by_fn.nodes[index]; - while (node != NULL && node->function != function) + while (node != NULL && node->frame->function != function) node = node->ht_next_by_fn; return node; } @@ -355,16 +361,16 @@ _call_graph_frame_accumulate (CallGraphFrame *frame, const AllocatorTime *At, co static gint _call_graph_frame_node_cmp (gconstpointer A, gconstpointer B) { - CallGraphFrame *a = container_of (A, CallGraphFrame, node); - CallGraphFrame *b = container_of (B, CallGraphFrame, node); - return a->ip - b->ip; + const CallGraphFrame *a = container_of (A, CallGraphFrame, node); + const CallGraphFrame *b = container_of (B, CallGraphFrame, node); + return a->frame - b->frame; } static gint _call_graph_frame_key_cmp (gconstpointer A, gconstpointer B) { - CallGraphFrame *b = container_of (B, CallGraphFrame, node); - return (gulong) A - b->ip; + const CallGraphFrame *b = container_of (B, CallGraphFrame, node); + return (Frame *) A - b->frame; } static CallGraphFrame * @@ -386,9 +392,7 @@ _call_graph_frame_new (CallGraphStore *store, frame->depth = depth; g_assert (depth < A->n_frames); - frame->ip = A->ips[depth]; - frame->frame = A->functions_srcloc[depth]; - frame->function = A->functions[depth]; + frame->frame = A->frames[depth]; frame->parent = parent; @@ -409,9 +413,9 @@ _call_graph_frame_new (CallGraphStore *store, &frame->node, _call_graph_frame_node_cmp); - index = (frame->ip ^ 6017773UL) % store->frames_by_ip.size; + index = (frame->frame->ip ^ 6017773UL) % store->frames_by_ip.size; prev = &store->frames_by_ip.nodes[index]; - while ((node = *prev) != NULL && node->ip != frame->ip) + while ((node = *prev) != NULL && node->frame != frame->frame) prev = &node->ht_next_by_ip; if (node != NULL) { frame->next_by_ip = node; @@ -421,9 +425,9 @@ _call_graph_frame_new (CallGraphStore *store, frame->ht_next_by_ip = store->frames_by_ip.nodes[index]; store->frames_by_ip.nodes[index] = frame; - index = ((gulong) frame->function ^ 6017773UL) % store->frames_by_fn.size; + index = ((gulong) frame->frame->function ^ 6017773UL) % store->frames_by_fn.size; prev = &store->frames_by_fn.nodes[index]; - while ((node = *prev) != NULL && node->function != frame->function) + while ((node = *prev) != NULL && node->frame->function != frame->frame->function) prev = &node->ht_next_by_fn; if (node != NULL) { frame->next_by_fn = node; @@ -582,7 +586,7 @@ _call_graph_store_get_value (GtkTreeModel *tree_model, switch (column) { case CG_FRAME: g_value_init (value, G_TYPE_STRING); - g_value_set_string (value, frame->frame); + g_value_set_string (value, frame->frame->function_srcloc); break; case CG_BYTES: @@ -737,7 +741,7 @@ simple_hash_table_init (SimpleHashTable *ht, guint size) static void call_graph_store_init (CallGraphStore *self) { - self->root.frame = self->root.function = "Everything"; + self->root.frame = (Frame *) &_Everything; self->root.depth = -1; self->frames = &self->root; @@ -930,7 +934,7 @@ call_graph_store_update (CallGraphStore *store, child = NULL; if (frame->children != NULL) child = _tree_lookup (frame->children, - (gpointer) A->ips[n], + A->frames[n], _call_graph_frame_key_cmp); if (child == NULL) { _call_graph_frame_new (store, A, n, frame); @@ -953,7 +957,7 @@ call_graph_store_update (CallGraphStore *store, n++; while (n < AA->n_frames && n < A->n_frames && - A->ips[n] == AA->ips[n]) + A->frames[n] == AA->frames[n]) { child = _call_graph_frame_new (store, AA, n, child); _call_graph_frame_accumulate (child, At, Ap); @@ -994,7 +998,7 @@ _call_graph_frame_is_alloc (CallGraphFrame *frame, App *app) { gboolean was_alloc_fn = frame->is_alloc_fn; - frame->is_alloc_fn = app_is_alloc_fn (app, frame->ip); + frame->is_alloc_fn = app_is_alloc_fn (app, frame->frame); /* XXX juggle tree model signals */ if (frame->is_alloc_fn) { @@ -1107,50 +1111,49 @@ call_graph_store_get_iter (CallGraphStore *store, CallGraphFrame *frame, GtkTree } GList * -call_graph_store_get_parents (CallGraphStore *store, gulong ip) +call_graph_store_get_parents (CallGraphStore *store, const Frame *frame) { GList *list = NULL; - CallGraphFrame *frame; + CallGraphFrame *f; - g_assert (ip != 0); - frame = call_graph_store_lookup_by_ip (store, ip); - while (frame != NULL) { - CallGraphFrame *parent = frame->filter_parent; + f = call_graph_store_lookup_by_frame (store, frame); + while (f != NULL) { + CallGraphFrame *parent = f->filter_parent; if (parent == NULL) continue; - parent= call_graph_store_lookup_by_fn (store, parent->function); + parent= call_graph_store_lookup_by_fn (store, parent->frame->function); while (parent != NULL) { list = g_list_prepend (list, parent); parent = parent->next_by_fn; } - frame = frame->next_by_ip; + f = f->next_by_ip; } return list; } GList * -call_graph_store_get_children (CallGraphStore *store, gulong ip) +call_graph_store_get_children (CallGraphStore *store, const Frame *frame) { GList *list = NULL; - CallGraphFrame *frame; + CallGraphFrame *f; guint n; - if (ip == 0) { - frame = &store->root; - for (n = 0; n < frame->n_filter; n++) - list = g_list_prepend (list, frame->filter[n]); + if (frame == &_Everything) { + f = &store->root; + for (n = 0; n < f->n_filter; n++) + list = g_list_prepend (list, f->filter[n]); } else { - frame = call_graph_store_lookup_by_ip (store, ip); - while (frame != NULL) { + f = call_graph_store_lookup_by_frame (store, frame); + while (f != NULL) { - for (n = 0; n < frame->n_filter; n++) - list = g_list_prepend (list, frame->filter[n]); + for (n = 0; n < f->n_filter; n++) + list = g_list_prepend (list, f->filter[n]); - frame = frame->next_by_ip; + f = f->next_by_ip; } } diff --git a/src/callgraph-treemap.c b/src/callgraph-treemap.c index 1f93790..e60ad89 100644 --- a/src/callgraph-treemap.c +++ b/src/callgraph-treemap.c @@ -26,6 +26,7 @@ #include "odin.h" #include "callgraph.h" +#include "frames.h" #define _(x) x @@ -139,7 +140,7 @@ call_graph_tree_map_layout_subdivide (CallGraphTreeMap *self, CallGraphTreeMapLa layout->extents.width = rect->width - 2*BORDER; layout->extents.height = rect->height - 2*BORDER; - layout->frame = frame->ip ? frame : NULL; + layout->frame = frame->frame->ip ? frame : NULL; layout->children = NULL; if (layout->extents.width < BORDER || layout->extents.height < BORDER) @@ -420,10 +421,10 @@ out: break; frame = f; - if (f->function == main_fn) + if (f->frame->function == main_fn) break; - f = call_graph_store_lookup_by_ip (self->model, frame->ip); + f = call_graph_store_lookup_by_frame (self->model, frame->frame); sum = 20 * frame->allocs / 19; while (f != NULL) { sum -= f->allocs; @@ -435,7 +436,7 @@ out: if (sum < 0) break; } - layout->frame = frame->ip ? frame : frame->n_filter ? frame->filter[0] : NULL; + layout->frame = frame->frame->ip ? frame : frame->n_filter ? frame->filter[0] : NULL; } } @@ -663,7 +664,7 @@ call_graph_tree_map_draw_label (CallGraphTreeMap *self, text = pango_layout_new (ctx); pango_layout_set_width (text, layout->extents.width - 2*BORDER); - pango_layout_set_text (text, layout->frame->frame, -1); + pango_layout_set_text (text, layout->frame->frame->function_srcloc, -1); pango_layout_get_pixel_extents (text, NULL, &logical); if (logical.width > layout->extents.width - 2*BORDER || @@ -865,13 +866,13 @@ call_graph_tree_map_query_tooltip (GtkWidget *widget, for (l = list; l != NULL; l = g_slist_next (l)) { CallGraphFrame *frame = l->data; - if (last != NULL && strcmp (frame->frame, last) == 0) - break; + if (frame->frame->function_srcloc == last) + continue; g_string_append_c (string, '\n'); g_string_append_c (string, '\t'); - g_string_append (string, frame->frame); - last = frame->frame; + g_string_append (string, frame->frame->function_srcloc); + last = frame->frame->function_srcloc; if (++n == 16) break; diff --git a/src/callgraph.c b/src/callgraph.c index 3584aad..10a25e3 100644 --- a/src/callgraph.c +++ b/src/callgraph.c @@ -26,6 +26,7 @@ #include "odin.h" #include "callgraph.h" +#include "frames.h" #define _(x) x @@ -304,7 +305,7 @@ call_graph_query_tooltip (GtkWidget *widget, guint n; gchar *text; - if (frame->function == main_fn) + if (frame->frame->function == main_fn) return FALSE; if (frame->allocator == NULL && frame->n_filter == 0) return FALSE; @@ -321,7 +322,7 @@ call_graph_query_tooltip (GtkWidget *widget, if (child->frame != child->parent->frame) { if (++n == 8) break; - if (frame->function == main_fn) + if (frame->frame->function == main_fn) break; } if (child->allocator != NULL) @@ -337,11 +338,12 @@ call_graph_query_tooltip (GtkWidget *widget, frame = frame->filter[0]; n = 0; do { - if (frame->frame != frame->parent->frame) { + if (frame->frame->function_srcloc != + frame->parent->frame->function_srcloc) { g_string_append_c (string, '\n'); g_string_append_c (string, '\t'); - g_string_append (string, frame->frame); - if (frame->function == main_fn) + g_string_append (string, frame->frame->function_srcloc); + if (frame->frame->function == main_fn) break; if (++n == 8) break; @@ -354,18 +356,18 @@ call_graph_query_tooltip (GtkWidget *widget, } else string = g_string_new ("Called from:"); - if (frame->function != main_fn && n < 8) { - const gchar *last_frame = frame->frame; + if (frame->frame->function != main_fn && n < 8) { + const gchar *last_frame = frame->frame->function_srcloc; const Allocator *A = frame->allocator; guint m = frame->depth + 1; g_assert (A != NULL); do { - const gchar *str = A->functions_srcloc[m]; + const gchar *str = A->frames[m]->function_srcloc; if (str != last_frame) { g_string_append_c (string, '\n'); g_string_append_c (string, '\t'); g_string_append (string, str); - if (str == main_fn) + if (A->frames[m]->function == main_fn) break; if (++n == 8) break; @@ -561,7 +563,7 @@ call_graph_search_equal_func (GtkTreeModel *model, gpointer data) { CallGraphFrame *frame = iter->user_data; - return strncmp (frame->frame, key, strlen (key)) != 0; + return strncmp (frame->frame->function, key, strlen (key)) != 0; } static void diff --git a/src/callgraph.h b/src/callgraph.h index bdc0b41..5c24491 100644 --- a/src/callgraph.h +++ b/src/callgraph.h @@ -40,15 +40,12 @@ struct _simple_hash_table { }; struct _call_graph_frame { - gulong ip; + Frame *frame; + gboolean is_alloc_fn; const Allocator *allocator; guint depth; - const gchar *frame; - const gchar *function; - gboolean is_alloc_fn; - guint64 bytes; guint allocs; guint frees; @@ -117,16 +114,16 @@ void call_graph_store_filter (CallGraphStore *store, App *app); CallGraphFrame * -call_graph_store_lookup_by_ip (CallGraphStore *store, gulong ip); +call_graph_store_lookup_by_frame (CallGraphStore *store, const Frame *frame); CallGraphFrame * call_graph_store_lookup_by_fn (CallGraphStore *store, const gchar *function); GList * -call_graph_store_get_parents (CallGraphStore *store, gulong ip); +call_graph_store_get_parents (CallGraphStore *store, const Frame *frame); GList * -call_graph_store_get_children (CallGraphStore *store, gulong ip); +call_graph_store_get_children (CallGraphStore *store, const Frame *frame); gboolean call_graph_store_get_iter (CallGraphStore *store, CallGraphFrame *frame, GtkTreeIter *iter); diff --git a/src/frames.c b/src/frames.c index aac8847..dea9760 100644 --- a/src/frames.c +++ b/src/frames.c @@ -187,14 +187,9 @@ frames_has_ip (Frames *frames, gulong ip) } gboolean -frames_is_alloc_fn (Frames *frames, gulong ip) +frames_is_alloc_fn (Frames *frames, Frame *f) { GList *l; - Frame *f; - - f = frames_get (frames, ip); - if (f == NULL) - return FALSE; if (! f->has_function) return TRUE; diff --git a/src/frames.h b/src/frames.h index c63dc73..208729c 100644 --- a/src/frames.h +++ b/src/frames.h @@ -26,7 +26,6 @@ G_BEGIN_DECLS -typedef struct _frame Frame; struct _frame { gulong ip; gboolean has_function; @@ -73,7 +72,7 @@ gboolean frames_has_ip (Frames *frames, gulong ip); gboolean -frames_is_alloc_fn (Frames *frames, gulong ip); +frames_is_alloc_fn (Frames *frames, Frame *f); Frame * frames_get (Frames *frames, gulong ip); @@ -33,6 +33,8 @@ typedef struct _allocator_time AllocatorTime; typedef struct _block Block; typedef struct _chunk Chunk; typedef struct _thread_faults ThreadFaults; + +typedef struct _frame Frame; typedef struct _frames Frames; typedef struct _shared_object SharedObject; @@ -76,9 +78,7 @@ struct _allocator { gulong key; Allocator *next, *ht_next; guint n_frames; - gulong *ips; - const gchar **functions; - const gchar **functions_srcloc; + Frame **frames; const gchar *alloc_fn; guint alloc_fn_serial; struct _allocator_time { @@ -161,7 +161,7 @@ gboolean app_add_alloc_fn (App *app, const gchar *pattern, GError **error); gboolean -app_is_alloc_fn (App *app, gulong ip); +app_is_alloc_fn (App *app, Frame *f); guint app_get_alloc_fns_serial (App *app); diff --git a/src/summary-chart.c b/src/summary-chart.c index 447b4da..e8deebe 100644 --- a/src/summary-chart.c +++ b/src/summary-chart.c @@ -396,18 +396,19 @@ summary_chart_query_tooltip (GtkWidget *widget, A->time_tail->n_allocs * 100. / sum->count); for (n = 0; n < A->n_frames; n++) - if (A->alloc_fn == A->functions[n]) + if (A->frames[n]->function == A->alloc_fn) break; main_fn = app_get_main_function (app_get (widget)); for (m = n; m < MIN (n + 8, A->n_frames); m++) { - if (A->functions_srcloc[m] != A->functions_srcloc[m-1]) { + if (A->frames[m]->function_srcloc != + A->frames[m-1]->function_srcloc) { g_string_append_c (string, '\n'); g_string_append_c (string, '\t'); - g_string_append (string, A->functions_srcloc[m]); + g_string_append (string, A->frames[m]->function_srcloc); } else n++; - if (A->functions[m] == main_fn) + if (A->frames[m]->function == main_fn) break; } } diff --git a/src/summary-view.c b/src/summary-view.c index f1ae0d9..7211ba3 100644 --- a/src/summary-view.c +++ b/src/summary-view.c @@ -158,18 +158,18 @@ summary_view_query_tooltip (GtkWidget *widget, A->time_tail->n_allocs * 100. / sum->count); for (n = 0; n < A->n_frames; n++) - if (A->alloc_fn == A->functions[n]) + if (A->frames[n]->function == A->alloc_fn) break; main_fn = app_get_main_function (app_get (widget)); for (m = n; m < MIN (n + 8, A->n_frames); m++) { - if (A->functions_srcloc[m] != A->functions_srcloc[m-1]) { + if (A->frames[m]->function_srcloc != A->frames[m-1]->function_srcloc) { g_string_append_c (string, '\n'); g_string_append_c (string, '\t'); - g_string_append (string, A->functions_srcloc[m]); + g_string_append (string, A->frames[m]->function_srcloc); } else n++; - if (A->functions[m] == main_fn) + if (A->frames[m]->function == main_fn) break; } text = g_string_free (string, FALSE); |