diff options
| author | Zachary Turner <zturner@google.com> | 2014-12-03 22:04:18 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2014-12-03 22:04:18 +0000 |
| commit | c6a6653ebb59a40f1701bd757540cdaf1108c969 (patch) | |
| tree | fba6553f28bbb3e1fb79ea0297e6029051f775bb /lldb/source/Plugins/Process/Windows/ProcessWindows.cpp | |
| parent | bbc017851815da300ce9d6315204a73d68754a1c (diff) | |
| download | bcm5719-llvm-c6a6653ebb59a40f1701bd757540cdaf1108c969.tar.gz bcm5719-llvm-c6a6653ebb59a40f1701bd757540cdaf1108c969.zip | |
Correctly shutdown when DoDestroy is called with an active exception.
Previously if we got a DoDestroy while stopped at a breakpoint, we
would detach and then say the process had exited. This is completely
wrong, as it resulted in the python script incorrectly assuming that
the process had actually exited and trying to delete the image, when
in fact it had done no such thing.
The fix employed here is that when we get a DoDestroy, we do 3 steps:
1) initiate a termination sequence on the process
2) If we were stopped handling an exception of any kind, mask it and
let the program resume, causing the program to see the termination
request and exit on its own.
3) Let the program exit normally, and close all of our handles before
returning control back to DoDestroy.
This fixes Bug 21722 and Bug 21723.
llvm-svn: 223272
Diffstat (limited to 'lldb/source/Plugins/Process/Windows/ProcessWindows.cpp')
| -rw-r--r-- | lldb/source/Plugins/Process/Windows/ProcessWindows.cpp | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/lldb/source/Plugins/Process/Windows/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/ProcessWindows.cpp index a577d202111..b19bfbd0077 100644 --- a/lldb/source/Plugins/Process/Windows/ProcessWindows.cpp +++ b/lldb/source/Plugins/Process/Windows/ProcessWindows.cpp @@ -61,7 +61,6 @@ class ProcessWindowsData ~ProcessWindowsData() { ::CloseHandle(m_initial_stop_event); } ProcessLaunchInfo m_launch_info; - std::shared_ptr<lldb_private::ExceptionRecord> m_active_exception; lldb_private::Error m_launch_error; lldb_private::DebuggerThreadSP m_debugger; StopInfoSP m_pending_stop_info; @@ -237,11 +236,10 @@ ProcessWindows::DoResume() Error error; if (GetPrivateState() == eStateStopped) { - if (m_session_data->m_active_exception) + if (m_session_data->m_debugger->GetActiveException()) { // Resume the process and continue processing debug events. Mask the exception so that // from the process's view, there is no indication that anything happened. - m_session_data->m_active_exception.reset(); m_session_data->m_debugger->ContinueAsyncException(ExceptionResult::MaskException); } @@ -279,10 +277,10 @@ ProcessWindows::DoDestroy() Error error; if (GetPrivateState() != eStateExited && GetPrivateState() != eStateDetached && m_session_data) { - // Ends the debugging session and terminates the inferior process. - DebugActiveProcessStop(m_session_data->m_debugger->GetProcess().GetProcessId()); - SetPrivateState(eStateExited); + DebuggerThread &debugger = *m_session_data->m_debugger; + error = debugger.StopDebugging(true); } + m_session_data.reset(); return error; } @@ -291,28 +289,28 @@ ProcessWindows::RefreshStateAfterStop() { m_thread_list.RefreshStateAfterStop(); - if (m_session_data->m_active_exception) - { - StopInfoSP stop_info; - ThreadSP stop_thread = m_thread_list.GetSelectedThread(); - RegisterContextSP register_context = stop_thread->GetRegisterContext(); + ExceptionRecord *active_exception = m_session_data->m_debugger->GetActiveException(); + if (!active_exception) + return; - ExceptionRecord &exception = *m_session_data->m_active_exception; - if (exception.GetExceptionCode() == EXCEPTION_BREAKPOINT) - { - uint64_t pc = register_context->GetPC(); - BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc)); - lldb::break_id_t break_id = LLDB_INVALID_BREAK_ID; - bool should_stop = true; - if (site) - { - should_stop = site->ValidForThisThread(stop_thread.get()); - break_id = site->GetID(); - } + StopInfoSP stop_info; + ThreadSP stop_thread = m_thread_list.GetSelectedThread(); + RegisterContextSP register_context = stop_thread->GetRegisterContext(); - stop_info = StopInfo::CreateStopReasonWithBreakpointSiteID(*stop_thread, break_id, should_stop); - stop_thread->SetStopInfo(stop_info); + if (active_exception->GetExceptionCode() == EXCEPTION_BREAKPOINT) + { + uint64_t pc = register_context->GetPC(); + BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc)); + lldb::break_id_t break_id = LLDB_INVALID_BREAK_ID; + bool should_stop = true; + if (site) + { + should_stop = site->ValidForThisThread(stop_thread.get()); + break_id = site->GetID(); } + + stop_info = StopInfo::CreateStopReasonWithBreakpointSiteID(*stop_thread, break_id, should_stop); + stop_thread->SetStopInfo(stop_info); } } @@ -442,7 +440,6 @@ ExceptionResult ProcessWindows::OnDebugException(bool first_chance, const ExceptionRecord &record) { ExceptionResult result = ExceptionResult::SendToApplication; - m_session_data->m_active_exception.reset(new ExceptionRecord(record)); switch (record.GetExceptionCode()) { case EXCEPTION_BREAKPOINT: |

