libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] Re: libunwind on x86 issues


From: Jörn Engel
Subject: [Libunwind-devel] Re: libunwind on x86 issues
Date: Thu, 4 Jun 2009 22:24:50 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]