On Thu, 4 June 2009 21:58:12 +0200, Jörn Engel wrote:
> 
> Ah, that works.  Thank you Arun.

And for the curious, this trivial bit of code allows mimicking the
kernel:

#define UNW_LOCAL_ONLY
#include <libunwind.h>

void dump_stack(void)
{
        unw_cursor_t cursor;
        unw_context_t uc;
        char name[80];
        unw_word_t ip, ofs;

        unw_getcontext(&uc);
        unw_init_local(&cursor, &uc);
        while (unw_step(&cursor) > 0) {
                unw_get_proc_name(&cursor, name, sizeof(name), &ofs);
                unw_get_reg(&cursor, UNW_REG_IP, &ip);
                printf("[%08llx] %s+0x%llx\n", (long long)ip, name,
                                (long long)ofs);
        }
}

And it can be _very_ useful in debugging.  So again, thank you very
much.

Jörn

-- 
Premature optimization is the root of all evil.
-- Donald Knuth


_______________________________________________
Libunwind-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/libunwind-devel

Reply via email to