Alexander Shaposhnikov | 696bd63 | 2016-11-26 05:23:44 +0000 | [diff] [blame] | 1 | //===-- DebuggerThread.cpp --------------------------------------*- C++ -*-===// |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "DebuggerThread.h" |
Zachary Turner | dcd8037 | 2014-11-11 00:00:14 +0000 | [diff] [blame] | 10 | #include "ExceptionRecord.h" |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 11 | #include "IDebugDelegate.h" |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 12 | |
Zachary Turner | a32d2ce | 2014-11-12 19:31:56 +0000 | [diff] [blame] | 13 | #include "lldb/Core/ModuleSpec.h" |
Pavel Labath | e7404d9 | 2019-02-04 15:03:06 +0000 | [diff] [blame] | 14 | #include "lldb/Host/ProcessLaunchInfo.h" |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 15 | #include "lldb/Host/ThreadLauncher.h" |
| 16 | #include "lldb/Host/windows/HostProcessWindows.h" |
| 17 | #include "lldb/Host/windows/HostThreadWindows.h" |
| 18 | #include "lldb/Host/windows/ProcessLauncherWindows.h" |
Zachary Turner | c62733b | 2015-05-20 18:31:17 +0000 | [diff] [blame] | 19 | #include "lldb/Target/Process.h" |
Zachary Turner | 5713a05 | 2017-03-22 18:40:07 +0000 | [diff] [blame] | 20 | #include "lldb/Utility/FileSpec.h" |
Zachary Turner | 6f9e690 | 2017-03-03 20:56:28 +0000 | [diff] [blame] | 21 | #include "lldb/Utility/Log.h" |
Raphael Isemann | 7fae493 | 2018-08-30 17:51:10 +0000 | [diff] [blame] | 22 | #include "lldb/Utility/Predicate.h" |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 23 | #include "lldb/Utility/Status.h" |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 24 | |
Adrian McCarthy | 18a9135d | 2015-10-28 18:21:45 +0000 | [diff] [blame] | 25 | #include "Plugins/Process/Windows/Common/ProcessWindowsLog.h" |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 26 | |
Zachary Turner | a32d2ce | 2014-11-12 19:31:56 +0000 | [diff] [blame] | 27 | #include "llvm/ADT/STLExtras.h" |
Zachary Turner | 190fadc | 2016-03-22 17:58:09 +0000 | [diff] [blame] | 28 | #include "llvm/Support/ConvertUTF.h" |
Zachary Turner | ed96be9 | 2017-03-04 01:31:06 +0000 | [diff] [blame] | 29 | #include "llvm/Support/Threading.h" |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 30 | #include "llvm/Support/raw_ostream.h" |
| 31 | |
| 32 | using namespace lldb; |
| 33 | using namespace lldb_private; |
| 34 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 35 | namespace { |
| 36 | struct DebugLaunchContext { |
| 37 | DebugLaunchContext(DebuggerThread *thread, |
| 38 | const ProcessLaunchInfo &launch_info) |
| 39 | : m_thread(thread), m_launch_info(launch_info) {} |
| 40 | DebuggerThread *m_thread; |
| 41 | ProcessLaunchInfo m_launch_info; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 42 | }; |
Zachary Turner | c62733b | 2015-05-20 18:31:17 +0000 | [diff] [blame] | 43 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 44 | struct DebugAttachContext { |
| 45 | DebugAttachContext(DebuggerThread *thread, lldb::pid_t pid, |
| 46 | const ProcessAttachInfo &attach_info) |
| 47 | : m_thread(thread), m_pid(pid), m_attach_info(attach_info) {} |
| 48 | DebuggerThread *m_thread; |
| 49 | lldb::pid_t m_pid; |
| 50 | ProcessAttachInfo m_attach_info; |
Zachary Turner | c62733b | 2015-05-20 18:31:17 +0000 | [diff] [blame] | 51 | }; |
Aaron Smith | e303790 | 2018-10-10 18:30:32 +0000 | [diff] [blame] | 52 | } // namespace |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 53 | |
| 54 | DebuggerThread::DebuggerThread(DebugDelegateSP debug_delegate) |
Zachary Turner | 5a8ad459 | 2016-10-05 17:07:34 +0000 | [diff] [blame] | 55 | : m_debug_delegate(debug_delegate), m_pid_to_detach(0), |
| 56 | m_is_shutting_down(false) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 57 | m_debugging_ended_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 60 | DebuggerThread::~DebuggerThread() { ::CloseHandle(m_debugging_ended_event); } |
| 61 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 62 | Status DebuggerThread::DebugLaunch(const ProcessLaunchInfo &launch_info) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 63 | Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); |
| 64 | LLDB_LOG(log, "launching '{0}'", launch_info.GetExecutableFile().GetPath()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 65 | |
Stella Stamenova | 631b5f7d | 2019-07-09 18:10:36 +0000 | [diff] [blame] | 66 | Status result; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 67 | DebugLaunchContext *context = new DebugLaunchContext(this, launch_info); |
Stella Stamenova | 631b5f7d | 2019-07-09 18:10:36 +0000 | [diff] [blame] | 68 | |
| 69 | llvm::Expected<HostThread> slave_thread = ThreadLauncher::LaunchThread( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 70 | "lldb.plugin.process-windows.slave[?]", DebuggerThreadLaunchRoutine, |
Stella Stamenova | 631b5f7d | 2019-07-09 18:10:36 +0000 | [diff] [blame] | 71 | context); |
| 72 | if (!slave_thread) { |
| 73 | result = Status(slave_thread.takeError()); |
| 74 | LLDB_LOG(log, "couldn't launch debugger thread. {0}", result); |
| 75 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 76 | |
Stella Stamenova | 631b5f7d | 2019-07-09 18:10:36 +0000 | [diff] [blame] | 77 | return result; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 80 | Status DebuggerThread::DebugAttach(lldb::pid_t pid, |
| 81 | const ProcessAttachInfo &attach_info) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 82 | Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); |
| 83 | LLDB_LOG(log, "attaching to '{0}'", pid); |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 84 | |
Stella Stamenova | 631b5f7d | 2019-07-09 18:10:36 +0000 | [diff] [blame] | 85 | Status result; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 86 | DebugAttachContext *context = new DebugAttachContext(this, pid, attach_info); |
Stella Stamenova | 631b5f7d | 2019-07-09 18:10:36 +0000 | [diff] [blame] | 87 | |
| 88 | llvm::Expected<HostThread> slave_thread = ThreadLauncher::LaunchThread( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 89 | "lldb.plugin.process-windows.slave[?]", DebuggerThreadAttachRoutine, |
Stella Stamenova | 631b5f7d | 2019-07-09 18:10:36 +0000 | [diff] [blame] | 90 | context); |
| 91 | if (!slave_thread) { |
| 92 | result = Status(slave_thread.takeError()); |
| 93 | LLDB_LOG(log, "couldn't attach to process '{0}'. {1}", pid, result); |
| 94 | } |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 95 | |
Stella Stamenova | 631b5f7d | 2019-07-09 18:10:36 +0000 | [diff] [blame] | 96 | return result; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 97 | } |
| 98 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 99 | lldb::thread_result_t DebuggerThread::DebuggerThreadLaunchRoutine(void *data) { |
| 100 | DebugLaunchContext *context = static_cast<DebugLaunchContext *>(data); |
| 101 | lldb::thread_result_t result = |
| 102 | context->m_thread->DebuggerThreadLaunchRoutine(context->m_launch_info); |
| 103 | delete context; |
| 104 | return result; |
Zachary Turner | c62733b | 2015-05-20 18:31:17 +0000 | [diff] [blame] | 105 | } |
| 106 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 107 | lldb::thread_result_t DebuggerThread::DebuggerThreadAttachRoutine(void *data) { |
| 108 | DebugAttachContext *context = static_cast<DebugAttachContext *>(data); |
| 109 | lldb::thread_result_t result = context->m_thread->DebuggerThreadAttachRoutine( |
| 110 | context->m_pid, context->m_attach_info); |
| 111 | delete context; |
| 112 | return result; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 113 | } |
| 114 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 115 | lldb::thread_result_t DebuggerThread::DebuggerThreadLaunchRoutine( |
| 116 | const ProcessLaunchInfo &launch_info) { |
| 117 | // Grab a shared_ptr reference to this so that we know it won't get deleted |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 118 | // until after the thread routine has exited. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 119 | std::shared_ptr<DebuggerThread> this_ref(shared_from_this()); |
Zachary Turner | c62733b | 2015-05-20 18:31:17 +0000 | [diff] [blame] | 120 | |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 121 | Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); |
| 122 | LLDB_LOG(log, "preparing to launch '{0}' on background thread.", |
| 123 | launch_info.GetExecutableFile().GetPath()); |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 124 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 125 | Status error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 126 | ProcessLauncherWindows launcher; |
| 127 | HostProcess process(launcher.LaunchProcess(launch_info, error)); |
| 128 | // If we couldn't create the process, notify waiters immediately. Otherwise |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 129 | // enter the debug loop and wait until we get the create process debug |
| 130 | // notification. Note that if the process was created successfully, we can |
| 131 | // throw away the process handle we got from CreateProcess because Windows |
| 132 | // will give us another (potentially more useful?) handle when it sends us |
| 133 | // the CREATE_PROCESS_DEBUG_EVENT. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 134 | if (error.Success()) |
Zachary Turner | c62733b | 2015-05-20 18:31:17 +0000 | [diff] [blame] | 135 | DebugLoop(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 136 | else |
| 137 | m_debug_delegate->OnDebuggerError(error, 0); |
Zachary Turner | c62733b | 2015-05-20 18:31:17 +0000 | [diff] [blame] | 138 | |
Konrad Kleine | 8520064 | 2019-05-23 15:17:39 +0000 | [diff] [blame] | 139 | return {}; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | lldb::thread_result_t DebuggerThread::DebuggerThreadAttachRoutine( |
| 143 | lldb::pid_t pid, const ProcessAttachInfo &attach_info) { |
| 144 | // Grab a shared_ptr reference to this so that we know it won't get deleted |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 145 | // until after the thread routine has exited. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 146 | std::shared_ptr<DebuggerThread> this_ref(shared_from_this()); |
| 147 | |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 148 | Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); |
| 149 | LLDB_LOG(log, "preparing to attach to process '{0}' on background thread.", |
| 150 | pid); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 151 | |
| 152 | if (!DebugActiveProcess((DWORD)pid)) { |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 153 | Status error(::GetLastError(), eErrorTypeWin32); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 154 | m_debug_delegate->OnDebuggerError(error, 0); |
Konrad Kleine | 8520064 | 2019-05-23 15:17:39 +0000 | [diff] [blame] | 155 | return {}; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 156 | } |
| 157 | |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 158 | // The attach was successful, enter the debug loop. From here on out, this |
| 159 | // is no different than a create process operation, so all the same comments |
| 160 | // in DebugLaunch should apply from this point out. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 161 | DebugLoop(); |
| 162 | |
Konrad Kleine | 8520064 | 2019-05-23 15:17:39 +0000 | [diff] [blame] | 163 | return {}; |
Zachary Turner | c62733b | 2015-05-20 18:31:17 +0000 | [diff] [blame] | 164 | } |
| 165 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 166 | Status DebuggerThread::StopDebugging(bool terminate) { |
| 167 | Status error; |
Zachary Turner | c6a6653 | 2014-12-03 22:04:18 +0000 | [diff] [blame] | 168 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 169 | lldb::pid_t pid = m_process.GetProcessId(); |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 170 | |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 171 | Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS); |
| 172 | LLDB_LOG(log, "terminate = {0}, inferior={1}.", terminate, pid); |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 173 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 174 | // Set m_is_shutting_down to true if it was false. Return if it was already |
| 175 | // true. |
| 176 | bool expected = false; |
| 177 | if (!m_is_shutting_down.compare_exchange_strong(expected, true)) |
Zachary Turner | c6a6653 | 2014-12-03 22:04:18 +0000 | [diff] [blame] | 178 | return error; |
Zachary Turner | c6a6653 | 2014-12-03 22:04:18 +0000 | [diff] [blame] | 179 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 180 | // Make a copy of the process, since the termination sequence will reset |
| 181 | // DebuggerThread's internal copy and it needs to remain open for the Wait |
| 182 | // operation. |
| 183 | HostProcess process_copy = m_process; |
| 184 | lldb::process_t handle = m_process.GetNativeProcess().GetSystemHandle(); |
Zachary Turner | c6a6653 | 2014-12-03 22:04:18 +0000 | [diff] [blame] | 185 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 186 | if (terminate) { |
Stella Stamenova | 9d6fabf | 2018-06-13 19:02:44 +0000 | [diff] [blame] | 187 | if (handle != nullptr && handle != LLDB_INVALID_PROCESS) { |
| 188 | // Initiate the termination before continuing the exception, so that the |
| 189 | // next debug event we get is the exit process event, and not some other |
| 190 | // event. |
| 191 | BOOL terminate_suceeded = TerminateProcess(handle, 0); |
| 192 | LLDB_LOG(log, |
| 193 | "calling TerminateProcess({0}, 0) (inferior={1}), success={2}", |
| 194 | handle, pid, terminate_suceeded); |
| 195 | } else { |
| 196 | LLDB_LOG(log, |
Aaron Smith | e303790 | 2018-10-10 18:30:32 +0000 | [diff] [blame] | 197 | "NOT calling TerminateProcess because the inferior is not valid " |
| 198 | "({0}, 0) (inferior={1})", |
Stella Stamenova | 9d6fabf | 2018-06-13 19:02:44 +0000 | [diff] [blame] | 199 | handle, pid); |
| 200 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 201 | } |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 202 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 203 | // If we're stuck waiting for an exception to continue (e.g. the user is at a |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 204 | // breakpoint messing around in the debugger), continue it now. But only |
| 205 | // AFTER calling TerminateProcess to make sure that the very next call to |
| 206 | // WaitForDebugEvent is an exit process event. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 207 | if (m_active_exception.get()) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 208 | LLDB_LOG(log, "masking active exception"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 209 | ContinueAsyncException(ExceptionResult::MaskException); |
| 210 | } |
| 211 | |
| 212 | if (!terminate) { |
| 213 | // Indicate that we want to detach. |
| 214 | m_pid_to_detach = GetProcess().GetProcessId(); |
| 215 | |
| 216 | // Force a fresh break so that the detach can happen from the debugger |
| 217 | // thread. |
| 218 | if (!::DebugBreakProcess( |
| 219 | GetProcess().GetNativeProcess().GetSystemHandle())) { |
| 220 | error.SetError(::GetLastError(), eErrorTypeWin32); |
Zachary Turner | c6a6653 | 2014-12-03 22:04:18 +0000 | [diff] [blame] | 221 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 222 | } |
| 223 | |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 224 | LLDB_LOG(log, "waiting for detach from process {0} to complete.", pid); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 225 | |
| 226 | DWORD wait_result = WaitForSingleObject(m_debugging_ended_event, 5000); |
| 227 | if (wait_result != WAIT_OBJECT_0) { |
| 228 | error.SetError(GetLastError(), eErrorTypeWin32); |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 229 | LLDB_LOG(log, "error: WaitForSingleObject({0}, 5000) returned {1}", |
| 230 | m_debugging_ended_event, wait_result); |
| 231 | } else |
| 232 | LLDB_LOG(log, "detach from process {0} completed successfully.", pid); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 233 | |
| 234 | if (!error.Success()) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 235 | LLDB_LOG(log, "encountered an error while trying to stop process {0}. {1}", |
| 236 | pid, error); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 237 | } |
| 238 | return error; |
Zachary Turner | dcd8037 | 2014-11-11 00:00:14 +0000 | [diff] [blame] | 239 | } |
| 240 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 241 | void DebuggerThread::ContinueAsyncException(ExceptionResult result) { |
| 242 | if (!m_active_exception.get()) |
| 243 | return; |
Zachary Turner | dcd8037 | 2014-11-11 00:00:14 +0000 | [diff] [blame] | 244 | |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 245 | Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS | |
| 246 | WINDOWS_LOG_EXCEPTION); |
| 247 | LLDB_LOG(log, "broadcasting for inferior process {0}.", |
| 248 | m_process.GetProcessId()); |
Zachary Turner | 6c3c0ed | 2015-10-02 22:47:04 +0000 | [diff] [blame] | 249 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 250 | m_active_exception.reset(); |
| 251 | m_exception_pred.SetValue(result, eBroadcastAlways); |
| 252 | } |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 253 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 254 | void DebuggerThread::FreeProcessHandles() { |
| 255 | m_process = HostProcess(); |
| 256 | m_main_thread = HostThread(); |
| 257 | if (m_image_file) { |
| 258 | ::CloseHandle(m_image_file); |
| 259 | m_image_file = nullptr; |
| 260 | } |
| 261 | } |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 262 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 263 | void DebuggerThread::DebugLoop() { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 264 | Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT); |
Zachary Turner | 5a8ad459 | 2016-10-05 17:07:34 +0000 | [diff] [blame] | 265 | DEBUG_EVENT dbe = {}; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 266 | bool should_debug = true; |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 267 | LLDB_LOGV(log, "Entering WaitForDebugEvent loop"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 268 | while (should_debug) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 269 | LLDB_LOGV(log, "Calling WaitForDebugEvent"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 270 | BOOL wait_result = WaitForDebugEvent(&dbe, INFINITE); |
| 271 | if (wait_result) { |
| 272 | DWORD continue_status = DBG_CONTINUE; |
| 273 | switch (dbe.dwDebugEventCode) { |
Aaron Smith | e303790 | 2018-10-10 18:30:32 +0000 | [diff] [blame] | 274 | default: |
| 275 | llvm_unreachable("Unhandle debug event code!"); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 276 | case EXCEPTION_DEBUG_EVENT: { |
| 277 | ExceptionResult status = |
| 278 | HandleExceptionEvent(dbe.u.Exception, dbe.dwThreadId); |
Adrian McCarthy | a59a721 | 2015-06-19 18:26:53 +0000 | [diff] [blame] | 279 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 280 | if (status == ExceptionResult::MaskException) |
| 281 | continue_status = DBG_CONTINUE; |
| 282 | else if (status == ExceptionResult::SendToApplication) |
| 283 | continue_status = DBG_EXCEPTION_NOT_HANDLED; |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 284 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 285 | break; |
| 286 | } |
| 287 | case CREATE_THREAD_DEBUG_EVENT: |
| 288 | continue_status = |
| 289 | HandleCreateThreadEvent(dbe.u.CreateThread, dbe.dwThreadId); |
| 290 | break; |
| 291 | case CREATE_PROCESS_DEBUG_EVENT: |
| 292 | continue_status = |
| 293 | HandleCreateProcessEvent(dbe.u.CreateProcessInfo, dbe.dwThreadId); |
| 294 | break; |
| 295 | case EXIT_THREAD_DEBUG_EVENT: |
| 296 | continue_status = |
| 297 | HandleExitThreadEvent(dbe.u.ExitThread, dbe.dwThreadId); |
| 298 | break; |
| 299 | case EXIT_PROCESS_DEBUG_EVENT: |
| 300 | continue_status = |
| 301 | HandleExitProcessEvent(dbe.u.ExitProcess, dbe.dwThreadId); |
| 302 | should_debug = false; |
| 303 | break; |
| 304 | case LOAD_DLL_DEBUG_EVENT: |
| 305 | continue_status = HandleLoadDllEvent(dbe.u.LoadDll, dbe.dwThreadId); |
| 306 | break; |
| 307 | case UNLOAD_DLL_DEBUG_EVENT: |
| 308 | continue_status = HandleUnloadDllEvent(dbe.u.UnloadDll, dbe.dwThreadId); |
| 309 | break; |
| 310 | case OUTPUT_DEBUG_STRING_EVENT: |
| 311 | continue_status = HandleODSEvent(dbe.u.DebugString, dbe.dwThreadId); |
| 312 | break; |
| 313 | case RIP_EVENT: |
| 314 | continue_status = HandleRipEvent(dbe.u.RipInfo, dbe.dwThreadId); |
| 315 | if (dbe.u.RipInfo.dwType == SLE_ERROR) |
| 316 | should_debug = false; |
| 317 | break; |
| 318 | } |
| 319 | |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 320 | LLDB_LOGV(log, "calling ContinueDebugEvent({0}, {1}, {2}) on thread {3}.", |
| 321 | dbe.dwProcessId, dbe.dwThreadId, continue_status, |
| 322 | ::GetCurrentThreadId()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 323 | |
| 324 | ::ContinueDebugEvent(dbe.dwProcessId, dbe.dwThreadId, continue_status); |
| 325 | |
| 326 | if (m_detached) { |
| 327 | should_debug = false; |
| 328 | } |
| 329 | } else { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 330 | LLDB_LOG(log, "returned FALSE from WaitForDebugEvent. Error = {0}", |
| 331 | ::GetLastError()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 332 | |
| 333 | should_debug = false; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 334 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 335 | } |
| 336 | FreeProcessHandles(); |
Zachary Turner | 3c1c5b9 | 2015-05-21 19:56:26 +0000 | [diff] [blame] | 337 | |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 338 | LLDB_LOG(log, "WaitForDebugEvent loop completed, exiting."); |
Aaron Smith | e303790 | 2018-10-10 18:30:32 +0000 | [diff] [blame] | 339 | ::SetEvent(m_debugging_ended_event); |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 340 | } |
| 341 | |
Zachary Turner | dcd8037 | 2014-11-11 00:00:14 +0000 | [diff] [blame] | 342 | ExceptionResult |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 343 | DebuggerThread::HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info, |
| 344 | DWORD thread_id) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 345 | Log *log = |
| 346 | ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 347 | if (m_is_shutting_down) { |
| 348 | // A breakpoint that occurs while `m_pid_to_detach` is non-zero is a magic |
| 349 | // exception that |
| 350 | // we use simply to wake up the DebuggerThread so that we can close out the |
| 351 | // debug loop. |
| 352 | if (m_pid_to_detach != 0 && |
| 353 | info.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 354 | LLDB_LOG(log, "Breakpoint exception is cue to detach from process {0:x}", |
| 355 | m_pid_to_detach.load()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 356 | ::DebugActiveProcessStop(m_pid_to_detach); |
| 357 | m_detached = true; |
Zachary Turner | 6c3c0ed | 2015-10-02 22:47:04 +0000 | [diff] [blame] | 358 | } |
| 359 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 360 | // Don't perform any blocking operations while we're shutting down. That |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 361 | // will cause TerminateProcess -> WaitForSingleObject to time out. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 362 | return ExceptionResult::SendToApplication; |
| 363 | } |
Zachary Turner | c6a6653 | 2014-12-03 22:04:18 +0000 | [diff] [blame] | 364 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 365 | bool first_chance = (info.dwFirstChance != 0); |
Zachary Turner | c6a6653 | 2014-12-03 22:04:18 +0000 | [diff] [blame] | 366 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 367 | m_active_exception.reset( |
| 368 | new ExceptionRecord(info.ExceptionRecord, thread_id)); |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 369 | LLDB_LOG(log, "encountered {0} chance exception {1:x} on thread {2:x}", |
| 370 | first_chance ? "first" : "second", |
| 371 | info.ExceptionRecord.ExceptionCode, thread_id); |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 372 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 373 | ExceptionResult result = |
| 374 | m_debug_delegate->OnDebugException(first_chance, *m_active_exception); |
| 375 | m_exception_pred.SetValue(result, eBroadcastNever); |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 376 | |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 377 | LLDB_LOG(log, "waiting for ExceptionPred != BreakInDebugger"); |
Pavel Labath | 4b13033 | 2018-05-09 14:49:43 +0000 | [diff] [blame] | 378 | result = *m_exception_pred.WaitForValueNotEqualTo( |
| 379 | ExceptionResult::BreakInDebugger); |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 380 | |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 381 | LLDB_LOG(log, "got ExceptionPred = {0}", (int)m_exception_pred.GetValue()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 382 | return result; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | DWORD |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 386 | DebuggerThread::HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info, |
| 387 | DWORD thread_id) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 388 | Log *log = |
| 389 | ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD); |
Aaron Smith | e303790 | 2018-10-10 18:30:32 +0000 | [diff] [blame] | 390 | LLDB_LOG(log, "Thread {0} spawned in process {1}", thread_id, |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 391 | m_process.GetProcessId()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 392 | HostThread thread(info.hThread); |
| 393 | thread.GetNativeThread().SetOwnsHandle(false); |
| 394 | m_debug_delegate->OnCreateThread(thread); |
| 395 | return DBG_CONTINUE; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | DWORD |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 399 | DebuggerThread::HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info, |
| 400 | DWORD thread_id) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 401 | Log *log = |
| 402 | ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_PROCESS); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 403 | uint32_t process_id = ::GetProcessId(info.hProcess); |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 404 | |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 405 | LLDB_LOG(log, "process {0} spawned", process_id); |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 406 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 407 | std::string thread_name; |
| 408 | llvm::raw_string_ostream name_stream(thread_name); |
| 409 | name_stream << "lldb.plugin.process-windows.slave[" << process_id << "]"; |
| 410 | name_stream.flush(); |
Zachary Turner | ed96be9 | 2017-03-04 01:31:06 +0000 | [diff] [blame] | 411 | llvm::set_thread_name(thread_name); |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 412 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 413 | // info.hProcess and info.hThread are closed automatically by Windows when |
| 414 | // EXIT_PROCESS_DEBUG_EVENT is received. |
| 415 | m_process = HostProcess(info.hProcess); |
| 416 | ((HostProcessWindows &)m_process.GetNativeProcess()).SetOwnsHandle(false); |
| 417 | m_main_thread = HostThread(info.hThread); |
| 418 | m_main_thread.GetNativeThread().SetOwnsHandle(false); |
| 419 | m_image_file = info.hFile; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 420 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 421 | lldb::addr_t load_addr = reinterpret_cast<lldb::addr_t>(info.lpBaseOfImage); |
| 422 | m_debug_delegate->OnDebuggerConnected(load_addr); |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 423 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 424 | return DBG_CONTINUE; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | DWORD |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 428 | DebuggerThread::HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info, |
| 429 | DWORD thread_id) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 430 | Log *log = |
| 431 | ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD); |
| 432 | LLDB_LOG(log, "Thread {0} exited with code {1} in process {2}", thread_id, |
| 433 | info.dwExitCode, m_process.GetProcessId()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 434 | m_debug_delegate->OnExitThread(thread_id, info.dwExitCode); |
| 435 | return DBG_CONTINUE; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | DWORD |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 439 | DebuggerThread::HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info, |
| 440 | DWORD thread_id) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 441 | Log *log = |
| 442 | ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD); |
| 443 | LLDB_LOG(log, "process {0} exited with code {1}", m_process.GetProcessId(), |
| 444 | info.dwExitCode); |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 445 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 446 | m_debug_delegate->OnExitProcess(info.dwExitCode); |
Adrian McCarthy | 2f8e4c3 | 2015-05-18 23:24:32 +0000 | [diff] [blame] | 447 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 448 | return DBG_CONTINUE; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | DWORD |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 452 | DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info, |
| 453 | DWORD thread_id) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 454 | Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 455 | if (info.hFile == nullptr) { |
| 456 | // Not sure what this is, so just ignore it. |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 457 | LLDB_LOG(log, "Warning: Inferior {0} has a NULL file handle, returning...", |
| 458 | m_process.GetProcessId()); |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 459 | return DBG_CONTINUE; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | std::vector<wchar_t> buffer(1); |
| 463 | DWORD required_size = |
| 464 | GetFinalPathNameByHandleW(info.hFile, &buffer[0], 0, VOLUME_NAME_DOS); |
| 465 | if (required_size > 0) { |
| 466 | buffer.resize(required_size + 1); |
| 467 | required_size = GetFinalPathNameByHandleW(info.hFile, &buffer[0], |
| 468 | required_size, VOLUME_NAME_DOS); |
| 469 | std::string path_str_utf8; |
| 470 | llvm::convertWideToUTF8(buffer.data(), path_str_utf8); |
| 471 | llvm::StringRef path_str = path_str_utf8; |
| 472 | const char *path = path_str.data(); |
| 473 | if (path_str.startswith("\\\\?\\")) |
| 474 | path += 4; |
| 475 | |
Aleksandr Urakov | 54bb316 | 2018-11-02 08:47:33 +0000 | [diff] [blame] | 476 | FileSpec file_spec(path); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 477 | ModuleSpec module_spec(file_spec); |
| 478 | lldb::addr_t load_addr = reinterpret_cast<lldb::addr_t>(info.lpBaseOfDll); |
| 479 | |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 480 | LLDB_LOG(log, "Inferior {0} - DLL '{1}' loaded at address {2:x}...", |
| 481 | m_process.GetProcessId(), path, info.lpBaseOfDll); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 482 | |
| 483 | m_debug_delegate->OnLoadDll(module_spec, load_addr); |
| 484 | } else { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 485 | LLDB_LOG( |
| 486 | log, |
| 487 | "Inferior {0} - Error {1} occurred calling GetFinalPathNameByHandle", |
| 488 | m_process.GetProcessId(), ::GetLastError()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 489 | } |
| 490 | // Windows does not automatically close info.hFile, so we need to do it. |
| 491 | ::CloseHandle(info.hFile); |
| 492 | return DBG_CONTINUE; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | DWORD |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 496 | DebuggerThread::HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info, |
| 497 | DWORD thread_id) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 498 | Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT); |
| 499 | LLDB_LOG(log, "process {0} unloading DLL at addr {1:x}.", |
| 500 | m_process.GetProcessId(), info.lpBaseOfDll); |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 501 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 502 | m_debug_delegate->OnUnloadDll( |
| 503 | reinterpret_cast<lldb::addr_t>(info.lpBaseOfDll)); |
| 504 | return DBG_CONTINUE; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | DWORD |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 508 | DebuggerThread::HandleODSEvent(const OUTPUT_DEBUG_STRING_INFO &info, |
| 509 | DWORD thread_id) { |
| 510 | return DBG_CONTINUE; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | DWORD |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 514 | DebuggerThread::HandleRipEvent(const RIP_INFO &info, DWORD thread_id) { |
Pavel Labath | a385d2c | 2017-02-22 10:38:02 +0000 | [diff] [blame] | 515 | Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT); |
| 516 | LLDB_LOG(log, "encountered error {0} (type={1}) in process {2} thread {3}", |
| 517 | info.dwError, info.dwType, m_process.GetProcessId(), thread_id); |
Zachary Turner | 610e529 | 2015-05-07 21:39:33 +0000 | [diff] [blame] | 518 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 519 | Status error(info.dwError, eErrorTypeWin32); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 520 | m_debug_delegate->OnDebuggerError(error, info.dwType); |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 521 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 522 | return DBG_CONTINUE; |
Zachary Turner | 02862bc | 2014-11-07 23:44:13 +0000 | [diff] [blame] | 523 | } |