LLDB  mainline
ProcessWindows.cpp
Go to the documentation of this file.
1 //===-- ProcessWindows.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 
9 #include "ProcessWindows.h"
10 
11 // Windows includes
13 #include <psapi.h>
14 
16 #include "lldb/Core/Module.h"
17 #include "lldb/Core/ModuleSpec.h"
19 #include "lldb/Core/Section.h"
20 #include "lldb/Host/FileSystem.h"
22 #include "lldb/Host/HostProcess.h"
25 #include "lldb/Symbol/ObjectFile.h"
28 #include "lldb/Target/StopInfo.h"
29 #include "lldb/Target/Target.h"
30 #include "lldb/Utility/State.h"
31 
32 #include "llvm/Support/ConvertUTF.h"
33 #include "llvm/Support/Format.h"
34 #include "llvm/Support/Threading.h"
35 #include "llvm/Support/raw_ostream.h"
36 
37 #include "DebuggerThread.h"
38 #include "ExceptionRecord.h"
39 #include "ForwardDecl.h"
40 #include "LocalDebugDelegate.h"
41 #include "ProcessWindowsLog.h"
42 #include "TargetThreadWindows.h"
43 
44 using namespace lldb;
45 using namespace lldb_private;
46 
47 LLDB_PLUGIN_DEFINE_ADV(ProcessWindows, ProcessWindowsCommon)
48 
49 namespace {
50 std::string GetProcessExecutableName(HANDLE process_handle) {
51  std::vector<wchar_t> file_name;
52  DWORD file_name_size = MAX_PATH; // first guess, not an absolute limit
53  DWORD copied = 0;
54  do {
55  file_name_size *= 2;
56  file_name.resize(file_name_size);
57  copied = ::GetModuleFileNameExW(process_handle, NULL, file_name.data(),
58  file_name_size);
59  } while (copied >= file_name_size);
60  file_name.resize(copied);
61  std::string result;
62  llvm::convertWideToUTF8(file_name.data(), result);
63  return result;
64 }
65 
66 std::string GetProcessExecutableName(DWORD pid) {
67  std::string file_name;
68  HANDLE process_handle =
69  ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
70  if (process_handle != NULL) {
71  file_name = GetProcessExecutableName(process_handle);
72  ::CloseHandle(process_handle);
73  }
74  return file_name;
75 }
76 } // anonymous namespace
77 
78 namespace lldb_private {
79 
80 ProcessSP ProcessWindows::CreateInstance(lldb::TargetSP target_sp,
81  lldb::ListenerSP listener_sp,
82  const FileSpec *,
83  bool can_connect) {
84  return ProcessSP(new ProcessWindows(target_sp, listener_sp));
85 }
86 
87 static bool ShouldUseLLDBServer() {
88  llvm::StringRef use_lldb_server = ::getenv("LLDB_USE_LLDB_SERVER");
89  return use_lldb_server.equals_insensitive("on") ||
90  use_lldb_server.equals_insensitive("yes") ||
91  use_lldb_server.equals_insensitive("1") ||
92  use_lldb_server.equals_insensitive("true");
93 }
94 
95 void ProcessWindows::Initialize() {
96  if (!ShouldUseLLDBServer()) {
97  static llvm::once_flag g_once_flag;
98 
99  llvm::call_once(g_once_flag, []() {
100  PluginManager::RegisterPlugin(GetPluginNameStatic(),
101  GetPluginDescriptionStatic(),
102  CreateInstance);
103  });
104  }
105 }
106 
107 void ProcessWindows::Terminate() {}
108 
109 lldb_private::ConstString ProcessWindows::GetPluginNameStatic() {
110  static ConstString g_name("windows");
111  return g_name;
112 }
113 
114 const char *ProcessWindows::GetPluginDescriptionStatic() {
115  return "Process plugin for Windows";
116 }
117 
118 // Constructors and destructors.
119 
120 ProcessWindows::ProcessWindows(lldb::TargetSP target_sp,
121  lldb::ListenerSP listener_sp)
122  : lldb_private::Process(target_sp, listener_sp),
123  m_watchpoint_ids(
124  RegisterContextWindows::GetNumHardwareBreakpointSlots(),
126 
128 
129 size_t ProcessWindows::GetSTDOUT(char *buf, size_t buf_size, Status &error) {
130  error.SetErrorString("GetSTDOUT unsupported on Windows");
131  return 0;
132 }
133 
134 size_t ProcessWindows::GetSTDERR(char *buf, size_t buf_size, Status &error) {
135  error.SetErrorString("GetSTDERR unsupported on Windows");
136  return 0;
137 }
138 
139 size_t ProcessWindows::PutSTDIN(const char *buf, size_t buf_size,
140  Status &error) {
141  error.SetErrorString("PutSTDIN unsupported on Windows");
142  return 0;
143 }
144 
146  if (bp_site->HardwareRequired())
147  return Status("Hardware breakpoints are not supported.");
148 
150  LLDB_LOG(log, "bp_site = {0:x}, id={1}, addr={2:x}", bp_site,
151  bp_site->GetID(), bp_site->GetLoadAddress());
152 
154  if (!error.Success())
155  LLDB_LOG(log, "error: {0}", error);
156  return error;
157 }
158 
161  LLDB_LOG(log, "bp_site = {0:x}, id={1}, addr={2:x}", bp_site,
162  bp_site->GetID(), bp_site->GetLoadAddress());
163 
165 
166  if (!error.Success())
167  LLDB_LOG(log, "error: {0}", error);
168  return error;
169 }
170 
171 Status ProcessWindows::DoDetach(bool keep_stopped) {
172  Status error;
174  StateType private_state = GetPrivateState();
175  if (private_state != eStateExited && private_state != eStateDetached) {
176  error = DetachProcess();
177  if (error.Success())
179  else
180  LLDB_LOG(log, "Detaching process error: {0}", error);
181  } else {
182  error.SetErrorStringWithFormatv("error: process {0} in state = {1}, but "
183  "cannot detach it in this state.",
184  GetID(), private_state);
185  LLDB_LOG(log, "error: {0}", error);
186  }
187  return error;
188 }
189 
191  ProcessLaunchInfo &launch_info) {
192  Status error;
193  DebugDelegateSP delegate(new LocalDebugDelegate(shared_from_this()));
194  error = LaunchProcess(launch_info, delegate);
195  if (error.Success())
196  SetID(launch_info.GetProcessID());
197  return error;
198 }
199 
200 Status
202  const ProcessAttachInfo &attach_info) {
203  DebugDelegateSP delegate(new LocalDebugDelegate(shared_from_this()));
204  Status error = AttachProcess(pid, attach_info, delegate);
205  if (error.Success())
207  return error;
208 }
209 
212  llvm::sys::ScopedLock lock(m_mutex);
213  Status error;
214 
215  StateType private_state = GetPrivateState();
216  if (private_state == eStateStopped || private_state == eStateCrashed) {
217  LLDB_LOG(log, "process {0} is in state {1}. Resuming...",
218  m_session_data->m_debugger->GetProcess().GetProcessId(),
219  GetPrivateState());
220 
221  LLDB_LOG(log, "resuming {0} threads.", m_thread_list.GetSize());
222 
223  bool failed = false;
224  for (uint32_t i = 0; i < m_thread_list.GetSize(); ++i) {
225  auto thread = std::static_pointer_cast<TargetThreadWindows>(
227  Status result = thread->DoResume();
228  if (result.Fail()) {
229  failed = true;
230  LLDB_LOG(
231  log,
232  "Trying to resume thread at index {0}, but failed with error {1}.",
233  i, result);
234  }
235  }
236 
237  if (failed) {
238  error.SetErrorString("ProcessWindows::DoResume failed");
239  } else {
241  }
242 
243  ExceptionRecordSP active_exception =
244  m_session_data->m_debugger->GetActiveException().lock();
245  if (active_exception) {
246  // Resume the process and continue processing debug events. Mask the
247  // exception so that from the process's view, there is no indication that
248  // anything happened.
249  m_session_data->m_debugger->ContinueAsyncException(
251  }
252  } else {
253  LLDB_LOG(log, "error: process {0} is in state {1}. Returning...",
254  m_session_data->m_debugger->GetProcess().GetProcessId(),
255  GetPrivateState());
256  }
257  return error;
258 }
259 
261  StateType private_state = GetPrivateState();
262  return DestroyProcess(private_state);
263 }
264 
265 Status ProcessWindows::DoHalt(bool &caused_stop) {
266  StateType state = GetPrivateState();
267  if (state != eStateStopped)
268  return HaltProcess(caused_stop);
269  caused_stop = false;
270  return Status();
271 }
272 
274  ArchSpec arch_spec;
275  DidAttach(arch_spec);
276 }
277 
279  llvm::sys::ScopedLock lock(m_mutex);
280 
281  // The initial stop won't broadcast the state change event, so account for
282  // that here.
284  m_session_data->m_stop_at_entry)
286 }
287 
288 static void
289 DumpAdditionalExceptionInformation(llvm::raw_ostream &stream,
290  const ExceptionRecordSP &exception) {
291  // Decode additional exception information for specific exception types based
292  // on
293  // https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_exception_record
294 
295  const int addr_min_width = 2 + 8; // "0x" + 4 address bytes
296 
297  const std::vector<ULONG_PTR> &args = exception->GetExceptionArguments();
298  switch (exception->GetExceptionCode()) {
299  case EXCEPTION_ACCESS_VIOLATION: {
300  if (args.size() < 2)
301  break;
302 
303  stream << ": ";
304  const int access_violation_code = args[0];
305  const lldb::addr_t access_violation_address = args[1];
306  switch (access_violation_code) {
307  case 0:
308  stream << "Access violation reading";
309  break;
310  case 1:
311  stream << "Access violation writing";
312  break;
313  case 8:
314  stream << "User-mode data execution prevention (DEP) violation at";
315  break;
316  default:
317  stream << "Unknown access violation (code " << access_violation_code
318  << ") at";
319  break;
320  }
321  stream << " location "
322  << llvm::format_hex(access_violation_address, addr_min_width);
323  break;
324  }
325  case EXCEPTION_IN_PAGE_ERROR: {
326  if (args.size() < 3)
327  break;
328 
329  stream << ": ";
330  const int page_load_error_code = args[0];
331  const lldb::addr_t page_load_error_address = args[1];
332  const DWORD underlying_code = args[2];
333  switch (page_load_error_code) {
334  case 0:
335  stream << "In page error reading";
336  break;
337  case 1:
338  stream << "In page error writing";
339  break;
340  case 8:
341  stream << "User-mode data execution prevention (DEP) violation at";
342  break;
343  default:
344  stream << "Unknown page loading error (code " << page_load_error_code
345  << ") at";
346  break;
347  }
348  stream << " location "
349  << llvm::format_hex(page_load_error_address, addr_min_width)
350  << " (status code " << llvm::format_hex(underlying_code, 8) << ")";
351  break;
352  }
353  }
354 }
355 
358  llvm::sys::ScopedLock lock(m_mutex);
359 
360  if (!m_session_data) {
361  LLDB_LOG(log, "no active session. Returning...");
362  return;
363  }
364 
366 
367  std::weak_ptr<ExceptionRecord> exception_record =
368  m_session_data->m_debugger->GetActiveException();
369  ExceptionRecordSP active_exception = exception_record.lock();
370  if (!active_exception) {
371  LLDB_LOG(log,
372  "there is no active exception in process {0}. Why is the "
373  "process stopped?",
374  m_session_data->m_debugger->GetProcess().GetProcessId());
375  return;
376  }
377 
378  StopInfoSP stop_info;
379  m_thread_list.SetSelectedThreadByID(active_exception->GetThreadID());
380  ThreadSP stop_thread = m_thread_list.GetSelectedThread();
381  if (!stop_thread)
382  return;
383 
384  switch (active_exception->GetExceptionCode()) {
385  case EXCEPTION_SINGLE_STEP: {
386  RegisterContextSP register_context = stop_thread->GetRegisterContext();
387  const uint64_t pc = register_context->GetPC();
388  BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc));
389  if (site && site->ValidForThisThread(*stop_thread)) {
390  LLDB_LOG(log,
391  "Single-stepped onto a breakpoint in process {0} at "
392  "address {1:x} with breakpoint site {2}",
393  m_session_data->m_debugger->GetProcess().GetProcessId(), pc,
394  site->GetID());
395  stop_info = StopInfo::CreateStopReasonWithBreakpointSiteID(*stop_thread,
396  site->GetID());
397  stop_thread->SetStopInfo(stop_info);
398 
399  return;
400  }
401 
402  auto *reg_ctx = static_cast<RegisterContextWindows *>(
403  stop_thread->GetRegisterContext().get());
404  uint32_t slot_id = reg_ctx->GetTriggeredHardwareBreakpointSlotId();
405  if (slot_id != LLDB_INVALID_INDEX32) {
406  int id = m_watchpoint_ids[slot_id];
407  LLDB_LOG(log,
408  "Single-stepped onto a watchpoint in process {0} at address "
409  "{1:x} with watchpoint {2}",
410  m_session_data->m_debugger->GetProcess().GetProcessId(), pc, id);
411 
412  if (lldb::WatchpointSP wp_sp =
413  GetTarget().GetWatchpointList().FindByID(id))
414  wp_sp->SetHardwareIndex(slot_id);
415 
417  *stop_thread, id, m_watchpoints[id].address);
418  stop_thread->SetStopInfo(stop_info);
419 
420  return;
421  }
422 
423  LLDB_LOG(log, "single stepping thread {0}", stop_thread->GetID());
424  stop_info = StopInfo::CreateStopReasonToTrace(*stop_thread);
425  stop_thread->SetStopInfo(stop_info);
426 
427  return;
428  }
429 
430  case EXCEPTION_BREAKPOINT: {
431  RegisterContextSP register_context = stop_thread->GetRegisterContext();
432 
433  int breakpoint_size = 1;
434  switch (GetTarget().GetArchitecture().GetMachine()) {
435  case llvm::Triple::aarch64:
436  breakpoint_size = 4;
437  break;
438 
439  case llvm::Triple::arm:
440  case llvm::Triple::thumb:
441  breakpoint_size = 2;
442  break;
443 
444  case llvm::Triple::x86:
445  case llvm::Triple::x86_64:
446  breakpoint_size = 1;
447  break;
448 
449  default:
450  LLDB_LOG(log, "Unknown breakpoint size for architecture");
451  break;
452  }
453 
454  // The current PC is AFTER the BP opcode, on all architectures.
455  uint64_t pc = register_context->GetPC() - breakpoint_size;
456 
457  BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc));
458  if (site) {
459  LLDB_LOG(log,
460  "detected breakpoint in process {0} at address {1:x} with "
461  "breakpoint site {2}",
462  m_session_data->m_debugger->GetProcess().GetProcessId(), pc,
463  site->GetID());
464 
465  if (site->ValidForThisThread(*stop_thread)) {
466  LLDB_LOG(log,
467  "Breakpoint site {0} is valid for this thread ({1:x}), "
468  "creating stop info.",
469  site->GetID(), stop_thread->GetID());
470 
472  *stop_thread, site->GetID());
473  register_context->SetPC(pc);
474  } else {
475  LLDB_LOG(log,
476  "Breakpoint site {0} is not valid for this thread, "
477  "creating empty stop info.",
478  site->GetID());
479  }
480  stop_thread->SetStopInfo(stop_info);
481  return;
482  } else {
483  // The thread hit a hard-coded breakpoint like an `int 3` or
484  // `__debugbreak()`.
485  LLDB_LOG(log,
486  "No breakpoint site matches for this thread. __debugbreak()? "
487  "Creating stop info with the exception.");
488  // FALLTHROUGH: We'll treat this as a generic exception record in the
489  // default case.
490  LLVM_FALLTHROUGH;
491  }
492  }
493 
494  default: {
495  std::string desc;
496  llvm::raw_string_ostream desc_stream(desc);
497  desc_stream << "Exception "
498  << llvm::format_hex(active_exception->GetExceptionCode(), 8)
499  << " encountered at address "
500  << llvm::format_hex(active_exception->GetExceptionAddress(), 8);
501  DumpAdditionalExceptionInformation(desc_stream, active_exception);
502 
504  *stop_thread, desc_stream.str().c_str());
505  stop_thread->SetStopInfo(stop_info);
506  LLDB_LOG(log, "{0}", desc_stream.str());
507  return;
508  }
509  }
510 }
511 
512 bool ProcessWindows::CanDebug(lldb::TargetSP target_sp,
513  bool plugin_specified_by_name) {
514  if (plugin_specified_by_name)
515  return true;
516 
517  // For now we are just making sure the file exists for a given module
518  ModuleSP exe_module_sp(target_sp->GetExecutableModule());
519  if (exe_module_sp.get())
520  return FileSystem::Instance().Exists(exe_module_sp->GetFileSpec());
521  // However, if there is no executable module, we return true since we might
522  // be preparing to attach.
523  return true;
524 }
525 
527  ThreadList &new_thread_list) {
529  // Add all the threads that were previously running and for which we did not
530  // detect a thread exited event.
531  int new_size = 0;
532  int continued_threads = 0;
533  int exited_threads = 0;
534  int new_threads = 0;
535 
536  for (ThreadSP old_thread : old_thread_list.Threads()) {
537  lldb::tid_t old_thread_id = old_thread->GetID();
538  auto exited_thread_iter =
539  m_session_data->m_exited_threads.find(old_thread_id);
540  if (exited_thread_iter == m_session_data->m_exited_threads.end()) {
541  new_thread_list.AddThread(old_thread);
542  ++new_size;
543  ++continued_threads;
544  LLDB_LOGV(log, "Thread {0} was running and is still running.",
545  old_thread_id);
546  } else {
547  LLDB_LOGV(log, "Thread {0} was running and has exited.", old_thread_id);
548  ++exited_threads;
549  }
550  }
551 
552  // Also add all the threads that are new since the last time we broke into
553  // the debugger.
554  for (const auto &thread_info : m_session_data->m_new_threads) {
555  new_thread_list.AddThread(thread_info.second);
556  ++new_size;
557  ++new_threads;
558  LLDB_LOGV(log, "Thread {0} is new since last update.", thread_info.first);
559  }
560 
561  LLDB_LOG(log, "{0} new threads, {1} old threads, {2} exited threads.",
562  new_threads, continued_threads, exited_threads);
563 
564  m_session_data->m_new_threads.clear();
565  m_session_data->m_exited_threads.clear();
566 
567  return new_size > 0;
568 }
569 
571  StateType state = GetPrivateState();
572  switch (state) {
573  case eStateCrashed:
574  case eStateDetached:
575  case eStateUnloaded:
576  case eStateExited:
577  case eStateInvalid:
578  return false;
579  default:
580  return true;
581  }
582 }
583 
584 size_t ProcessWindows::DoReadMemory(lldb::addr_t vm_addr, void *buf,
585  size_t size, Status &error) {
586  size_t bytes_read = 0;
587  error = ProcessDebugger::ReadMemory(vm_addr, buf, size, bytes_read);
588  return bytes_read;
589 }
590 
591 size_t ProcessWindows::DoWriteMemory(lldb::addr_t vm_addr, const void *buf,
592  size_t size, Status &error) {
593  size_t bytes_written = 0;
594  error = ProcessDebugger::WriteMemory(vm_addr, buf, size, bytes_written);
595  return bytes_written;
596 }
597 
599  Status &error) {
601  error = ProcessDebugger::AllocateMemory(size, permissions, vm_addr);
602  return vm_addr;
603 }
604 
607 }
608 
610  MemoryRegionInfo &info) {
611  return ProcessDebugger::GetMemoryRegionInfo(vm_addr, info);
612 }
613 
615  Target &target = GetTarget();
616  ObjectFile *obj_file = target.GetExecutableModule()->GetObjectFile();
617  Address addr = obj_file->GetImageInfoAddress(&target);
618  if (addr.IsValid())
619  return addr.GetLoadAddress(&target);
620  else
621  return LLDB_INVALID_ADDRESS;
622 }
623 
625  if (m_dyld_up.get() == NULL)
627  this, DynamicLoaderWindowsDYLD::GetPluginNameStatic().GetCString()));
628  return static_cast<DynamicLoaderWindowsDYLD *>(m_dyld_up.get());
629 }
630 
632  // No need to acquire the lock since m_session_data isn't accessed.
634  LLDB_LOG(log, "Process {0} exited with code {1}", GetID(), exit_code);
635 
636  TargetSP target = CalculateTarget();
637  if (target) {
638  ModuleSP executable_module = target->GetExecutableModule();
639  ModuleList unloaded_modules;
640  unloaded_modules.Append(executable_module);
641  target->ModulesDidUnload(unloaded_modules, true);
642  }
643 
644  SetProcessExitStatus(GetID(), true, 0, exit_code);
646 
648 }
649 
651  DebuggerThreadSP debugger = m_session_data->m_debugger;
653  LLDB_LOG(log, "Debugger connected to process {0}. Image base = {1:x}",
654  debugger->GetProcess().GetProcessId(), image_base);
655 
656  ModuleSP module = GetTarget().GetExecutableModule();
657  if (!module) {
658  // During attach, we won't have the executable module, so find it now.
659  const DWORD pid = debugger->GetProcess().GetProcessId();
660  const std::string file_name = GetProcessExecutableName(pid);
661  if (file_name.empty()) {
662  return;
663  }
664 
665  FileSpec executable_file(file_name);
666  FileSystem::Instance().Resolve(executable_file);
667  ModuleSpec module_spec(executable_file);
668  Status error;
669  module =
670  GetTarget().GetOrCreateModule(module_spec, true /* notify */, &error);
671  if (!module) {
672  return;
673  }
674 
676  }
677 
678  if (auto dyld = GetDynamicLoader())
679  dyld->OnLoadModule(module, ModuleSpec(), image_base);
680 
681  // Add the main executable module to the list of pending module loads. We
682  // can't call GetTarget().ModulesDidLoad() here because we still haven't
683  // returned from DoLaunch() / DoAttach() yet so the target may not have set
684  // the process instance to `this` yet.
685  llvm::sys::ScopedLock lock(m_mutex);
686 
687  const HostThread &host_main_thread = debugger->GetMainThread();
688  ThreadSP main_thread =
689  std::make_shared<TargetThreadWindows>(*this, host_main_thread);
690 
691  tid_t id = host_main_thread.GetNativeThread().GetThreadId();
692  main_thread->SetID(id);
693 
694  m_session_data->m_new_threads[id] = main_thread;
695 }
696 
699  const ExceptionRecord &record) {
701  llvm::sys::ScopedLock lock(m_mutex);
702 
703  // FIXME: Without this check, occasionally when running the test suite there
704  // is
705  // an issue where m_session_data can be null. It's not clear how this could
706  // happen but it only surfaces while running the test suite. In order to
707  // properly diagnose this, we probably need to first figure allow the test
708  // suite to print out full lldb logs, and then add logging to the process
709  // plugin.
710  if (!m_session_data) {
711  LLDB_LOG(log,
712  "Debugger thread reported exception {0:x} at address {1:x}, "
713  "but there is no session.",
714  record.GetExceptionCode(), record.GetExceptionAddress());
716  }
717 
718  if (!first_chance) {
719  // Not any second chance exception is an application crash by definition.
720  // It may be an expression evaluation crash.
722  }
723 
725  switch (record.GetExceptionCode()) {
726  case EXCEPTION_BREAKPOINT:
727  // Handle breakpoints at the first chance.
729 
730  if (!m_session_data->m_initial_stop_received) {
731  LLDB_LOG(
732  log,
733  "Hit loader breakpoint at address {0:x}, setting initial stop event.",
734  record.GetExceptionAddress());
735  m_session_data->m_initial_stop_received = true;
736  ::SetEvent(m_session_data->m_initial_stop_event);
737  } else {
738  LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
739  record.GetExceptionAddress());
740  }
742  break;
743  case EXCEPTION_SINGLE_STEP:
746  break;
747  default:
748  LLDB_LOG(log,
749  "Debugger thread reported exception {0:x} at address {1:x} "
750  "(first_chance={2})",
751  record.GetExceptionCode(), record.GetExceptionAddress(),
752  first_chance);
753  // For non-breakpoints, give the application a chance to handle the
754  // exception first.
755  if (first_chance)
757  else
759  }
760 
761  return result;
762 }
763 
765  llvm::sys::ScopedLock lock(m_mutex);
766 
767  ThreadSP thread = std::make_shared<TargetThreadWindows>(*this, new_thread);
768 
769  const HostNativeThread &native_new_thread = new_thread.GetNativeThread();
770  tid_t id = native_new_thread.GetThreadId();
771  thread->SetID(id);
772 
773  m_session_data->m_new_threads[id] = thread;
774 
775  for (const std::map<int, WatchpointInfo>::value_type &p : m_watchpoints) {
776  auto *reg_ctx = static_cast<RegisterContextWindows *>(
777  thread->GetRegisterContext().get());
778  reg_ctx->AddHardwareBreakpoint(p.second.slot_id, p.second.address,
779  p.second.size, p.second.read,
780  p.second.write);
781  }
782 }
783 
785  llvm::sys::ScopedLock lock(m_mutex);
786 
787  // On a forced termination, we may get exit thread events after the session
788  // data has been cleaned up.
789  if (!m_session_data)
790  return;
791 
792  // A thread may have started and exited before the debugger stopped allowing a
793  // refresh.
794  // Just remove it from the new threads list in that case.
795  auto iter = m_session_data->m_new_threads.find(thread_id);
796  if (iter != m_session_data->m_new_threads.end())
797  m_session_data->m_new_threads.erase(iter);
798  else
799  m_session_data->m_exited_threads.insert(thread_id);
800 }
801 
802 void ProcessWindows::OnLoadDll(const ModuleSpec &module_spec,
803  lldb::addr_t module_addr) {
804  if (auto dyld = GetDynamicLoader())
805  dyld->OnLoadModule(nullptr, module_spec, module_addr);
806 }
807 
809  if (auto dyld = GetDynamicLoader())
810  dyld->OnUnloadModule(module_addr);
811 }
812 
814 
816  llvm::sys::ScopedLock lock(m_mutex);
818 
819  if (m_session_data->m_initial_stop_received) {
820  // This happened while debugging. Do we shutdown the debugging session,
821  // try to continue, or do something else?
822  LLDB_LOG(log,
823  "Error {0} occurred during debugging. Unexpected behavior "
824  "may result. {1}",
825  error.GetError(), error);
826  } else {
827  // If we haven't actually launched the process yet, this was an error
828  // launching the process. Set the internal error and signal the initial
829  // stop event so that the DoLaunch method wakes up and returns a failure.
830  m_session_data->m_launch_error = error;
831  ::SetEvent(m_session_data->m_initial_stop_event);
832  LLDB_LOG(
833  log,
834  "Error {0} occurred launching the process before the initial stop. {1}",
835  error.GetError(), error);
836  return;
837  }
838 }
839 
842  return {};
843 }
844 
848  return {};
849 }
850 
852  Status error;
853 
854  if (wp->IsEnabled()) {
855  wp->SetEnabled(true, notify);
856  return error;
857  }
858 
859  WatchpointInfo info;
860  for (info.slot_id = 0;
862  info.slot_id++)
864  break;
866  error.SetErrorStringWithFormat("Can't find free slot for watchpoint %i",
867  wp->GetID());
868  return error;
869  }
870  info.address = wp->GetLoadAddress();
871  info.size = wp->GetByteSize();
872  info.read = wp->WatchpointRead();
873  info.write = wp->WatchpointWrite();
874 
875  for (unsigned i = 0U; i < m_thread_list.GetSize(); i++) {
876  Thread *thread = m_thread_list.GetThreadAtIndex(i).get();
877  auto *reg_ctx = static_cast<RegisterContextWindows *>(
878  thread->GetRegisterContext().get());
879  if (!reg_ctx->AddHardwareBreakpoint(info.slot_id, info.address, info.size,
880  info.read, info.write)) {
881  error.SetErrorStringWithFormat(
882  "Can't enable watchpoint %i on thread 0x%llx", wp->GetID(),
883  thread->GetID());
884  break;
885  }
886  }
887  if (error.Fail()) {
888  for (unsigned i = 0U; i < m_thread_list.GetSize(); i++) {
889  Thread *thread = m_thread_list.GetThreadAtIndex(i).get();
890  auto *reg_ctx = static_cast<RegisterContextWindows *>(
891  thread->GetRegisterContext().get());
892  reg_ctx->RemoveHardwareBreakpoint(info.slot_id);
893  }
894  return error;
895  }
896 
897  m_watchpoints[wp->GetID()] = info;
898  m_watchpoint_ids[info.slot_id] = wp->GetID();
899 
900  wp->SetEnabled(true, notify);
901 
902  return error;
903 }
904 
906  Status error;
907 
908  if (!wp->IsEnabled()) {
909  wp->SetEnabled(false, notify);
910  return error;
911  }
912 
913  auto it = m_watchpoints.find(wp->GetID());
914  if (it == m_watchpoints.end()) {
915  error.SetErrorStringWithFormat("Info about watchpoint %i is not found",
916  wp->GetID());
917  return error;
918  }
919 
920  for (unsigned i = 0U; i < m_thread_list.GetSize(); i++) {
921  Thread *thread = m_thread_list.GetThreadAtIndex(i).get();
922  auto *reg_ctx = static_cast<RegisterContextWindows *>(
923  thread->GetRegisterContext().get());
924  if (!reg_ctx->RemoveHardwareBreakpoint(it->second.slot_id)) {
925  error.SetErrorStringWithFormat(
926  "Can't disable watchpoint %i on thread 0x%llx", wp->GetID(),
927  thread->GetID());
928  break;
929  }
930  }
931  if (error.Fail())
932  return error;
933 
934  m_watchpoint_ids[it->second.slot_id] = LLDB_INVALID_BREAK_ID;
935  m_watchpoints.erase(it);
936 
937  wp->SetEnabled(false, notify);
938 
939  return error;
940 }
941 } // namespace lldb_private
lldb_private::ProcessWindows::DidAttach
void DidAttach(lldb_private::ArchSpec &arch_spec) override
Called after attaching a process.
Definition: ProcessWindows.cpp:278
WINDOWS_LOG_PROCESS
#define WINDOWS_LOG_PROCESS
Definition: ProcessWindowsLog.h:14
lldb_private::ProcessDebugger::GetDebuggedProcessId
lldb::pid_t GetDebuggedProcessId() const
Definition: ProcessDebugger.cpp:68
lldb_private::StoppointSite::GetLoadAddress
virtual lldb::addr_t GetLoadAddress() const
Definition: StoppointSite.h:27
ProcessWindows.h
lldb_private::ProcessWindows::DoReadMemory
size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) override
Actually do the reading of memory from a process.
Definition: ProcessWindows.cpp:584
lldb_private::ProcessWindows::OnDebugString
void OnDebugString(const std::string &string) override
Definition: ProcessWindows.cpp:813
lldb_private::ArchSpec
Definition: ArchSpec.h:33
ExceptionResult::BreakInDebugger
@ BreakInDebugger
lldb_private::HostThread::GetNativeThread
HostNativeThread & GetNativeThread()
Definition: HostThread.cpp:32
FileSystem.h
lldb_private::ProcessWindows::m_watchpoint_ids
std::vector< lldb::break_id_t > m_watchpoint_ids
Definition: ProcessWindows.h:117
lldb_private::Process::m_thread_list
ThreadList m_thread_list
The threads for this process as the user will see them.
Definition: Process.h:2894
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:336
ModuleSpec.h
lldb_private::HostThread
Definition: HostThread.h:29
lldb_private::HostThreadPosix
Definition: HostThreadPosix.h:16
lldb_private::Target::GetOrCreateModule
lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify, Status *error_ptr=nullptr)
Find a binary on the system and return its Module, or return an existing Module that is already in th...
Definition: Target.cpp:1977
lldb_private::Process::GetPrivateState
lldb::StateType GetPrivateState()
Definition: Process.cpp:1414
ExceptionResult::MaskException
@ MaskException
lldb_private::Process::EnableSoftwareBreakpoint
virtual Status EnableSoftwareBreakpoint(BreakpointSite *bp_site)
Definition: Process.cpp:1756
HostProcess.h
lldb_private::ProcessWindows::GetSTDOUT
size_t GetSTDOUT(char *buf, size_t buf_size, Status &error) override
Get any available STDOUT.
Definition: ProcessWindows.cpp:129
lldb_private::DebuggerThreadSP
std::shared_ptr< DebuggerThread > DebuggerThreadSP
Definition: ForwardDecl.h:36
lldb_private::StoppointSite::GetByteSize
uint32_t GetByteSize() const
Definition: StoppointSite.h:31
lldb_private::ProcessWindows::WatchpointInfo
Definition: ProcessWindows.h:109
TargetThreadWindows.h
lldb_private::Process
Definition: Process.h:341
lldb_private::Target::GetExecutableModule
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition: Target.cpp:1345
lldb_private::Process::GetBreakpointSiteList
BreakpointSiteList & GetBreakpointSiteList()
Definition: Process.cpp:1566
Module.h
lldb_private::Process::GetTarget
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1209
lldb_private::ProcessWindows::DoHalt
Status DoHalt(bool &caused_stop) override
Halts a running process.
Definition: ProcessWindows.cpp:265
lldb_private::ThreadList::RefreshStateAfterStop
void RefreshStateAfterStop()
Definition: ThreadList.cpp:458
lldb_private::ProcessWindows::IsAlive
bool IsAlive() override
Check if a process is still alive.
Definition: ProcessWindows.cpp:570
lldb_private::ProcessWindows::DoAttachToProcessWithID
Status DoAttachToProcessWithID(lldb::pid_t pid, const lldb_private::ProcessAttachInfo &attach_info) override
Attach to an existing process using a process ID.
Definition: ProcessWindows.cpp:201
lldb_private::Module
Definition: Module.h:84
lldb_private::ProcessWindows::~ProcessWindows
~ProcessWindows()
Definition: ProcessWindows.cpp:127
lldb_private::ProcessInfo::GetProcessID
lldb::pid_t GetProcessID() const
Definition: ProcessInfo.h:67
lldb_private::StopInfo::CreateStopReasonToTrace
static lldb::StopInfoSP CreateStopReasonToTrace(Thread &thread)
Definition: StopInfo.cpp:1278
lldb_private::ProcessWindows::GetImageInfoAddress
lldb::addr_t GetImageInfoAddress() override
Get the image information address for the current process.
Definition: ProcessWindows.cpp:614
lldb_private::MemoryRegionInfo
Definition: MemoryRegionInfo.h:21
lldb_private::FileSystem::Exists
bool Exists(const FileSpec &file_spec) const
Returns whether the given file exists.
Definition: common/FileSystem.cpp:170
lldb_private::ProcessDebugger::m_mutex
llvm::sys::Mutex m_mutex
Definition: ProcessDebugger.h:97
lldb_private::ProcessDebugger::ReadMemory
Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read)
Definition: ProcessDebugger.cpp:262
lldb_private::ProcessWindows::OnExitProcess
void OnExitProcess(uint32_t exit_code) override
Definition: ProcessWindows.cpp:631
lldb_private::RegisterContextWindows::DoHardwareBreakpointsTriggerAfter
static constexpr bool DoHardwareBreakpointsTriggerAfter()
Definition: RegisterContextWindows.h:41
lldb_private::Process::SetID
void SetID(lldb::pid_t new_pid)
Sets the stored pid.
Definition: Process.h:546
lldb_private::StoppointSite::GetID
lldb::break_id_t GetID() const
Definition: StoppointSite.h:49
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::ProcessWindows
Definition: ProcessWindows.h:23
pc
@ pc
Definition: CompactUnwindInfo.cpp:1250
lldb_private::Process::SetPrivateState
void SetPrivateState(lldb::StateType state)
Definition: Process.cpp:1416
lldb_private::ProcessWindows::OnDebuggerError
void OnDebuggerError(const Status &error, uint32_t type) override
Definition: ProcessWindows.cpp:815
lldb_private::ProcessWindows::WatchpointInfo::read
bool read
Definition: ProcessWindows.h:113
lldb_private::Target
Definition: Target.h:451
Section.h
LLDB_LOGV
#define LLDB_LOGV(log,...)
Definition: Log.h:256
LLDB_PLUGIN_DEFINE_ADV
LLDB_PLUGIN_DEFINE_ADV(ObjectContainerUniversalMachO, ObjectContainerMachOArchive) void ObjectContainerUniversalMachO
Definition: ObjectContainerUniversalMachO.cpp:23
lldb_private::ProcessWindows::GetWatchpointSupportInfo
Status GetWatchpointSupportInfo(uint32_t &num) override
Definition: ProcessWindows.cpp:840
lldb_private::ProcessDebugger::DestroyProcess
Status DestroyProcess(lldb::StateType process_state)
Definition: ProcessDebugger.cpp:211
lldb_private::ProcessWindows::EnableWatchpoint
Status EnableWatchpoint(Watchpoint *wp, bool notify=true) override
Definition: ProcessWindows.cpp:851
lldb::eStateExited
@ eStateExited
Process has exited and can't be examined.
Definition: lldb-enumerations.h:90
lldb_private::ProcessDebugger::DetachProcess
Status DetachProcess()
Definition: ProcessDebugger.cpp:74
lldb_private::ProcessWindows::WatchpointInfo::size
uint32_t size
Definition: ProcessWindows.h:112
lldb_private::ProcessWindows::DisableWatchpoint
Status DisableWatchpoint(Watchpoint *wp, bool notify=true) override
Definition: ProcessWindows.cpp:905
WINDOWS_LOG_THREAD
#define WINDOWS_LOG_THREAD
Definition: ProcessWindowsLog.h:16
ProcessWindowsLog.h
lldb_private::Watchpoint::SetEnabled
void SetEnabled(bool enabled, bool notify=true)
Definition: Watchpoint.cpp:238
lldb_private::ProcessWindows::OnExitThread
void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override
Definition: ProcessWindows.cpp:784
lldb_private::ProcessWindows::PutSTDIN
size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) override
Puts data into this process's STDIN.
Definition: ProcessWindows.cpp:139
lldb::eStateStopped
@ eStateStopped
Process or thread is stopped and can be examined.
Definition: lldb-enumerations.h:84
Target.h
lldb_private::Watchpoint::IsEnabled
bool IsEnabled() const
Definition: Watchpoint.cpp:219
lldb_private::ProcessWindows::DisableBreakpointSite
Status DisableBreakpointSite(BreakpointSite *bp_site) override
Definition: ProcessWindows.cpp:159
lldb_private::ProcessWindows::OnLoadDll
void OnLoadDll(const ModuleSpec &module_spec, lldb::addr_t module_addr) override
Definition: ProcessWindows.cpp:802
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:56
lldb_private::ProcessWindows::GetMemoryRegionInfo
Status GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info) override
Locate the memory region that contains load_addr.
Definition: ProcessWindows.cpp:609
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ProcessWindows::DoUpdateThreadList
bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
Definition: ProcessWindows.cpp:526
lldb_private::ThreadList::SetSelectedThreadByID
bool SetSelectedThreadByID(lldb::tid_t tid, bool notify=false)
Definition: ThreadList.cpp:660
lldb_private::ProcessWindows::DoWriteMemory
size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error) override
Actually do the writing of memory to a process.
Definition: ProcessWindows.cpp:591
lldb::eStateCrashed
@ eStateCrashed
Process or thread has crashed and can be examined.
Definition: lldb-enumerations.h:88
lldb_private::BreakpointSite
Definition: BreakpointSite.h:35
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
Watchpoint.h
lldb_private::ModuleList
Definition: ModuleList.h:72
lldb_private::ProcessWindows::GetDynamicLoader
DynamicLoaderWindowsDYLD * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
Definition: ProcessWindows.cpp:624
lldb_private::eLoadDependentsNo
@ eLoadDependentsNo
Definition: Target.h:64
MemoryRegionInfo.h
HostNativeProcessBase.h
lldb_private::Process::DisableSoftwareBreakpoint
virtual Status DisableSoftwareBreakpoint(BreakpointSite *bp_site)
Definition: Process.cpp:1832
lldb_private::Thread
Definition: Thread.h:60
lldb_private::RegisterContextWindows::AddHardwareBreakpoint
bool AddHardwareBreakpoint(uint32_t slot, lldb::addr_t address, uint32_t size, bool read, bool write)
Definition: RegisterContextWindows.cpp:76
lldb_private::Watchpoint
Definition: Watchpoint.h:24
lldb_private::Status::Fail
bool Fail() const
Test for error condition.
Definition: Status.cpp:182
ForwardDecl.h
lldb_private::StoppointSite::HardwareRequired
bool HardwareRequired() const
Definition: StoppointSite.h:37
lldb_private::Process::m_dyld_up
lldb::DynamicLoaderUP m_dyld_up
Definition: Process.h:2918
lldb_private::ObjectFile::GetImageInfoAddress
virtual lldb_private::Address GetImageInfoAddress(Target *target)
Similar to Process::GetImageInfoAddress().
Definition: ObjectFile.h:461
ExceptionResult
ExceptionResult
Definition: ForwardDecl.h:16
WINDOWS_LOG_EXCEPTION
#define WINDOWS_LOG_EXCEPTION
Definition: ProcessWindowsLog.h:15
lldb_private::ProcessDebugger::LaunchProcess
Status LaunchProcess(ProcessLaunchInfo &launch_info, DebugDelegateSP delegate)
Definition: ProcessDebugger.cpp:105
lldb_private::ThreadList
Definition: ThreadList.h:26
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::ExceptionRecord::GetExceptionCode
DWORD GetExceptionCode() const
Definition: ExceptionRecord.h:58
lldb_private::ThreadCollection::Threads
virtual ThreadIterable Threads()
Definition: ThreadCollection.h:46
lldb_private::Process::SetProcessExitStatus
static bool SetProcessExitStatus(lldb::pid_t pid, bool exited, int signo, int status)
Static function that can be used with the host function Host::StartMonitoringChildProcess ().
Definition: Process.cpp:1105
lldb_private::StopInfo::CreateStopReasonWithWatchpointID
static lldb::StopInfoSP CreateStopReasonWithWatchpointID(Thread &thread, lldb::break_id_t watch_id, lldb::addr_t watch_hit_addr=LLDB_INVALID_ADDRESS)
Definition: StopInfo.cpp:1268
lldb_private::ProcessWindows::DoResume
Status DoResume() override
Resumes all of a process's threads as configured using the Thread run control functions.
Definition: ProcessWindows.cpp:210
lldb_private::Watchpoint::WatchpointRead
bool WatchpointRead() const
Definition: Watchpoint.cpp:266
lldb_private::DynamicLoaderWindowsDYLD::GetPluginNameStatic
static ConstString GetPluginNameStatic()
Definition: DynamicLoaderWindowsDYLD.cpp:40
lldb::eStateDetached
@ eStateDetached
Process has been detached and can't be examined.
Definition: lldb-enumerations.h:89
lldb_private::ProcessWindows::GetSTDERR
size_t GetSTDERR(char *buf, size_t buf_size, Status &error) override
Get any available STDERR.
Definition: ProcessWindows.cpp:134
ExceptionResult::SendToApplication
@ SendToApplication
lldb_private::RegisterContextWindows
Definition: RegisterContextWindows.h:19
lldb_private::ProcessWindows::OnCreateThread
void OnCreateThread(const HostThread &thread) override
Definition: ProcessWindows.cpp:764
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::ThreadList::GetThreadAtIndex
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
Definition: ThreadList.cpp:90
lldb_private::FileSystem::Resolve
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
Definition: common/FileSystem.cpp:255
lldb_private::LocalDebugDelegate
Definition: LocalDebugDelegate.h:41
lldb_private::ProcessWindows::RefreshStateAfterStop
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
Definition: ProcessWindows.cpp:356
ExceptionRecord.h
lldb_private::ProcessWindows::DoDeallocateMemory
Status DoDeallocateMemory(lldb::addr_t ptr) override
Actually deallocate memory in the process.
Definition: ProcessWindows.cpp:605
lldb::eStateUnloaded
@ eStateUnloaded
Process is object is valid, but not currently loaded.
Definition: lldb-enumerations.h:75
WINDOWS_LOG_BREAKPOINTS
#define WINDOWS_LOG_BREAKPOINTS
Definition: ProcessWindowsLog.h:18
lldb_private::ProcessAttachInfo
Definition: Process.h:113
ObjectFile.h
lldb_private::ProcessWindows::DidLaunch
void DidLaunch() override
Called after launching a process.
Definition: ProcessWindows.cpp:273
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
lldb_private::ExceptionRecord::GetExceptionAddress
lldb::addr_t GetExceptionAddress() const
Definition: ExceptionRecord.h:63
lldb_private::Target::SetExecutableModule
void SetExecutableModule(lldb::ModuleSP &module_sp, LoadDependentFiles load_dependent_files=eLoadDependentsDefault)
Set the main executable module.
Definition: Target.cpp:1394
lldb_private::ShouldUseLLDBServer
static bool ShouldUseLLDBServer()
Definition: ProcessWindows.cpp:87
DebuggerThread.h
LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_BREAK_ID
Definition: lldb-defines.h:49
lldb_private::Process::CalculateTarget
lldb::TargetSP CalculateTarget() override
Definition: Process.cpp:4204
lldb_private::ProcessDebugger::DeallocateMemory
Status DeallocateMemory(lldb::addr_t addr)
Definition: ProcessDebugger.cpp:355
lldb_private::ModuleSpec
Definition: ModuleSpec.h:26
lldb_private::ProcessWindows::OnDebuggerConnected
void OnDebuggerConnected(lldb::addr_t image_base) override
Definition: ProcessWindows.cpp:650
lldb_private::Status
Definition: Status.h:44
uint32_t
lldb_private::Address
Definition: Address.h:59
id
void * id
Definition: PlatformiOSSimulatorCoreSimulatorSupport.h:20
lldb::pid_t
uint64_t pid_t
Definition: lldb-types.h:85
lldb_private::RegisterContextWindows::RemoveHardwareBreakpoint
bool RemoveHardwareBreakpoint(uint32_t slot)
Definition: RegisterContextWindows.cpp:121
lldb_private::ProcessWindows::m_watchpoints
std::map< lldb::break_id_t, WatchpointInfo > m_watchpoints
Definition: ProcessWindows.h:116
lldb_private::Address::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:310
lldb_private::ThreadList::GetSize
uint32_t GetSize(bool can_update=true)
Definition: ThreadList.cpp:82
lldb_private::ProcessWindowsLog::GetLogIfAny
static Log * GetLogIfAny(uint32_t mask)
Definition: ProcessWindowsLog.h:31
lldb_private::DynamicLoader::FindPlugin
static DynamicLoader * FindPlugin(Process *process, const char *plugin_name)
Find a dynamic loader plugin for a given process.
Definition: DynamicLoader.cpp:32
StopInfo.h
windows.h
lldb_private::ProcessWindows::CanDebug
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
Definition: ProcessWindows.cpp:512
PluginManager.h
lldb_private::ProcessWindows::DoDetach
Status DoDetach(bool keep_stopped) override
Detaches from a running or stopped process.
Definition: ProcessWindows.cpp:171
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
LLDB_LOG
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:242
lldb_private::Process::GetID
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
Definition: Process.h:541
lldb_private::ProcessWindows::DoDestroy
Status DoDestroy() override
Definition: ProcessWindows.cpp:260
lldb_private::FileSystem::Instance
static FileSystem & Instance()
Definition: common/FileSystem.cpp:45
lldb_private::ProcessWindows::DoAllocateMemory
lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, Status &error) override
Actually allocate memory in the process.
Definition: ProcessWindows.cpp:598
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::ProcessDebugger::AllocateMemory
Status AllocateMemory(size_t size, uint32_t permissions, lldb::addr_t &addr)
Definition: ProcessDebugger.cpp:326
lldb_private::ProcessWindows::OnDebugException
ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record) override
Definition: ProcessWindows.cpp:698
lldb::eStateInvalid
@ eStateInvalid
Definition: lldb-enumerations.h:74
lldb_private::ProcessWindows::WatchpointInfo::slot_id
uint32_t slot_id
Definition: ProcessWindows.h:110
State.h
lldb_private::ThreadCollection::AddThread
void AddThread(const lldb::ThreadSP &thread_sp)
Definition: ThreadCollection.cpp:24
LLDB_INVALID_INDEX32
#define LLDB_INVALID_INDEX32
Definition: lldb-defines.h:87
lldb::StateType
StateType
Process and Thread States.
Definition: lldb-enumerations.h:73
lldb_private::StopInfo::CreateStopReasonWithBreakpointSiteID
static lldb::StopInfoSP CreateStopReasonWithBreakpointSiteID(Thread &thread, lldb::break_id_t break_id)
Definition: StopInfo.cpp:1256
lldb_private::Log
Definition: Log.h:49
lldb_private::DynamicLoaderWindowsDYLD
Definition: DynamicLoaderWindowsDYLD.h:19
lldb_private::ProcessWindows::WatchpointInfo::write
bool write
Definition: ProcessWindows.h:114
lldb_private::Thread::GetRegisterContext
virtual lldb::RegisterContextSP GetRegisterContext()=0
lldb_private::RegisterContextWindows::GetNumHardwareBreakpointSlots
static constexpr uint32_t GetNumHardwareBreakpointSlots()
Definition: RegisterContextWindows.h:38
lldb_private::DumpAdditionalExceptionInformation
static void DumpAdditionalExceptionInformation(llvm::raw_ostream &stream, const ExceptionRecordSP &exception)
Definition: ProcessWindows.cpp:289
lldb_private::ThreadList::GetSelectedThread
lldb::ThreadSP GetSelectedThread()
Definition: ThreadList.cpp:648
lldb_private::StopInfo::CreateStopReasonWithException
static lldb::StopInfoSP CreateStopReasonWithException(Thread &thread, const char *description)
Definition: StopInfo.cpp:1289
lldb_private::ExceptionRecordSP
std::shared_ptr< ExceptionRecord > ExceptionRecordSP
Definition: ForwardDecl.h:37
LocalDebugDelegate.h
DynamicLoader.h
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:296
lldb::eStateRunning
@ eStateRunning
Process or thread is running and can't be examined.
Definition: lldb-enumerations.h:85
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:472
lldb_private::Watchpoint::WatchpointWrite
bool WatchpointWrite() const
Definition: Watchpoint.cpp:268
HostThreadWindows.h
lldb_private::ObjectFile
Definition: ObjectFile.h:58
lldb_private::ModuleList::Append
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
lldb_private::ProcessDebugger::GetMemoryRegionInfo
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
Definition: ProcessDebugger.cpp:380
lldb_private::ExceptionRecord
Definition: ExceptionRecord.h:25
lldb_private::ProcessWindows::DoLaunch
Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override
Launch a new process.
Definition: ProcessWindows.cpp:190
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86
lldb_private::ProcessWindows::WatchpointInfo::address
lldb::addr_t address
Definition: ProcessWindows.h:111
lldb_private::ProcessWindows::EnableBreakpointSite
Status EnableBreakpointSite(BreakpointSite *bp_site) override
Definition: ProcessWindows.cpp:145
lldb_private::ProcessWindows::OnUnloadDll
void OnUnloadDll(lldb::addr_t module_addr) override
Definition: ProcessWindows.cpp:808