Patch for lldb bug 26322 “core load hangs”
authorHoward Hellyer <hhellyer@uk.ibm.com>
Thu, 24 Nov 2016 08:56:37 +0000 (08:56 +0000)
committerHoward Hellyer <hhellyer@uk.ibm.com>
Thu, 24 Nov 2016 08:56:37 +0000 (08:56 +0000)
commit1a2ac9bda573919f52123d93baf91501023b5ba8
treecac70dd6edf06d2a04f76aafa6ca51b4dda698cf
parent1c7f07aa3e8b268877f4163b95d066647f0df651
Patch for lldb bug 26322 “core load hangs”

Summary:
This patch changes the way ProcessElfCore.cpp handles signal information.
The patch changes ProcessElfCore.cpp to use the signal from si_signo in SIGINFO notes in preference to the value of cursig in PRSTATUS notes. The value from SIGINFO seems to be more thread specific. The value from PRSTATUS is usually the same for all threads even if only one thread received a signal.
If it cannot find any SIGINFO blocks it reverts to the old behaviour and uses the value from cursig in PRSTATUS. If after that no thread appears to have been stopped it forces the status of the first thread to be SIGSTOP to prevent lldb hanging waiting for any thread from the core file to change state.

The order is:
- If one or more threads have a non-zero si_signo in SIGINFO that will be used.
- If no threads had a SIGINFO block with a non-zero si_signo set all threads signals to the value in cursig in their PRSTATUS notes.
- If no thread has a signal set to a non-zero value set the signal for only the first thread to SIGSTOP.

This resolves two issues. The first was identified in bug 26322, the second became apparent while investigating this problem and looking at the signal values reported for each thread via “thread list”.

Firstly lldb is able to load core dumps generated by gcore where each thread has a SIGINFO note containing a signal number but cursig in the PRSTATUS block for each thread is 0.

Secondly if a SIGINFO note was found the “thread list” command will no longer show the same signal number for all threads. At the moment if a process crashes, for example with SIGILL, all threads will show “stop reason = signal SIGILL”. With this patch only the thread that executed the illegal instruction shows that stop reason. The other threads show “stop reason = signal 0”.

Reviewers: jingham, clayborg

Subscribers: sas, labath, lldb-commits

Differential Revision: https://reviews.llvm.org/D26676

llvm-svn: 287858
15 files changed:
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/TestGCore.py [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/linux-i386.core [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/linux-x86_64.core [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.cpp [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/main.mk [new file with mode: 0755]
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/gcore/make-core.sh [new file with mode: 0755]
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/linux-i386.core [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/linux-x86_64.core [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.cpp [new file with mode: 0644]
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/main.mk [new file with mode: 0755]
lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/make-core.sh [new file with mode: 0755]
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
lldb/source/Plugins/Process/elf-core/ThreadElfCore.h