LLDB  mainline
NativeProcessWindows.cpp
Go to the documentation of this file.
1 //===-- NativeProcessWindows.cpp ------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include <psapi.h>
11 
12 #include "NativeProcessWindows.h"
13 #include "NativeThreadWindows.h"
14 #include "lldb/Host/FileSystem.h"
16 #include "lldb/Host/HostProcess.h"
22 #include "lldb/Target/Process.h"
23 #include "lldb/Utility/State.h"
24 #include "llvm/Support/ConvertUTF.h"
25 #include "llvm/Support/Errc.h"
26 #include "llvm/Support/Error.h"
27 #include "llvm/Support/Format.h"
28 #include "llvm/Support/Threading.h"
29 #include "llvm/Support/raw_ostream.h"
30 
31 #include "DebuggerThread.h"
32 #include "ExceptionRecord.h"
33 #include "ProcessWindowsLog.h"
34 
35 #include <tlhelp32.h>
36 
37 #pragma warning(disable : 4005)
38 #include "winternl.h"
39 #include <ntstatus.h>
40 
41 using namespace lldb;
42 using namespace lldb_private;
43 using namespace llvm;
44 
45 namespace lldb_private {
46 
47 NativeProcessWindows::NativeProcessWindows(ProcessLaunchInfo &launch_info,
48  NativeDelegate &delegate,
49  llvm::Error &E)
51  launch_info.GetPTY().ReleasePrimaryFileDescriptor(),
52  delegate),
53  ProcessDebugger(), m_arch(launch_info.GetArchitecture()) {
54  ErrorAsOutParameter EOut(&E);
55  DebugDelegateSP delegate_sp(new NativeDebugDelegate(*this));
56  E = LaunchProcess(launch_info, delegate_sp).ToError();
57  if (E)
58  return;
59 
61 }
62 
64  NativeDelegate &delegate,
65  llvm::Error &E)
66  : NativeProcessProtocol(pid, terminal_fd, delegate), ProcessDebugger() {
67  ErrorAsOutParameter EOut(&E);
68  DebugDelegateSP delegate_sp(new NativeDebugDelegate(*this));
69  ProcessAttachInfo attach_info;
70  attach_info.SetProcessID(pid);
71  E = AttachProcess(pid, attach_info, delegate_sp).ToError();
72  if (E)
73  return;
74 
76 
78  if (!Host::GetProcessInfo(pid, info)) {
79  E = createStringError(inconvertibleErrorCode(),
80  "Cannot get process information");
81  return;
82  }
83  m_arch = info.GetArchitecture();
84 }
85 
88  Status error;
89  llvm::sys::ScopedLock lock(m_mutex);
90 
91  StateType state = GetState();
92  if (state == eStateStopped || state == eStateCrashed) {
93  LLDB_LOG(log, "process {0} is in state {1}. Resuming...",
94  GetDebuggedProcessId(), state);
95  LLDB_LOG(log, "resuming {0} threads.", m_threads.size());
96 
97  bool failed = false;
98  for (uint32_t i = 0; i < m_threads.size(); ++i) {
99  auto thread = static_cast<NativeThreadWindows *>(m_threads[i].get());
100  const ResumeAction *const action =
101  resume_actions.GetActionForThread(thread->GetID(), true);
102  if (action == nullptr)
103  continue;
104 
105  switch (action->state) {
106  case eStateRunning:
107  case eStateStepping: {
108  Status result = thread->DoResume(action->state);
109  if (result.Fail()) {
110  failed = true;
111  LLDB_LOG(log,
112  "Trying to resume thread at index {0}, but failed with "
113  "error {1}.",
114  i, result);
115  }
116  break;
117  }
118  case eStateSuspended:
119  case eStateStopped:
120  break;
121 
122  default:
123  return Status(
124  "NativeProcessWindows::%s (): unexpected state %s specified "
125  "for pid %" PRIu64 ", tid %" PRIu64,
126  __FUNCTION__, StateAsCString(action->state), GetID(),
127  thread->GetID());
128  }
129  }
130 
131  if (failed) {
132  error.SetErrorString("NativeProcessWindows::DoResume failed");
133  } else {
135  }
136 
137  // Resume the debug loop.
138  ExceptionRecordSP active_exception =
139  m_session_data->m_debugger->GetActiveException().lock();
140  if (active_exception) {
141  // Resume the process and continue processing debug events. Mask the
142  // exception so that from the process's view, there is no indication that
143  // anything happened.
144  m_session_data->m_debugger->ContinueAsyncException(
146  }
147  } else {
148  LLDB_LOG(log, "error: process {0} is in state {1}. Returning...",
150  }
151 
152  return error;
153 }
154 
157  return static_cast<NativeThreadWindows *>(
159 }
160 
162  bool caused_stop = false;
163  StateType state = GetState();
164  if (state != eStateStopped)
165  return HaltProcess(caused_stop);
166  return Status();
167 }
168 
170  Status error;
172  StateType state = GetState();
173  if (state != eStateExited && state != eStateDetached) {
174  error = DetachProcess();
175  if (error.Success())
177  else
178  LLDB_LOG(log, "Detaching process error: {0}", error);
179  } else {
180  error.SetErrorStringWithFormatv("error: process {0} in state = {1}, but "
181  "cannot detach it in this state.",
182  GetID(), state);
183  LLDB_LOG(log, "error: {0}", error);
184  }
185  return error;
186 }
187 
189  Status error;
190  error.SetErrorString("Windows does not support sending signals to processes");
191  return error;
192 }
193 
195 
197  StateType state = GetState();
198  return DestroyProcess(state);
199 }
200 
201 Status NativeProcessWindows::IgnoreSignals(llvm::ArrayRef<int> signals) {
202  return Status();
203 }
204 
206  MemoryRegionInfo &range_info) {
207  return ProcessDebugger::GetMemoryRegionInfo(load_addr, range_info);
208 }
209 
211  size_t size, size_t &bytes_read) {
212  return ProcessDebugger::ReadMemory(addr, buf, size, bytes_read);
213 }
214 
216  size_t size, size_t &bytes_written) {
217  return ProcessDebugger::WriteMemory(addr, buf, size, bytes_written);
218 }
219 
220 llvm::Expected<lldb::addr_t>
222  lldb::addr_t addr;
223  Status ST = ProcessDebugger::AllocateMemory(size, permissions, addr);
224  if (ST.Success())
225  return addr;
226  return ST.ToError();
227 }
228 
231 }
232 
234 
236  StateType state = GetState();
237  switch (state) {
238  case eStateCrashed:
239  case eStateDetached:
240  case eStateExited:
241  case eStateInvalid:
242  case eStateUnloaded:
243  return false;
244  default:
245  return true;
246  }
247 }
248 
250  lldb::StopReason reason,
251  std::string description) {
252  SetCurrentThreadID(thread.GetID());
253 
254  ThreadStopInfo stop_info;
255  stop_info.reason = reason;
256  // No signal support on Windows but required to provide a 'valid' signum.
257  stop_info.signo = SIGTRAP;
258 
259  if (reason == StopReason::eStopReasonException) {
260  stop_info.details.exception.type = 0;
261  stop_info.details.exception.data_count = 0;
262  }
263 
264  thread.SetStopReason(stop_info, description);
265 }
266 
268  lldb::StopReason reason,
269  std::string description) {
270  NativeThreadWindows *thread = GetThreadByID(thread_id);
271  if (!thread)
272  return;
273 
274  for (uint32_t i = 0; i < m_threads.size(); ++i) {
275  auto t = static_cast<NativeThreadWindows *>(m_threads[i].get());
276  Status error = t->DoStop();
277  if (error.Fail())
278  exit(1);
279  }
280  SetStopReasonForThread(*thread, reason, description);
281 }
282 
284 
285 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
287  // Not available on this target.
288  return llvm::errc::not_supported;
289 }
290 
291 llvm::Expected<llvm::ArrayRef<uint8_t>>
293  static const uint8_t g_aarch64_opcode[] = {0x00, 0x00, 0x3e, 0xd4}; // brk #0xf000
294  static const uint8_t g_thumb_opcode[] = {0xfe, 0xde}; // udf #0xfe
295 
296  switch (GetArchitecture().GetMachine()) {
297  case llvm::Triple::aarch64:
298  return llvm::makeArrayRef(g_aarch64_opcode);
299 
300  case llvm::Triple::arm:
301  case llvm::Triple::thumb:
302  return llvm::makeArrayRef(g_thumb_opcode);
303 
304  default:
306  }
307 }
308 
310  // Windows always reports an incremented PC after a breakpoint is hit,
311  // even on ARM.
312  return cantFail(GetSoftwareBreakpointTrapOpcode(0)).size();
313 }
314 
316  auto it = m_software_breakpoints.find(addr);
317  if (it == m_software_breakpoints.end())
318  return false;
319  return true;
320 }
321 
323  bool hardware) {
324  if (hardware)
325  return SetHardwareBreakpoint(addr, size);
326  return SetSoftwareBreakpoint(addr, size);
327 }
328 
330  bool hardware) {
331  if (hardware)
332  return RemoveHardwareBreakpoint(addr);
333  return RemoveSoftwareBreakpoint(addr);
334 }
335 
337  Status error;
338  if (!m_loaded_modules.empty())
339  return Status();
340 
341  // Retrieve loaded modules by a Target/Module free implemenation.
342  AutoHandle snapshot(CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetID()));
343  if (snapshot.IsValid()) {
344  MODULEENTRY32W me;
345  me.dwSize = sizeof(MODULEENTRY32W);
346  if (Module32FirstW(snapshot.get(), &me)) {
347  do {
348  std::string path;
349  if (!llvm::convertWideToUTF8(me.szExePath, path))
350  continue;
351 
352  FileSpec file_spec(path);
353  FileSystem::Instance().Resolve(file_spec);
354  m_loaded_modules[file_spec] = (addr_t)me.modBaseAddr;
355  } while (Module32Next(snapshot.get(), &me));
356  }
357 
358  if (!m_loaded_modules.empty())
359  return Status();
360  }
361 
362  error.SetError(::GetLastError(), lldb::ErrorType::eErrorTypeWin32);
363  return error;
364 }
365 
367  FileSpec &file_spec) {
369  if (error.Fail())
370  return error;
371 
372  FileSpec module_file_spec(module_path);
373  FileSystem::Instance().Resolve(module_file_spec);
374  for (auto &it : m_loaded_modules) {
375  if (it.first == module_file_spec) {
376  file_spec = it.first;
377  return Status();
378  }
379  }
380  return Status("Module (%s) not found in process %" PRIu64 "!",
381  module_file_spec.GetPath().c_str(), GetID());
382 }
383 
384 Status
385 NativeProcessWindows::GetFileLoadAddress(const llvm::StringRef &file_name,
386  lldb::addr_t &load_addr) {
388  if (error.Fail())
389  return error;
390 
391  load_addr = LLDB_INVALID_ADDRESS;
392  FileSpec file_spec(file_name);
393  FileSystem::Instance().Resolve(file_spec);
394  for (auto &it : m_loaded_modules) {
395  if (it.first == file_spec) {
396  load_addr = it.second;
397  return Status();
398  }
399  }
400  return Status("Can't get loaded address of file (%s) in process %" PRIu64 "!",
401  file_spec.GetPath().c_str(), GetID());
402 }
403 
406  LLDB_LOG(log, "Process {0} exited with code {1}", GetID(), exit_code);
407 
409 
410  // No signal involved. It is just an exit event.
411  WaitStatus wait_status(WaitStatus::Exit, exit_code);
412  SetExitStatus(wait_status, true);
413 
414  // Notify the native delegate.
415  SetState(eStateExited, true);
416 }
417 
420  LLDB_LOG(log, "Debugger connected to process {0}. Image base = {1:x}",
421  GetDebuggedProcessId(), image_base);
422 
423  // This is the earliest chance we can resolve the process ID and
424  // architecture if we don't know them yet.
427 
428  if (GetArchitecture().GetMachine() == llvm::Triple::UnknownArch) {
429  ProcessInstanceInfo process_info;
430  if (!Host::GetProcessInfo(GetDebuggedProcessId(), process_info)) {
431  LLDB_LOG(log, "Cannot get process information during debugger connecting "
432  "to process");
433  return;
434  }
435  SetArchitecture(process_info.GetArchitecture());
436  }
437 
438  // The very first one shall always be the main thread.
439  assert(m_threads.empty());
440  m_threads.push_back(std::make_unique<NativeThreadWindows>(
441  *this, m_session_data->m_debugger->GetMainThread()));
442 }
443 
446  const ExceptionRecord &record) {
448  llvm::sys::ScopedLock lock(m_mutex);
449 
450  // Let the debugger establish the internal status.
451  ProcessDebugger::OnDebugException(first_chance, record);
452 
453  static bool initial_stop = false;
454  if (!first_chance) {
455  SetState(eStateStopped, false);
456  }
457 
459  switch (record.GetExceptionCode()) {
460  case DWORD(STATUS_SINGLE_STEP):
461  case STATUS_WX86_SINGLE_STEP: {
463  if (NativeThreadWindows *thread = GetThreadByID(record.GetThreadID())) {
464  NativeRegisterContextWindows &reg_ctx = thread->GetRegisterContext();
465  Status error =
466  reg_ctx.GetWatchpointHitIndex(wp_id, record.GetExceptionAddress());
467  if (error.Fail())
468  LLDB_LOG(log,
469  "received error while checking for watchpoint hits, pid = "
470  "{0}, error = {1}",
471  thread->GetID(), error);
472  if (wp_id != LLDB_INVALID_INDEX32) {
473  addr_t wp_addr = reg_ctx.GetWatchpointAddress(wp_id);
474  addr_t wp_hit_addr = reg_ctx.GetWatchpointHitAddress(wp_id);
475  std::string desc =
476  formatv("{0} {1} {2}", wp_addr, wp_id, wp_hit_addr).str();
478  desc);
479  }
480  }
481  if (wp_id == LLDB_INVALID_INDEX32)
483 
484  SetState(eStateStopped, true);
485 
486  // Continue the debugger.
488  }
489  case DWORD(STATUS_BREAKPOINT):
492  LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
493  record.GetExceptionAddress());
494 
496 
497  if (NativeThreadWindows *stop_thread =
498  GetThreadByID(record.GetThreadID())) {
499  auto &register_context = stop_thread->GetRegisterContext();
500  uint32_t breakpoint_size = GetSoftwareBreakpointPCOffset();
501  // The current PC is AFTER the BP opcode, on all architectures.
502  uint64_t pc = register_context.GetPC() - breakpoint_size;
503  register_context.SetPC(pc);
504  }
505 
506  SetState(eStateStopped, true);
508  }
509 
510  if (!initial_stop) {
511  initial_stop = true;
512  LLDB_LOG(log,
513  "Hit loader breakpoint at address {0:x}, setting initial stop "
514  "event.",
515  record.GetExceptionAddress());
516 
517  // We are required to report the reason for the first stop after
518  // launching or being attached.
519  if (NativeThreadWindows *thread = GetThreadByID(record.GetThreadID()))
521 
522  // Do not notify the native delegate (e.g. llgs) since at this moment
523  // the program hasn't returned from Factory::Launch() and the delegate
524  // might not have an valid native process to operate on.
525  SetState(eStateStopped, false);
526 
527  // Hit the initial stop. Continue the application.
529  }
530 
531  [[fallthrough]];
532  default:
533  LLDB_LOG(log,
534  "Debugger thread reported exception {0:x} at address {1:x} "
535  "(first_chance={2})",
536  record.GetExceptionCode(), record.GetExceptionAddress(),
537  first_chance);
538 
539  {
540  std::string desc;
541  llvm::raw_string_ostream desc_stream(desc);
542  desc_stream << "Exception "
543  << llvm::format_hex(record.GetExceptionCode(), 8)
544  << " encountered at address "
545  << llvm::format_hex(record.GetExceptionAddress(), 8);
547  desc_stream.str().c_str());
548 
549  SetState(eStateStopped, true);
550  }
551 
552  // For non-breakpoints, give the application a chance to handle the
553  // exception first.
554  if (first_chance)
556  else
558  }
559 
560  return result;
561 }
562 
564  llvm::sys::ScopedLock lock(m_mutex);
565 
566  auto thread = std::make_unique<NativeThreadWindows>(*this, new_thread);
567  thread->GetRegisterContext().ClearAllHardwareWatchpoints();
568  for (const auto &pair : GetWatchpointMap()) {
569  const NativeWatchpoint &wp = pair.second;
570  thread->SetWatchpoint(wp.m_addr, wp.m_size, wp.m_watch_flags,
571  wp.m_hardware);
572  }
573 
574  m_threads.push_back(std::move(thread));
575 }
576 
578  uint32_t exit_code) {
579  llvm::sys::ScopedLock lock(m_mutex);
580  NativeThreadWindows *thread = GetThreadByID(thread_id);
581  if (!thread)
582  return;
583 
584  for (auto t = m_threads.begin(); t != m_threads.end();) {
585  if ((*t)->GetID() == thread_id) {
586  t = m_threads.erase(t);
587  } else {
588  ++t;
589  }
590  }
591 }
592 
594  lldb::addr_t module_addr) {
595  // Simply invalidate the cached loaded modules.
596  if (!m_loaded_modules.empty())
597  m_loaded_modules.clear();
598 }
599 
601  if (!m_loaded_modules.empty())
602  m_loaded_modules.clear();
603 }
604 
605 llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
607  ProcessLaunchInfo &launch_info,
608  NativeProcessProtocol::NativeDelegate &native_delegate,
609  MainLoop &mainloop) const {
610  Error E = Error::success();
611  auto process_up = std::unique_ptr<NativeProcessWindows>(
612  new NativeProcessWindows(launch_info, native_delegate, E));
613  if (E)
614  return std::move(E);
615  return std::move(process_up);
616 }
617 
618 llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
621  MainLoop &mainloop) const {
622  Error E = Error::success();
623  // Set pty primary fd invalid since it is not available.
624  auto process_up = std::unique_ptr<NativeProcessWindows>(
625  new NativeProcessWindows(pid, -1, native_delegate, E));
626  if (E)
627  return std::move(E);
628  return std::move(process_up);
629 }
630 } // namespace lldb_private
lldb_private::NativeProcessProtocol::SetSoftwareBreakpoint
Status SetSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint)
Definition: NativeProcessProtocol.cpp:339
lldb_private::NativeWatchpoint::m_watch_flags
uint32_t m_watch_flags
Definition: NativeWatchpointList.h:21
lldb_private::NativeProcessWindows::OnLoadDll
void OnLoadDll(const ModuleSpec &module_spec, lldb::addr_t module_addr) override
Definition: NativeProcessWindows.cpp:593
lldb_private::ProcessInstanceInfo
Definition: ProcessInfo.h:106
lldb_private::ProcessDebugger::GetDebuggedProcessId
lldb::pid_t GetDebuggedProcessId() const
Definition: ProcessDebugger.cpp:68
lldb_private::NativeWatchpoint::m_addr
lldb::addr_t m_addr
Definition: NativeWatchpointList.h:19
lldb_private::NativeThreadWindows::SetStopReason
void SetStopReason(ThreadStopInfo stop_info, std::string description)
Definition: NativeThreadWindows.cpp:113
llvm
Definition: Debugger.h:50
lldb_private::NativeProcessWindows::NativeProcessWindows
NativeProcessWindows(ProcessLaunchInfo &launch_info, NativeDelegate &delegate, llvm::Error &E)
Definition: NativeProcessWindows.cpp:47
lldb_private::NativeProcessProtocol::NativeDelegate
Definition: NativeProcessProtocol.h:236
lldb_private::ExceptionRecord::GetThreadID
lldb::tid_t GetThreadID() const
Definition: ExceptionRecord.h:60
lldb_private::NativeProcessWindows::Halt
Status Halt() override
Definition: NativeProcessWindows.cpp:161
ExceptionResult::BreakInDebugger
@ BreakInDebugger
FileSystem.h
lldb_private::NativeRegisterContext::GetWatchpointHitIndex
virtual Status GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr)
Definition: NativeRegisterContext.cpp:293
lldb_private::NativeThreadWindows
Definition: NativeThreadWindows.h:22
LLDB_INVALID_PROCESS_ID
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:81
lldb_private::NativeProcessWindows::m_loaded_modules
std::map< lldb_private::FileSpec, lldb::addr_t > m_loaded_modules
Definition: NativeProcessWindows.h:135
lldb_private::NativeProcessProtocol::SetHardwareBreakpoint
virtual Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size)
Definition: NativeProcessProtocol.cpp:235
lldb_private::WindowsLog::Process
@ Process
lldb_private::HostThread
Definition: HostThread.h:29
lldb_private::NativeProcessWindows::Kill
Status Kill() override
Definition: NativeProcessWindows.cpp:196
lldb_private::AutoHandle
Definition: AutoHandle.h:16
lldb_private::AutoHandle::get
HANDLE get() const
Definition: AutoHandle.h:28
lldb_private::NativeProcessWindows::IsAlive
bool IsAlive() const override
Definition: NativeProcessWindows.cpp:235
ExceptionResult::MaskException
@ MaskException
lldb_private::NativeProcessProtocol::SetState
void SetState(lldb::StateType state, bool notify_delegates=true)
Definition: NativeProcessProtocol.cpp:729
ProcessLaunchInfo.h
lldb_private::NativeProcessWindows::OnDebuggerConnected
void OnDebuggerConnected(lldb::addr_t image_base) override
Definition: NativeProcessWindows.cpp:418
HostProcess.h
lldb_private::NativeDebugDelegate
Definition: NativeProcessWindows.h:141
lldb_private::NativeProcessProtocol::GetThreadByID
NativeThreadProtocol * GetThreadByID(lldb::tid_t tid)
Definition: NativeProcessProtocol.cpp:115
lldb_private::StateAsCString
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
Definition: State.cpp:14
lldb_private::NativeWatchpoint::m_size
size_t m_size
Definition: NativeWatchpointList.h:20
STATUS_WX86_BREAKPOINT
#define STATUS_WX86_BREAKPOINT
Definition: DebuggerThread.cpp:36
lldb_private::NativeProcessProtocol::m_software_breakpoints
std::unordered_map< lldb::addr_t, SoftwareBreakpoint > m_software_breakpoints
Definition: NativeProcessProtocol.h:415
lldb_private::NativeProcessProtocol::SetExitStatus
virtual bool SetExitStatus(WaitStatus status, bool bNotifyStateChange)
Definition: NativeProcessProtocol.cpp:76
lldb::StopReason
StopReason
Thread stop reasons.
Definition: lldb-enumerations.h:240
lldb_private::ResumeAction
Definition: Debug.h:19
lldb_private::ThreadStopInfo::exception
struct lldb_private::ThreadStopInfo::@12::@13 exception
lldb::eStopReasonException
@ eStopReasonException
Definition: lldb-enumerations.h:247
lldb_private::MemoryRegionInfo
Definition: MemoryRegionInfo.h:21
lldb_private::NativeProcessWindows::IgnoreSignals
Status IgnoreSignals(llvm::ArrayRef< int > signals) override
Definition: NativeProcessWindows.cpp:201
lldb_private::ProcessDebugger::m_mutex
llvm::sys::Mutex m_mutex
Definition: ProcessDebugger.h:97
lldb_private::ProcessInfo::SetProcessID
void SetProcessID(lldb::pid_t pid)
Definition: ProcessInfo.h:68
lldb_private::ProcessDebugger::ReadMemory
Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read)
Definition: ProcessDebugger.cpp:262
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
pc
@ pc
Definition: CompactUnwindInfo.cpp:1251
lldb_private::NativeProcessWindows::Factory::Launch
llvm::Expected< std::unique_ptr< NativeProcessProtocol > > Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate, MainLoop &mainloop) const override
Launch a process for debugging.
Definition: NativeProcessWindows.cpp:606
lldb::eStopReasonTrace
@ eStopReasonTrace
Definition: lldb-enumerations.h:243
lldb::eErrorTypeWin32
@ eErrorTypeWin32
Standard Win32 error codes.
Definition: lldb-enumerations.h:313
AutoHandle.h
lldb_private::ProcessDebugger::DestroyProcess
Status DestroyProcess(lldb::StateType process_state)
Definition: ProcessDebugger.cpp:211
lldb_private::NativeProcessWindows::OnExitProcess
void OnExitProcess(uint32_t exit_code) override
Definition: NativeProcessWindows.cpp:404
lldb::eStateExited
@ eStateExited
Process has exited and can't be examined.
Definition: lldb-enumerations.h:91
lldb_private::ProcessDebugger::DetachProcess
Status DetachProcess()
Definition: ProcessDebugger.cpp:74
Process.h
lldb_private::WaitStatus
Definition: Host.h:35
ProcessWindowsLog.h
lldb_private::NativeProcessWindows::Interrupt
Status Interrupt() override
Tells a process to interrupt all operations as if by a Ctrl-C.
Definition: NativeProcessWindows.cpp:194
lldb_private::ResumeActionList::GetActionForThread
const ResumeAction * GetActionForThread(lldb::tid_t tid, bool default_ok) const
Definition: Debug.h:74
lldb::eStateStopped
@ eStateStopped
Process or thread is stopped and can be examined.
Definition: lldb-enumerations.h:85
lldb_private::NativeProcessProtocol::SetCurrentThreadID
void SetCurrentThreadID(lldb::tid_t tid)
Definition: NativeProcessProtocol.h:216
lldb_private::NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode
virtual llvm::Expected< llvm::ArrayRef< uint8_t > > GetSoftwareBreakpointTrapOpcode(size_t size_hint)
Definition: NativeProcessProtocol.cpp:500
lldb_private::ProcessDebugger::AttachProcess
Status AttachProcess(lldb::pid_t pid, const ProcessAttachInfo &attach_info, DebugDelegateSP delegate)
Definition: ProcessDebugger.cpp:171
lldb_private::FileSpec
Definition: FileSpec.h:55
lldb_private::ProcessDebugger
Definition: ProcessDebugger.h:48
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::Status::Success
bool Success() const
Test for success condition.
Definition: Status.cpp:287
lldb::eStateCrashed
@ eStateCrashed
Process or thread has crashed and can be examined.
Definition: lldb-enumerations.h:89
lldb_private::NativeProcessWindows::StopThread
void StopThread(lldb::tid_t thread_id, lldb::StopReason reason, std::string description="")
Definition: NativeProcessWindows.cpp:267
lldb_private::NativeProcessWindows::DeallocateMemory
llvm::Error DeallocateMemory(lldb::addr_t addr) override
Definition: NativeProcessWindows.cpp:229
lldb_private::NativeProcessWindows::GetLoadedModuleFileSpec
Status GetLoadedModuleFileSpec(const char *module_path, FileSpec &file_spec) override
Definition: NativeProcessWindows.cpp:366
lldb_private::NativeProcessWindows::ReadMemory
Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) override
Definition: NativeProcessWindows.cpp:210
lldb_private::NativeProcessWindows::GetMemoryRegionInfo
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override
Definition: NativeProcessWindows.cpp:205
lldb_private::NativeProcessProtocol::RemoveSoftwareBreakpoint
Status RemoveSoftwareBreakpoint(lldb::addr_t addr)
Definition: NativeProcessProtocol.cpp:357
lldb_private::NativeRegisterContext::GetWatchpointHitAddress
virtual lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index)
Definition: NativeRegisterContext.cpp:309
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
lldb_private::NativeProcessWindows::OnUnloadDll
void OnUnloadDll(lldb::addr_t module_addr) override
Definition: NativeProcessWindows.cpp:600
lldb_private::ResumeAction::state
lldb::StateType state
Definition: Debug.h:23
MemoryRegionInfo.h
lldb_private::NativeProcessWindows::GetFileLoadAddress
Status GetFileLoadAddress(const llvm::StringRef &file_name, lldb::addr_t &load_addr) override
Definition: NativeProcessWindows.cpp:385
lldb::eStopReasonWatchpoint
@ eStopReasonWatchpoint
Definition: lldb-enumerations.h:245
HostNativeProcessBase.h
lldb_private::NativeProcessWindows::GetSoftwareBreakpointTrapOpcode
llvm::Expected< llvm::ArrayRef< uint8_t > > GetSoftwareBreakpointTrapOpcode(size_t size_hint) override
Definition: NativeProcessWindows.cpp:292
lldb_private::Status::Fail
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
SIGTRAP
#define SIGTRAP
Definition: windows/PosixApi.h:30
ExceptionResult
ExceptionResult
Definition: ForwardDecl.h:16
lldb_private::ThreadStopInfo::reason
lldb::StopReason reason
Definition: Debug.h:132
lldb_private::NativeProcessProtocol::SetID
void SetID(lldb::pid_t pid)
Definition: NativeProcessProtocol.h:447
lldb_private::NativeProcessWindows::GetAuxvData
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > GetAuxvData() const override
Definition: NativeProcessWindows.cpp:286
lldb_private::NativeProcessProtocol::GetID
lldb::pid_t GetID() const
Definition: NativeProcessProtocol.h:183
lldb_private::NativeRegisterContextWindows
Definition: NativeRegisterContextWindows.h:20
lldb_private::ProcessDebugger::LaunchProcess
Status LaunchProcess(ProcessLaunchInfo &launch_info, DebugDelegateSP delegate)
Definition: ProcessDebugger.cpp:105
lldb_private::ExceptionRecord::GetExceptionCode
DWORD GetExceptionCode() const
Definition: ExceptionRecord.h:56
lldb_private::NativeProcessWindows::FindSoftwareBreakpoint
bool FindSoftwareBreakpoint(lldb::addr_t addr)
Definition: NativeProcessWindows.cpp:315
lldb_private::NativeWatchpoint::m_hardware
bool m_hardware
Definition: NativeWatchpointList.h:22
lldb_private::NativeProcessWindows::OnExitThread
void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override
Definition: NativeProcessWindows.cpp:577
lldb::eStateDetached
@ eStateDetached
Process has been detached and can't be examined.
Definition: lldb-enumerations.h:90
ExceptionResult::SendToApplication
@ SendToApplication
lldb_private::DebugDelegateSP
std::shared_ptr< IDebugDelegate > DebugDelegateSP
Definition: ForwardDecl.h:33
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::FileSystem::Resolve
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
Definition: common/FileSystem.cpp:235
lldb_private::NativeProcessWindows::Factory::Attach
llvm::Expected< std::unique_ptr< NativeProcessProtocol > > Attach(lldb::pid_t pid, NativeDelegate &native_delegate, MainLoop &mainloop) const override
Attach to an existing process.
Definition: NativeProcessWindows.cpp:619
lldb_private::WindowsLog::Exception
@ Exception
ExceptionRecord.h
lldb::eStateUnloaded
@ eStateUnloaded
Process is object is valid, but not currently loaded.
Definition: lldb-enumerations.h:76
lldb_private::ThreadStopInfo::details
union lldb_private::ThreadStopInfo::@12 details
lldb_private::NativeProcessWindows::SetBreakpoint
Status SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) override
Definition: NativeProcessWindows.cpp:322
lldb_private::NativeProcessProtocol::m_threads
std::vector< std::unique_ptr< NativeThreadProtocol > > m_threads
Definition: NativeProcessProtocol.h:418
lldb_private::NativeProcessWindows::OnDebugException
ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record) override
Definition: NativeProcessWindows.cpp:445
lldb_private::ThreadStopInfo
Definition: Debug.h:131
lldb_private::ProcessAttachInfo
Definition: Process.h:113
lldb_private::ExceptionRecord::GetExceptionAddress
lldb::addr_t GetExceptionAddress() const
Definition: ExceptionRecord.h:58
lldb_private::MainLoopPosix
Definition: MainLoopPosix.h:27
lldb_private::NativeProcessWindows::GetArchitecture
const ArchSpec & GetArchitecture() const override
Definition: NativeProcessWindows.h:79
DebuggerThread.h
lldb_private::ProcessDebugger::DeallocateMemory
Status DeallocateMemory(lldb::addr_t addr)
Definition: ProcessDebugger.cpp:351
lldb::eStateStepping
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
Definition: lldb-enumerations.h:87
lldb_private::AutoHandle::IsValid
bool IsValid() const
Definition: AutoHandle.h:26
lldb_private::NativeProcessWindows::SetArchitecture
void SetArchitecture(const ArchSpec &arch_spec)
Definition: NativeProcessWindows.h:81
lldb::eStateSuspended
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
Definition: lldb-enumerations.h:92
lldb_private::NativeProcessWindows::SetStopReasonForThread
void SetStopReasonForThread(NativeThreadWindows &thread, lldb::StopReason reason, std::string description="")
Definition: NativeProcessWindows.cpp:249
lldb_private::NativeProcessWindows::CacheLoadedModules
Status CacheLoadedModules()
Definition: NativeProcessWindows.cpp:336
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
lldb_private::NativeProcessWindows::Signal
Status Signal(int signo) override
Sends a process a UNIX signal signal.
Definition: NativeProcessWindows.cpp:188
lldb_private::Status
Definition: Status.h:44
uint32_t
NativeProcessWindows.h
ProcessLauncherWindows.h
lldb_private::NativeProcessWindows::OnCreateThread
void OnCreateThread(const HostThread &thread) override
Definition: NativeProcessWindows.cpp:563
lldb_private::NativeProcessProtocol::RemoveHardwareBreakpoint
virtual Status RemoveHardwareBreakpoint(lldb::addr_t addr)
Definition: NativeProcessProtocol.cpp:292
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb_private::NativeProcessProtocol
Definition: NativeProcessProtocol.h:48
lldb_private::NativeThreadProtocol::GetID
lldb::tid_t GetID() const
Definition: NativeThreadProtocol.h:39
lldb_private::NativeProcessWindows::UpdateThreads
size_t UpdateThreads() override
Definition: NativeProcessWindows.cpp:283
lldb_private::Host::GetProcessInfo
static bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info)
Definition: freebsd/Host.cpp:230
lldb_private::NativeProcessProtocol::GetState
lldb::StateType GetState() const
Definition: NativeProcessProtocol.cpp:724
lldb_private::NativeWatchpoint
Definition: NativeWatchpointList.h:18
lldb_private::ThreadStopInfo::signo
uint32_t signo
Definition: Debug.h:133
windows.h
lldb::eStopReasonBreakpoint
@ eStopReasonBreakpoint
Definition: lldb-enumerations.h:244
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::NativeProcessWindows::m_arch
ArchSpec m_arch
Definition: NativeProcessWindows.h:126
lldb_private::NativeProcessWindows::Detach
Status Detach() override
Definition: NativeProcessWindows.cpp:169
LLDB_LOG
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:337
lldb_private::FileSystem::Instance
static FileSystem & Instance()
Definition: common/FileSystem.cpp:46
lldb_private::NativeProcessWindows::AllocateMemory
llvm::Expected< lldb::addr_t > AllocateMemory(size_t size, uint32_t permissions) override
Definition: NativeProcessWindows.cpp:221
lldb_private::ProcessDebugger::OnDebugException
virtual ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record)
Definition: ProcessDebugger.cpp:481
lldb_private::ProcessInfo::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ProcessInfo.h:60
lldb_private::ResumeActionList
Definition: Debug.h:33
lldb_private::ProcessDebugger::HaltProcess
Status HaltProcess(bool &caused_stop)
Definition: ProcessDebugger.cpp:247
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::NativeProcessWindows::GetSoftwareBreakpointPCOffset
size_t GetSoftwareBreakpointPCOffset() override
Return the offset of the PC relative to the software breakpoint that was hit.
Definition: NativeProcessWindows.cpp:309
lldb_private::ProcessDebugger::AllocateMemory
Status AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr)
Definition: ProcessDebugger.cpp:322
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:34
lldb_private::NativeProcessProtocol::GetWatchpointMap
virtual const NativeWatchpointList::WatchpointMap & GetWatchpointMap() const
Definition: NativeProcessProtocol.cpp:126
lldb::eStateInvalid
@ eStateInvalid
Definition: lldb-enumerations.h:75
lldb_private::NativeProcessWindows::RemoveBreakpoint
Status RemoveBreakpoint(lldb::addr_t addr, bool hardware=false) override
Definition: NativeProcessWindows.cpp:329
lldb_private::Status::ToError
llvm::Error ToError() const
Definition: Status.cpp:89
lldb_private::NativeProcessWindows::Resume
Status Resume(const ResumeActionList &resume_actions) override
Definition: NativeProcessWindows.cpp:86
State.h
LLDB_INVALID_INDEX32
#define LLDB_INVALID_INDEX32
Definition: lldb-defines.h:75
lldb::StateType
StateType
Process and Thread States.
Definition: lldb-enumerations.h:74
lldb_private::Log
Definition: Log.h:115
lldb_private::NativeProcessWindows::GetSharedLibraryInfoAddress
lldb::addr_t GetSharedLibraryInfoAddress() override
Definition: NativeProcessWindows.cpp:233
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
lldb_private::FileSpec::GetPath
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:364
lldb_private::ExceptionRecordSP
std::shared_ptr< ExceptionRecord > ExceptionRecordSP
Definition: ForwardDecl.h:37
lldb
Definition: SBAddress.h:15
lldb_private::ProcessDebugger::WriteMemory
Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written)
Definition: ProcessDebugger.cpp:292
lldb::eStateRunning
@ eStateRunning
Process or thread is running and can't be examined.
Definition: lldb-enumerations.h:86
lldb_private::NativeProcessWindows::WriteMemory
Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) override
Definition: NativeProcessWindows.cpp:215
lldb_private::WaitStatus::Exit
@ Exit
Definition: Host.h:37
lldb_private::ProcessDebugger::m_session_data
std::unique_ptr< ProcessWindowsData > m_session_data
Definition: ProcessDebugger.h:98
lldb_private::ProcessDebugger::OnExitProcess
virtual void OnExitProcess(uint32_t exit_code)
Definition: ProcessDebugger.cpp:468
HostThreadWindows.h
lldb_private::ProcessDebugger::GetMemoryRegionInfo
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
Definition: ProcessDebugger.cpp:376
lldb_private::ExceptionRecord
Definition: ExceptionRecord.h:25
lldb_private::NativeRegisterContext::GetWatchpointAddress
virtual lldb::addr_t GetWatchpointAddress(uint32_t wp_index)
Definition: NativeRegisterContext.cpp:305
lldb_private::NativeProcessWindows::GetThreadByID
NativeThreadWindows * GetThreadByID(lldb::tid_t thread_id)
Definition: NativeProcessWindows.cpp:156
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86
NativeThreadWindows.h