[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Libunwind-devel] [PATCH 0/1] Fast back-trace for x86_64 for only co
From: |
Arun Sharma |
Subject: |
Re: [Libunwind-devel] [PATCH 0/1] Fast back-trace for x86_64 for only collecting the call stack |
Date: |
Wed, 26 May 2010 09:34:31 -0700 |
On Wed, May 26, 2010 at 6:25 AM, Lassi Tuura <address@hidden> wrote:
Hi Lassi,
>
> > This patch adds new function to perform a pure stack walk without
> > unwinding, functionally similar to backtrace() but accelerated by an
> > address attribute cache the caller maintains across calls.
>
> Any news on this patch? This is rather useful for us and I would like to
> see some accelerated lookup functionality included in libunwind, even if
> it isn't this patch.
I'm a bit behind on libunwind related emails/patches, but hope to look
at your patch in more detail in the next week or so.
I've reproduced the core of your proposal here - so others can chime in too.
+ unw_getcontext(&ctx);
+ memcpy(&saved, &ctx, sizeof(ctx));
+
+ unw_init_local(&cur, &ctx);
+ if (! cache || (ret = unw_tdep_trace(&cur, addrs, &depth, cache)) < 0)
+ {
+ depth = 0;
+ unw_init_local(&cur, &saved);
+ while (depth < 128)
+ {
+ unw_word_t ip;
+ unw_get_reg(&cur, UNW_REG_IP, &ip);
+ addresses[depth++] = (void *) ip;
+ if ((ret = unw_step(&cur)) <= 0)
+ break;
+ }
+ }
I generally like the idea of having a fast back trace with a fall back
to a correct, slower, but more general case. A couple of initial
comments:
* Why not use a call back based API instead of a backtrace() style API? For eg:
+ while (depth < 128)
+ {
+ unw_word_t ip;
+ unw_get_reg(&cur, UNW_REG_IP, &ip);
+ addresses[depth++] = (void *) ip;
+ if ((ret = unw_fast_step(&cur)) <= 0)
+ break;
+ }
* I couldn't tell what is the locking protocol on the frame cache. In
the multi-threaded case, do you expect to have a global frame cache or
a per-thread frame cache?
-Arun