diff options
| author | Martin Storsjö <martin@martin.st> | 2019-10-28 10:28:26 +0200 |
|---|---|---|
| committer | Martin Storsjö <martin@martin.st> | 2019-10-31 11:26:20 +0200 |
| commit | 403cd574b6d9fbdae1b39fe9d2576b02c7139486 (patch) | |
| tree | 483a5a1092f0179136dbc6476999428621d034ca /lldb/source/Plugins/Process | |
| parent | 3db1d138b1172b5855f35ab74dbf3bf327f517d2 (diff) | |
| download | bcm5719-llvm-403cd574b6d9fbdae1b39fe9d2576b02c7139486.tar.gz bcm5719-llvm-403cd574b6d9fbdae1b39fe9d2576b02c7139486.zip | |
[LLDB] [Windows] Fix Windows-specific race condition in LLDB for session lifetime
This can e.g. happen if the debugged executable exits before the initial
stop, e.g. if it fails to load dependent DLLs.
Add a virtual destructor to ProcessDebugger and let it clean up the
session, and make ProcessWindows::OnExitProcess call
ProcessDebugger::OnExitProcess for shared parts.
Fix suggestion by Adrian McCarthy.
Differential Revision: https://reviews.llvm.org/D69503
Diffstat (limited to 'lldb/source/Plugins/Process')
3 files changed, 5 insertions, 10 deletions
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp index 6ee882f7f88..cd780518fe2 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp @@ -63,6 +63,8 @@ static bool IsPageExecutable(uint32_t protect) { namespace lldb_private { +ProcessDebugger::~ProcessDebugger() {} + lldb::pid_t ProcessDebugger::GetDebuggedProcessId() const { if (m_session_data) return m_session_data->m_debugger->GetProcess().GetProcessId(); diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h index b4d053f8834..a4db76455ef 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.h @@ -48,6 +48,8 @@ public: class ProcessDebugger { public: + virtual ~ProcessDebugger(); + virtual void OnExitProcess(uint32_t exit_code); virtual void OnDebuggerConnected(lldb::addr_t image_base); virtual ExceptionResult OnDebugException(bool first_chance, diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp index c4b7a6d1a90..d4e60ec2b43 100644 --- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp @@ -625,16 +625,7 @@ void ProcessWindows::OnExitProcess(uint32_t exit_code) { SetProcessExitStatus(GetID(), true, 0, exit_code); SetPrivateState(eStateExited); - // If the process exits before any initial stop then notify the debugger - // of the error otherwise WaitForDebuggerConnection() will be blocked. - // An example of this issue is when a process fails to load a dependent DLL. - if (m_session_data && !m_session_data->m_initial_stop_received) { - Status error(exit_code, eErrorTypeWin32); - OnDebuggerError(error, 0); - } - - // Reset the session. - m_session_data.reset(); + ProcessDebugger::OnExitProcess(exit_code); } void ProcessWindows::OnDebuggerConnected(lldb::addr_t image_base) { |

