mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-12-23 12:03:41 +01:00
(ui): Make it global instead of local to do_backtrace().
(do_backtrace): Move creation/destruction of the UPT-info structure from here... (main): ...to here. (Logical change 1.44)
This commit is contained in:
parent
385b56fb3d
commit
de4410dce0
1 changed files with 5 additions and 4 deletions
|
@ -40,6 +40,7 @@ int verbose = 1;
|
|||
do { fprintf (stderr, args); ++nerrors; } while (0)
|
||||
|
||||
static unw_addr_space_t as;
|
||||
static struct UPT_info *ui;
|
||||
|
||||
void
|
||||
do_backtrace (pid_t target_pid)
|
||||
|
@ -49,9 +50,7 @@ do_backtrace (pid_t target_pid)
|
|||
unw_cursor_t c;
|
||||
char buf[512];
|
||||
int ret;
|
||||
struct UPT_info *ui;
|
||||
|
||||
ui = _UPT_create (target_pid);
|
||||
ret = unw_init_remote (&c, as, ui);
|
||||
if (ret < 0)
|
||||
panic ("unw_init_remote() failed: ret=%d\n", ret);
|
||||
|
@ -89,8 +88,6 @@ do_backtrace (pid_t target_pid)
|
|||
}
|
||||
while (ret > 0);
|
||||
|
||||
_UPT_destroy (ui);
|
||||
|
||||
if (ret < 0)
|
||||
panic ("unwind failed with ret=%d\n", ret);
|
||||
|
||||
|
@ -129,6 +126,8 @@ main (int argc, char **argv)
|
|||
_exit (-1);
|
||||
}
|
||||
|
||||
ui = _UPT_create (target_pid);
|
||||
|
||||
while (1)
|
||||
{
|
||||
pid = wait4 (-1, &status, 0, 0);
|
||||
|
@ -166,6 +165,8 @@ main (int argc, char **argv)
|
|||
#endif
|
||||
}
|
||||
|
||||
_UPT_destroy (ui);
|
||||
|
||||
if (nerrors)
|
||||
{
|
||||
printf ("FAILURE: detected %d errors\n", nerrors);
|
||||
|
|
Loading…
Reference in a new issue