unwind: initialize unwind context only if given tcb is initialized

With libdw based unwinder, following warnings are reported
when -p is passed before -k:

   $ ./strace -p 1 -k
   ...
   ./strace: dwfl_linux_proc_attach returned an error for process 0: No such file or directory
   ...

It seems that commit 54c7792b, "Fix libunwind segfault when -p is
passed before -k" doesn't fix the original issue.

* strace.c (init) [ENABLE_STACKTRACE]: Initialize unwind context only
if given tcb is initialized.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
This commit is contained in:
Masatake YAMATO 2018-04-19 17:49:47 +09:00 committed by Dmitry V. Levin
parent ee2c065dd4
commit 98d3356b04

View File

@ -1783,6 +1783,8 @@ init(int argc, char *argv[])
unwind_init();
for (tcbi = 0; tcbi < tcbtabsize; ++tcbi) {
if (!tcbtab[tcbi]->pid)
continue;
unwind_tcb_init(tcbtab[tcbi]);
}
}