mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2025-01-11 03:23:43 +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)
|
do { fprintf (stderr, args); ++nerrors; } while (0)
|
||||||
|
|
||||||
static unw_addr_space_t as;
|
static unw_addr_space_t as;
|
||||||
|
static struct UPT_info *ui;
|
||||||
|
|
||||||
void
|
void
|
||||||
do_backtrace (pid_t target_pid)
|
do_backtrace (pid_t target_pid)
|
||||||
|
@ -49,9 +50,7 @@ do_backtrace (pid_t target_pid)
|
||||||
unw_cursor_t c;
|
unw_cursor_t c;
|
||||||
char buf[512];
|
char buf[512];
|
||||||
int ret;
|
int ret;
|
||||||
struct UPT_info *ui;
|
|
||||||
|
|
||||||
ui = _UPT_create (target_pid);
|
|
||||||
ret = unw_init_remote (&c, as, ui);
|
ret = unw_init_remote (&c, as, ui);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
panic ("unw_init_remote() failed: ret=%d\n", ret);
|
panic ("unw_init_remote() failed: ret=%d\n", ret);
|
||||||
|
@ -89,8 +88,6 @@ do_backtrace (pid_t target_pid)
|
||||||
}
|
}
|
||||||
while (ret > 0);
|
while (ret > 0);
|
||||||
|
|
||||||
_UPT_destroy (ui);
|
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
panic ("unwind failed with ret=%d\n", ret);
|
panic ("unwind failed with ret=%d\n", ret);
|
||||||
|
|
||||||
|
@ -129,6 +126,8 @@ main (int argc, char **argv)
|
||||||
_exit (-1);
|
_exit (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui = _UPT_create (target_pid);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
pid = wait4 (-1, &status, 0, 0);
|
pid = wait4 (-1, &status, 0, 0);
|
||||||
|
@ -166,6 +165,8 @@ main (int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_UPT_destroy (ui);
|
||||||
|
|
||||||
if (nerrors)
|
if (nerrors)
|
||||||
{
|
{
|
||||||
printf ("FAILURE: detected %d errors\n", nerrors);
|
printf ("FAILURE: detected %d errors\n", nerrors);
|
||||||
|
|
Loading…
Reference in a new issue