1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-09-27 08:59:28 +02:00

(do_backtrace): Adjust for "offset" argument in unw_get_proc_name() and print

procedure name in a prettier fashion.

(Logical change 1.45)
This commit is contained in:
mostang.com!davidm 2003-02-08 10:10:59 +00:00
parent 7e29f92baa
commit 5f82f8e557

View file

@ -40,11 +40,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
static void
do_backtrace (void)
{
char buf[512], name[256];
unw_word_t ip, sp, off;
unw_cursor_t cursor;
unw_proc_info_t pi;
unw_word_t ip, sp;
unw_context_t uc;
char buf[512];
int ret;
unw_getcontext (&uc);
@ -55,7 +55,14 @@ do_backtrace (void)
{
unw_get_reg (&cursor, UNW_REG_IP, &ip);
unw_get_reg (&cursor, UNW_REG_SP, &sp);
unw_get_proc_name (&cursor, buf, sizeof (buf));
buf[0] = '\0';
if (unw_get_proc_name (&cursor, name, sizeof (name), &off) == 0)
{
if (off)
snprintf (buf, sizeof (buf), "<%s+0x%lx>", name, off);
else
snprintf (buf, sizeof (buf), "<%s>", name);
}
printf ("%016lx %-32s (sp=%016lx)\n", (long) ip, buf, (long) sp);
unw_get_proc_info (&cursor, &pi);