mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-26 09:07:38 +01:00
(do_backtrace): Keep track of initial IP so we can issue better error messages.
(main): Update comment for -t. (Logical change 1.276)
This commit is contained in:
parent
b4f1459444
commit
b0048ee762
1 changed files with 9 additions and 5 deletions
|
@ -70,7 +70,7 @@ do_backtrace (pid_t target_pid)
|
||||||
{
|
{
|
||||||
int n = 0, ret;
|
int n = 0, ret;
|
||||||
unw_proc_info_t pi;
|
unw_proc_info_t pi;
|
||||||
unw_word_t ip, sp;
|
unw_word_t ip, sp, start_ip;
|
||||||
unw_cursor_t c;
|
unw_cursor_t c;
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
|
||||||
|
@ -84,6 +84,9 @@ do_backtrace (pid_t target_pid)
|
||||||
|| (ret = unw_get_reg (&c, UNW_REG_SP, &sp)) < 0)
|
|| (ret = unw_get_reg (&c, UNW_REG_SP, &sp)) < 0)
|
||||||
panic ("unw_get_reg/unw_get_proc_name() failed: ret=%d\n", ret);
|
panic ("unw_get_reg/unw_get_proc_name() failed: ret=%d\n", ret);
|
||||||
|
|
||||||
|
if (n == 0)
|
||||||
|
start_ip = ip;
|
||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
if (print_names)
|
if (print_names)
|
||||||
unw_get_proc_name (&c, buf, sizeof (buf), NULL);
|
unw_get_proc_name (&c, buf, sizeof (buf), NULL);
|
||||||
|
@ -115,8 +118,8 @@ do_backtrace (pid_t target_pid)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
unw_get_reg (&c, UNW_REG_IP, &ip);
|
unw_get_reg (&c, UNW_REG_IP, &ip);
|
||||||
panic ("FAILURE: unw_step() returned %d for ip=%lx\n",
|
panic ("FAILURE: unw_step() returned %d for ip=%lx (start ip=%lx)\n",
|
||||||
ret, (long) ip);
|
ret, (long) ip, (long) start_ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++n > 32)
|
if (++n > 32)
|
||||||
|
@ -162,7 +165,8 @@ main (int argc, char **argv)
|
||||||
else if (strcmp (argv[optind], "-s") == 0)
|
else if (strcmp (argv[optind], "-s") == 0)
|
||||||
++optind, trace_mode = SYSCALL; /* backtrace at each syscall */
|
++optind, trace_mode = SYSCALL; /* backtrace at each syscall */
|
||||||
else if (strcmp (argv[optind], "-t") == 0)
|
else if (strcmp (argv[optind], "-t") == 0)
|
||||||
/* Execute until syscall(-1), then backtrace at each insn. */
|
/* Execute until raise(SIGUSR1), then backtrace at each insn
|
||||||
|
until raise(SIGUSR2). */
|
||||||
++optind, trace_mode = TRIGGER;
|
++optind, trace_mode = TRIGGER;
|
||||||
else if (strcmp (argv[optind], "-c") == 0)
|
else if (strcmp (argv[optind], "-c") == 0)
|
||||||
/* Enable caching of unwind-info. */
|
/* Enable caching of unwind-info. */
|
||||||
|
|
Loading…
Reference in a new issue