Call callback with an extra boolean indicating whether the sample read was

2007-10-20  Soren Sandmann <sandmann@daimi.au.dk>

       * collector.c (on_read): Call callback with an extra boolean
       indicating whether the sample read was the first one

       * collector.c (add_trace_to_stash): Allocate addresses on the
       stack if possible.

       * sysprof.c (on_new_sample): Only call update_sensitivity() on the
       first sample.

       * stackstash.c (stack_stash_add_trace): Move match to front


svn path=/trunk/; revision=373
This commit is contained in:
Soren Sandmann
2007-10-20 23:51:35 +00:00
committed by Søren Sandmann Pedersen
parent f1cbdbf27c
commit 476e6f0c1b
5 changed files with 42 additions and 10 deletions

View File

@ -1,3 +1,16 @@
2007-10-20 Soren Sandmann <sandmann@daimi.au.dk>
* collector.c (on_read): Call callback with an extra boolean
indicating whether the sample read was the first one
* collector.c (add_trace_to_stash): Allocate addresses on the
stack if possible.
* sysprof.c (on_new_sample): Only call update_sensitivity() on the
first sample.
* stackstash.c (stack_stash_add_trace): Move match to front
2007-09-16 Soren Sandmann <sandmann@daimi.au.dk>
* process.c (process_lookup_kernel_symbol): Add support for

View File

@ -94,11 +94,17 @@ add_trace_to_stash (const SysprofStackTrace *trace,
int n_addresses;
int n_kernel_words;
int a;
gulong addrs_stack[2048];
int n_alloc;
n_addresses = trace->n_addresses;
n_kernel_words = trace->n_kernel_words;
addrs = g_new (gulong, n_addresses + n_kernel_words + 2);
n_alloc = n_addresses + n_kernel_words + 2;
if (n_alloc <= 2048)
addrs = addrs_stack;
else
addrs = g_new (gulong, n_alloc);
a = 0;
/* Add kernel addresses */
@ -140,7 +146,8 @@ add_trace_to_stash (const SysprofStackTrace *trace,
stack_stash_add_trace (
stash, addrs, a, 1);
g_free (addrs);
if (addrs != addrs_stack)
g_free (addrs);
}
static gboolean
@ -202,7 +209,7 @@ on_read (gpointer data)
collector->n_samples++;
if (collector->callback)
collector->callback (collector->data);
collector->callback (collector->n_samples == 1, collector->data);
}
}

View File

@ -21,7 +21,8 @@
typedef struct Collector Collector;
typedef void (* CollectorFunc) (gpointer data);
typedef void (* CollectorFunc) (gboolean first_sample,
gpointer data);
#define COLLECTOR_ERROR collector_error_quark ()

View File

@ -165,13 +165,21 @@ stack_stash_add_trace (StackStash *stash,
for (i = n_addrs - 1; i >= 0; --i)
{
StackNode *match = NULL;
StackNode *n;
StackNode *prev;
for (n = *location; n != NULL; n = n->siblings)
prev = NULL;
for (match = *location; match != NULL; prev = match, match = match->siblings)
{
if (n->address == (gpointer)addrs[i])
if (match->address == (gpointer)addrs[i])
{
match = n;
if (prev)
{
/* move to front */
prev->siblings = match->siblings;
match->siblings = *location;
*location = match;
}
break;
}
}

View File

@ -1552,12 +1552,15 @@ build_gui (Application *app)
}
static void
on_new_sample (gpointer data)
on_new_sample (gboolean first_sample,
gpointer data)
{
Application *app = data;
if (app->state == PROFILING)
if (app->state == PROFILING && first_sample)
update_sensitivity (app);
else
queue_show_samples (app);
}
static Application *