summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-11-29 22:10:04 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2007-11-29 22:10:04 +0000
commit0e8581652c8f6de4de4bb998786d3517af8d4b60 (patch)
tree96f17d8bff640166360bd1ee371f1bcef022bf7e
parent790239953ae11e92990df88defd20725a448893c (diff)
Accumulate deltas.
-rw-r--r--Makefile.am35
-rw-r--r--src/allocators.c6
-rw-r--r--src/app.c26
-rw-r--r--src/blockmap.c5
-rw-r--r--src/callgraph-ring.c3
-rw-r--r--src/callgraph-store.c20
-rw-r--r--src/callgraph-treemap.c2
-rw-r--r--src/frames.c8
-rw-r--r--src/frames.h12
-rw-r--r--src/memfault.h20
-rw-r--r--src/timeline.c3
11 files changed, 65 insertions, 75 deletions
diff --git a/Makefile.am b/Makefile.am
index 69bc0a6..924e44c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,21 +1,20 @@
bin_PROGRAMS = memfault-gui
-memfault_gui_SOURCES = \
- src/memfault.h \
- src/app.c \
- src/blockmap.c \
- src/timeline.c \
- src/allocators.c \
- src/frames.h \
- src/frames.c \
- src/callgraph.h \
- src/callgraph.c \
- src/callgraph-store.c \
- src/callgraph-ring.c \
- src/callgraph-treemap.c \
- src/procmap.h \
- src/procmap.c \
- src/procmap-store.c \
- src/utils.c
-memfault_gui_CFLAGS = @MEMFAULT_CFLAGS@ @gtk_CFLAGS@ -DG_ENABLE_DEBUG
+memfault_gui_SOURCES = src/memfault.h \
+ src/app.c \
+ src/blockmap.c \
+ src/timeline.c \
+ src/allocators.c \
+ src/frames.h \
+ src/frames.c \
+ src/callgraph.h \
+ src/callgraph.c \
+ src/callgraph-store.c \
+ src/callgraph-ring.c \
+ src/callgraph-treemap.c \
+ src/procmap.h \
+ src/procmap.c \
+ src/procmap-store.c \
+ src/utils.c
+memfault_gui_CFLAGS = @MEMFAULT_CFLAGS@ @gtk_CFLAGS@
memfault_gui_LDADD = @gtk_LIBS@
diff --git a/src/allocators.c b/src/allocators.c
index c0107cc..02bde48 100644
--- a/src/allocators.c
+++ b/src/allocators.c
@@ -49,17 +49,11 @@ typedef struct _allocators_class {
GtkTreeViewClass parent_class;
} AllocatorsClass;
-static GType
-allocators_get_type (void);
-
G_DEFINE_TYPE (Allocators, allocators, GTK_TYPE_TREE_VIEW)
static void
allocators_store_tree_model_init (GtkTreeModelIface *iface);
-static GType
-allocators_store_get_type (void);
-
G_DEFINE_TYPE_WITH_CODE (AllocatorsStore, allocators_store, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL,
allocators_store_tree_model_init))
diff --git a/src/app.c b/src/app.c
index 5d26e12..a0aecac 100644
--- a/src/app.c
+++ b/src/app.c
@@ -167,7 +167,7 @@ read_string (int fd, gchar **bp, guint *rem, gchar **str)
}
static Allocator *
-app_get_allocator (App *app, gulong key)
+app_get_allocator (App *app, guint key)
{
guint index = (key ^ 6017773) % app->allocators_by_addr.size;
Allocator *A = app->allocators_by_addr.nodes[index];
@@ -229,7 +229,7 @@ discard_allocator_time (int fd)
static Allocator *
read_allocator (App *app, int fd, guint time)
{
- gulong key;
+ guint key;
Allocator *A;
AllocatorTime *At;
guint magic;
@@ -250,22 +250,22 @@ read_allocator (App *app, int fd, guint time)
A = app_perm_alloc (app, sizeof (Allocator));
A->key = key;
At = &A->time[0];
+ A->time_tail = NULL;
if (! readn (fd, &A->n_frames, sizeof (A->n_frames)))
return NULL;
A->ips = app_perm_alloc (app,
- sizeof (gulong) * A->n_frames +
+ sizeof (guint) * 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;
- if (! readn (fd, A->ips, A->n_frames * sizeof (gulong)))
+ if (! readn (fd, A->ips, A->n_frames * sizeof (guint)))
return NULL;
for (n = 0; n < A->n_frames; n++) {
Frame *frame = frames_get (&app->frames, A->ips[n]);
- g_return_val_if_fail (frame != NULL, NULL);
A->functions[n] = frame->function;
A->functions_srcloc[n] = frame->function_srcloc;
}
@@ -309,10 +309,12 @@ read_allocator (App *app, int fd, guint time)
At = app_perm_alloc (app, sizeof (AllocatorTime));
A->time_tail->next = At;
}
+ At->prev = A->time_tail;
A->time_tail = At;
- At->time = time;
At->next = NULL;
+ At->time = time;
+
if (! readn (fd, &At->bytes, sizeof (At->bytes)) ||
! readn (fd, &At->freed, sizeof (At->freed)) ||
! readn (fd, &At->max_size, sizeof (At->max_size)) ||
@@ -397,9 +399,9 @@ static Block *
read_block (App *app, int fd, Block *blocks)
{
Block *b;
- gulong addr;
+ guint addr;
gsize size;
- gulong allocator;
+ guint allocator;
Allocator *A;
guint age;
@@ -542,7 +544,7 @@ load_allocators (GIOChannel *io, App *app)
return FALSE;
while (count--) {
gchar buf[4096], *bp = buf;
- gulong eip;
+ guint eip;
gchar *function, *object, *file, *directory;
gint line;
guint len = G_N_ELEMENTS (buf);
@@ -638,7 +640,7 @@ load_allocators (GIOChannel *io, App *app)
while (count--) {
Event ev;
gchar c;
- gulong allocator;
+ guint allocator;
if (! readn (fd, &c, sizeof (c)) ||
@@ -1082,7 +1084,7 @@ tcp_log_server_cb (GIOChannel *source,
}
gboolean
-app_is_alloc_fn (App *app, gulong ip)
+app_is_alloc_fn (App *app, guint ip)
{
return frames_is_alloc_fn (&app->frames, ip);
}
@@ -1134,7 +1136,7 @@ app_get (GtkWidget *widget)
}
G_CONST_RETURN Event *
-app_find_prev_event_for_addr_range (App *app, guint time, gulong min, gulong max)
+app_find_prev_event_for_addr_range (App *app, guint time, guint min, guint max)
{
guint n;
diff --git a/src/blockmap.c b/src/blockmap.c
index 952e035..ade5bff 100644
--- a/src/blockmap.c
+++ b/src/blockmap.c
@@ -12,7 +12,7 @@ struct _block_map {
gdouble aspect;
guint width, height;
- gulong min, max, pages;
+ guint min, max, pages;
guint pagesize;
Block *blocks;
@@ -28,9 +28,6 @@ typedef struct _block_map_class {
GtkWidgetClass parent_class;
} BlockMapClass;
-static GType
-block_map_get_type (void);
-
G_DEFINE_TYPE (BlockMap, block_map, GTK_TYPE_WIDGET)
enum {
diff --git a/src/callgraph-ring.c b/src/callgraph-ring.c
index 78cf2a5..57eadcb 100644
--- a/src/callgraph-ring.c
+++ b/src/callgraph-ring.c
@@ -47,9 +47,6 @@ enum {
static guint signals[LAST_SIGNAL];
-static GType
-call_graph_ring_get_type (void);
-
G_DEFINE_TYPE (CallGraphRing, call_graph_ring, GTK_TYPE_WIDGET)
enum {
diff --git a/src/callgraph-store.c b/src/callgraph-store.c
index fb55b3f..3f297b9 100644
--- a/src/callgraph-store.c
+++ b/src/callgraph-store.c
@@ -322,20 +322,20 @@ _call_graph_frame_alloc (CallGraphStore *store)
}
static void
-_call_graph_frame_accumulate (CallGraphStore *store, CallGraphFrame *frame, AllocatorTime *At)
+_call_graph_frame_accumulate (CallGraphFrame *frame, const AllocatorTime *At, const AllocatorTime *Ap)
{
guint n, max;
g_assert (frame != NULL);
g_assert (At != NULL);
- frame->bytes += At->bytes;
- frame->allocs += At->n_allocs;
- frame->frees += At->n_frees;
+ frame->bytes += At->bytes - Ap->bytes;
+ frame->allocs += At->n_allocs - Ap->n_allocs;
+ frame->frees += At->n_frees - Ap->n_frees;
max = At->max_size_alloc;
g_assert (max <= G_N_ELEMENTS (frame->size_allocs));
for (n = 0; n < max; n++)
- frame->size_allocs[n] += At->size_allocs[n];
+ frame->size_allocs[n] += At->size_allocs[n] - Ap->size_allocs[n];
}
@@ -735,6 +735,7 @@ call_graph_store_update (CallGraphStore *store,
Allocator *allocators,
guint since)
{
+ static AllocatorTime nil;
Allocator *A;
CallGraphFrame *frame, *child, *eol;
guint n, new, updated;
@@ -746,14 +747,19 @@ call_graph_store_update (CallGraphStore *store,
new = updated = 0;
for (A = allocators; A != NULL; A = A->next) {
AllocatorTime *At = A->time_tail;
+ AllocatorTime *Ap = A->time_tail->prev;
+
if (At->time <= since)
continue;
+ if (Ap == NULL)
+ Ap = &nil;
+
if (At->max_size_alloc > store->max_size_alloc)
store->max_size_alloc = At->max_size_alloc;
frame = store->root;
- _call_graph_frame_accumulate (store, frame, At);
+ _call_graph_frame_accumulate (frame, At, Ap);
for (n = 0; n < A->n_frames; n++) {
child = NULL;
if (frame->children != NULL)
@@ -769,7 +775,7 @@ call_graph_store_update (CallGraphStore *store,
}
frame = child;
g_assert (frame != NULL);
- _call_graph_frame_accumulate (store, frame, At);
+ _call_graph_frame_accumulate (frame, At, Ap);
}
updated++;
}
diff --git a/src/callgraph-treemap.c b/src/callgraph-treemap.c
index 644f1b6..e3dec2c 100644
--- a/src/callgraph-treemap.c
+++ b/src/callgraph-treemap.c
@@ -51,8 +51,6 @@ static CallGraphTreeMapLayout *
call_graph_tree_map_find_layout_for_cursor (CallGraphTreeMap *self,
gint x, gint y);
-static GType
-call_graph_tree_map_get_type (void);
G_DEFINE_TYPE (CallGraphTreeMap, call_graph_tree_map, GTK_TYPE_WIDGET)
diff --git a/src/frames.c b/src/frames.c
index 38d71eb..ed85cfb 100644
--- a/src/frames.c
+++ b/src/frames.c
@@ -3,7 +3,7 @@
#include <string.h>
Frame *
-frames_get (Frames *frames, gulong ip)
+frames_get (Frames *frames, guint ip)
{
guint index = (ip ^ 6017773) % frames->frames.size;
Frame *frame = frames->frames.nodes[index];
@@ -119,7 +119,7 @@ srcloc_equal (const Frame *a, const Frame *b)
void
frames_add (Frames *frames,
- gulong ip,
+ guint ip,
const gchar *function,
const gchar *object,
const gchar *file,
@@ -236,13 +236,13 @@ frames_add (Frames *frames,
}
gboolean
-frames_has_ip (Frames *frames, gulong ip)
+frames_has_ip (Frames *frames, guint ip)
{
return frames_get (frames, ip) != NULL;
}
gboolean
-frames_is_alloc_fn (Frames *frames, gulong ip)
+frames_is_alloc_fn (Frames *frames, guint ip)
{
GList *l;
Frame *f;
diff --git a/src/frames.h b/src/frames.h
index 821d24c..6697ec0 100644
--- a/src/frames.h
+++ b/src/frames.h
@@ -7,7 +7,7 @@ G_BEGIN_DECLS
typedef struct _frame Frame;
struct _frame {
- gulong ip;
+ guint ip;
const gchar *function;
const gchar *object;
const gchar *file;
@@ -47,26 +47,26 @@ struct _frames {
void
frames_add (Frames *frames,
- gulong ip,
+ guint ip,
const gchar *function,
const gchar *object,
const gchar *file,
const gchar *directory,
gint line);
gboolean
-frames_has_ip (Frames *frames, gulong ip);
+frames_has_ip (Frames *frames, guint ip);
gboolean
-frames_is_alloc_fn (Frames *frames, gulong ip);
+frames_is_alloc_fn (Frames *frames, guint ip);
Frame *
-frames_get (Frames *frames, gulong ip);
+frames_get (Frames *frames, guint ip);
guint
frames_get_unique_count (Frames *frames);
gchar *
-frames_get_source_path (Frames *frames, gulong ip);
+frames_get_source_path (Frames *frames, guint ip);
gboolean
frames_add_alloc_fn (Frames *frames, const gchar *pattern, GError **error);
diff --git a/src/memfault.h b/src/memfault.h
index 83f6b37..7605dc0 100644
--- a/src/memfault.h
+++ b/src/memfault.h
@@ -26,7 +26,7 @@ typedef struct _call_graph_store_class CallGraphStoreClass;
struct _block {
Block *next;
- gulong addr;
+ guint addr;
gsize size;
guint age;
Allocator *allocator;
@@ -46,13 +46,13 @@ struct _thread_faults {
};
struct _allocator {
- gulong key;
+ guint key;
Allocator *next, *ht_next;
guint n_frames;
const gchar **functions;
const gchar **functions_srcloc;
const gchar *alloc_fn;
- gulong *ips;
+ guint *ips;
struct _allocator_time {
guint time;
guint64 bytes;
@@ -67,7 +67,7 @@ struct _allocator {
guint peak_blocks;
gsize peak_bytes;
ThreadFaults faults;
- AllocatorTime *next;
+ AllocatorTime *next, *prev;
} time[1];
AllocatorTime *time_tail;
};
@@ -91,7 +91,7 @@ typedef struct _event_alloc {
guint tid;
Allocator *allocator;
- gulong addr;
+ guint addr;
gsize size;
} EventAlloc;
@@ -101,9 +101,9 @@ typedef struct _event_realloc {
guint tid;
Allocator *allocator;
- gulong old_addr;
+ guint old_addr;
gsize old_size;
- gulong new_addr;
+ guint new_addr;
gsize new_size;
} EventRealloc;
@@ -113,7 +113,7 @@ typedef struct _event_dealloc {
guint tid;
Allocator *allocator;
- gulong addr;
+ guint addr;
gsize size;
} EventDealloc;
@@ -136,7 +136,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, guint ip);
guint
app_get_alloc_fns_serial (App *app);
@@ -194,7 +194,7 @@ GtkWidget *
procmap_new (void);
G_CONST_RETURN Event *
-app_find_prev_event_for_addr_range (App *app, guint time, gulong min, gulong max);
+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);
diff --git a/src/timeline.c b/src/timeline.c
index 468aab4..3960694 100644
--- a/src/timeline.c
+++ b/src/timeline.c
@@ -32,9 +32,6 @@ typedef struct _timeline_class {
GtkWidgetClass parent_class;
} TimelineClass;
-static GType
-timeline_get_type (void);
-
G_DEFINE_TYPE (Timeline, timeline, GTK_TYPE_WIDGET)
static void