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