14#include "llvm/ADT/ScopeExit.h"
15#include "llvm/Support/ScopedPrinter.h"
16#include "llvm/Support/Threading.h"
77using namespace std::chrono;
81#define ENABLE_MEMORY_CACHING
83#ifdef ENABLE_MEMORY_CACHING
84#define DISABLE_MEM_CACHE_DEFAULT false
86#define DISABLE_MEM_CACHE_DEFAULT true
90 :
public Cloneable<ProcessOptionValueProperties, OptionValueProperties> {
106 if (
this != instance_properties)
118 "Continue tracing the parent process and detach the child.",
123 "Trace the child process and detach the parent.",
127#define LLDB_PROPERTIES_process
128#include "TargetProperties.inc"
131#define LLDB_PROPERTIES_process
132#include "TargetPropertiesEnum.inc"
136#define LLDB_PROPERTIES_process_experimental
137#include "TargetProperties.inc"
140#define LLDB_PROPERTIES_process_experimental
141#include "TargetPropertiesEnum.inc"
145 :
public Cloneable<ProcessExperimentalOptionValueProperties,
146 OptionValueProperties> {
162 if (process ==
nullptr) {
164 m_collection_sp = std::make_shared<ProcessOptionValueProperties>(
"process");
167 "thread",
"Settings specific to threads.",
true,
173 ePropertyPythonOSPluginPath,
178 std::make_unique<ProcessExperimentalProperties>();
181 "Experimental settings - setting these won't produce "
182 "errors if the setting is not present.",
189 const uint32_t idx = ePropertyDisableMemCache;
190 return GetPropertyAtIndexAs<bool>(
191 idx, g_process_properties[idx].default_uint_value != 0);
195 const uint32_t idx = ePropertyMemCacheLineSize;
196 return GetPropertyAtIndexAs<uint64_t>(
197 idx, g_process_properties[idx].default_uint_value);
202 const uint32_t idx = ePropertyExtraStartCommand;
208 const uint32_t idx = ePropertyExtraStartCommand;
213 const uint32_t idx = ePropertyPythonOSPluginPath;
214 return GetPropertyAtIndexAs<FileSpec>(idx, {});
218 const uint32_t idx = ePropertyVirtualAddressableBits;
219 return GetPropertyAtIndexAs<uint64_t>(
220 idx, g_process_properties[idx].default_uint_value);
224 const uint32_t idx = ePropertyVirtualAddressableBits;
229 const uint32_t idx = ePropertyHighmemVirtualAddressableBits;
230 return GetPropertyAtIndexAs<uint64_t>(
231 idx, g_process_properties[idx].default_uint_value);
235 const uint32_t idx = ePropertyHighmemVirtualAddressableBits;
240 const uint32_t idx = ePropertyPythonOSPluginPath;
245 const uint32_t idx = ePropertyIgnoreBreakpointsInExpressions;
246 return GetPropertyAtIndexAs<bool>(
247 idx, g_process_properties[idx].default_uint_value != 0);
251 const uint32_t idx = ePropertyIgnoreBreakpointsInExpressions;
256 const uint32_t idx = ePropertyUnwindOnErrorInExpressions;
257 return GetPropertyAtIndexAs<bool>(
258 idx, g_process_properties[idx].default_uint_value != 0);
262 const uint32_t idx = ePropertyUnwindOnErrorInExpressions;
267 const uint32_t idx = ePropertyStopOnSharedLibraryEvents;
268 return GetPropertyAtIndexAs<bool>(
269 idx, g_process_properties[idx].default_uint_value != 0);
273 const uint32_t idx = ePropertyStopOnSharedLibraryEvents;
278 const uint32_t idx = ePropertyDisableLangRuntimeUnwindPlans;
279 return GetPropertyAtIndexAs<bool>(
280 idx, g_process_properties[idx].default_uint_value != 0);
284 const uint32_t idx = ePropertyDisableLangRuntimeUnwindPlans;
290 const uint32_t idx = ePropertyDetachKeepsStopped;
291 return GetPropertyAtIndexAs<bool>(
292 idx, g_process_properties[idx].default_uint_value != 0);
296 const uint32_t idx = ePropertyDetachKeepsStopped;
301 const uint32_t idx = ePropertyWarningOptimization;
302 return GetPropertyAtIndexAs<bool>(
303 idx, g_process_properties[idx].default_uint_value != 0);
307 const uint32_t idx = ePropertyWarningUnsupportedLanguage;
308 return GetPropertyAtIndexAs<bool>(
309 idx, g_process_properties[idx].default_uint_value != 0);
313 const uint32_t idx = ePropertyStopOnExec;
314 return GetPropertyAtIndexAs<bool>(
315 idx, g_process_properties[idx].default_uint_value != 0);
319 const uint32_t idx = ePropertyUtilityExpressionTimeout;
320 uint64_t value = GetPropertyAtIndexAs<uint64_t>(
321 idx, g_process_properties[idx].default_uint_value);
322 return std::chrono::seconds(value);
326 const uint32_t idx = ePropertyInterruptTimeout;
327 uint64_t value = GetPropertyAtIndexAs<uint64_t>(
328 idx, g_process_properties[idx].default_uint_value);
329 return std::chrono::seconds(value);
333 const uint32_t idx = ePropertySteppingRunsAllThreads;
334 return GetPropertyAtIndexAs<bool>(
335 idx, g_process_properties[idx].default_uint_value != 0);
339 const bool fail_value =
true;
343 exp_property->
GetValue()->GetAsProperties();
349 .value_or(fail_value);
356 exp_property->
GetValue()->GetAsProperties();
363 const uint32_t idx = ePropertyFollowForkMode;
364 return GetPropertyAtIndexAs<FollowForkMode>(
366 g_process_properties[idx].default_uint_value));
370 llvm::StringRef plugin_name,
374 static uint32_t g_process_unique_id = 0;
378 if (!plugin_name.empty()) {
381 if (create_callback) {
382 process_sp = create_callback(target_sp, listener_sp, crash_file_path,
385 if (process_sp->CanDebug(target_sp,
true)) {
386 process_sp->m_process_unique_id = ++g_process_unique_id;
392 for (uint32_t idx = 0;
396 process_sp = create_callback(target_sp, listener_sp, crash_file_path,
399 if (process_sp->CanDebug(target_sp,
false)) {
400 process_sp->m_process_unique_id = ++g_process_unique_id;
424 Broadcaster((target_sp->GetDebugger().GetBroadcasterManager()),
425 Process::GetStaticBroadcasterClass().AsCString()),
428 m_private_state_broadcaster(nullptr,
429 "lldb.process.internal_state_broadcaster"),
430 m_private_state_control_broadcaster(
431 nullptr,
"lldb.process.internal_state_control_broadcaster"),
432 m_private_state_listener_sp(
433 Listener::MakeListener(
"lldb.process.internal_state_listener")),
434 m_mod_id(), m_process_unique_id(0), m_thread_index_id(0),
435 m_thread_id_to_index_id_map(), m_exit_status(-1), m_exit_string(),
436 m_exit_status_mutex(), m_thread_mutex(), m_thread_list_real(this),
437 m_thread_list(this), m_thread_plans(*this), m_extended_thread_list(this),
438 m_extended_thread_stop_id(0), m_queue_list(this), m_queue_list_stop_id(0),
439 m_watchpoint_resource_list(), m_notifications(), m_image_tokens(),
440 m_breakpoint_site_list(), m_dynamic_checkers_up(),
441 m_unix_signals_sp(unix_signals_sp), m_abi_sp(), m_process_input_reader(),
442 m_stdio_communication(
"process.stdio"), m_stdio_communication_mutex(),
443 m_stdin_forward(false), m_stdout_data(), m_stderr_data(),
444 m_profile_data_comm_mutex(), m_profile_data(), m_iohandler_sync(0),
445 m_memory_cache(*this), m_allocated_memory_cache(*this),
446 m_should_detach(false), m_next_event_action_up(), m_public_run_lock(),
447 m_private_run_lock(), m_currently_handling_do_on_removals(false),
448 m_resume_requested(false), m_finalizing(false), m_destructing(false),
449 m_clear_thread_plans_on_stop(false), m_force_next_event_delivery(false),
450 m_last_broadcast_state(
eStateInvalid), m_destroy_in_process(false),
451 m_can_interpret_function_calls(false), m_run_thread_plan_lock(),
452 m_can_jit(eCanJITDontKnow) {
456 LLDB_LOGF(log,
"%p Process::Process()",
static_cast<void *
>(
this));
494 uint64_t platform_cache_line_size =
495 target_sp->GetPlatform()->GetDefaultMemoryCacheLineSize();
496 if (!value_sp->OptionWasSet() && platform_cache_line_size != 0)
497 value_sp->SetValueAs(platform_cache_line_size);
504 LLDB_LOGF(log,
"%p Process::~Process()",
static_cast<void *
>(
this));
518 return *g_settings_ptr;
553 std::vector<Notifications> empty_notifications;
587 if (pos->baton == callbacks.
baton &&
598 std::vector<Notifications>::iterator notification_pos,
601 notification_pos != notification_end; ++notification_pos) {
602 if (notification_pos->process_state_changed)
603 notification_pos->process_state_changed(notification_pos->baton,
this,
622 std::chrono::seconds(0)) &&
642 "waited from m_iohandler_sync to change from {0}. New value is {1}.",
643 iohandler_id, *Result);
645 LLDB_LOG(log,
"timed out waiting for m_iohandler_sync to change from {0}.",
658 event_sp_ptr->reset();
666 LLDB_LOG(log,
"timeout = {0}", timeout);
671 "Process::%s returning without waiting for events; process "
672 "private and public states are already 'stopped'.",
676 if (hijack_listener_sp && use_run_lock)
684 if (event_sp_ptr && event_sp)
685 *event_sp_ptr = event_sp;
687 bool pop_process_io_handler = (hijack_listener_sp.get() !=
nullptr);
689 event_sp, stream, select_most_relevant, pop_process_io_handler);
698 if (hijack_listener_sp && use_run_lock)
707 if (hijack_listener_sp && use_run_lock)
721 bool &pop_process_io_handler) {
722 const bool handle_pop = pop_process_io_handler;
724 pop_process_io_handler =
false;
736 switch (event_state) {
744 stream->
Printf(
"Process %" PRIu64
" %s\n", process_sp->GetID(),
747 pop_process_io_handler =
true;
757 process_sp->GetStatus(*stream);
758 pop_process_io_handler =
true;
769 if (num_reasons > 0) {
772 if (num_reasons == 1) {
776 stream->
Printf(
"Process %" PRIu64
" stopped and restarted: %s\n",
778 reason ? reason :
"<UNKNOWN REASON>");
780 stream->
Printf(
"Process %" PRIu64
781 " stopped and restarted, reasons:\n",
782 process_sp->GetID());
784 for (
size_t i = 0; i < num_reasons; i++) {
788 stream->
Printf(
"\t%s\n", reason ? reason :
"<UNKNOWN REASON>");
798 ThreadList &thread_list = process_sp->GetThreadList();
799 std::lock_guard<std::recursive_mutex> guard(thread_list.
GetMutex());
804 bool prefer_curr_thread =
false;
805 if (curr_thread && curr_thread->IsValid()) {
806 curr_thread_stop_reason = curr_thread->GetStopReason();
807 switch (curr_thread_stop_reason) {
816 uint64_t signo = curr_thread->GetStopInfo()->GetValue();
817 if (process_sp->GetUnixSignals()->GetShouldStop(signo))
818 prefer_curr_thread =
true;
821 prefer_curr_thread =
true;
824 curr_thread_stop_info_sp = curr_thread->GetStopInfo();
827 if (!prefer_curr_thread) {
833 const size_t num_threads = thread_list.
GetSize();
835 for (i = 0; i < num_threads; ++i) {
837 StopReason thread_stop_reason = thread->GetStopReason();
838 switch (thread_stop_reason) {
847 uint64_t signo = thread->GetStopInfo()->GetValue();
848 if (process_sp->GetUnixSignals()->GetShouldStop(signo)) {
850 other_thread = thread;
866 other_thread = thread;
870 plan_thread = thread;
876 else if (other_thread)
879 if (curr_thread && curr_thread->IsValid())
880 thread = curr_thread;
894 Debugger &debugger = process_sp->GetTarget().GetDebugger();
896 &process_sp->GetTarget()) {
897 ThreadSP thread_sp = process_sp->GetThreadList().GetSelectedThread();
899 if (!thread_sp || !thread_sp->IsValid())
902 const bool only_threads_with_stop_reason =
true;
903 const uint32_t start_frame =
904 thread_sp->GetSelectedFrameIndex(select_most_relevant);
905 const uint32_t num_frames = 1;
906 const uint32_t num_frames_with_source = 1;
907 const bool stop_format =
true;
909 process_sp->GetStatus(*stream);
910 process_sp->GetThreadStatus(*stream, only_threads_with_stop_reason,
911 start_frame, num_frames,
912 num_frames_with_source,
914 if (curr_thread_stop_info_sp) {
917 curr_thread_stop_info_sp, &crashing_address);
923 valobj_sp->GetExpressionPath(*stream, format);
924 stream->
Printf(
" accessed 0x%" PRIx64
"\n", crashing_address);
929 process_sp->GetTarget().shared_from_this());
931 stream->
Printf(
"Target %d: (", target_idx);
933 stream->
Printf(
"Target <unknown index>: (");
935 stream->
Printf(
") stopped.\n");
940 pop_process_io_handler =
true;
945 if (handle_pop && pop_process_io_handler)
946 process_sp->PopProcessIOHandler();
965 LLDB_LOG(log,
"timeout = {0}, event_sp)...", timeout);
972 if (listener_sp->GetEventForBroadcasterWithType(
978 LLDB_LOG(log,
"got no event or was interrupted.");
981 LLDB_LOG(log,
"timeout = {0}, event_sp) => {1}", timeout, state);
988 LLDB_LOGF(log,
"Process::%s...", __FUNCTION__);
995 LLDB_LOGF(log,
"Process::%s (event_ptr) => %s", __FUNCTION__,
998 LLDB_LOGF(log,
"Process::%s no events found", __FUNCTION__);
1008 LLDB_LOG(log,
"timeout = {0}, event_sp)...", timeout);
1018 LLDB_LOG(log,
"timeout = {0}, event_sp) => {1}", timeout,
1025 bool control_only) {
1027 LLDB_LOG(log,
"timeout = {0}, event_sp)...", timeout);
1061 LLDB_LOG(log,
"(plugin = {0} status = {1} ({1:x8}), description=\"{2}\")",
1068 "(plugin = {0}) ignoring exit status because state was already set "
1075 if (!exit_string.empty())
1119 "Process::SetProcessExitStatus (pid=%" PRIu64
1120 ", exited=%i, signal=%i, exit_status=%i)\n",
1121 pid, exited, signo, exit_status);
1126 ProcessSP process_sp(target_sp->GetProcessSP());
1128 llvm::StringRef signal_str =
1129 process_sp->GetUnixSignals()->GetSignalAsStringRef(signo);
1130 process_sp->SetExitStatus(exit_status, signal_str);
1148 bool clear_unused_threads =
true;
1171 size_t num_old_threads = old_thread_list.
GetSize(
false);
1172 for (
size_t i = 0; i < num_old_threads; ++i)
1205 new_thread_list = real_thread_list;
1245 bool internal,
bool condense_trivial,
1246 bool skip_unreported_plans) {
1248 strm, tid, desc_level, internal, condense_trivial, skip_unreported_plans);
1251 bool internal,
bool condense_trivial,
1252 bool skip_unreported_plans) {
1254 skip_unreported_plans);
1287 uint32_t result = 0;
1288 std::map<uint64_t, uint32_t>::iterator iterator =
1294 result = iterator->second;
1309 if (new_state_is_stopped) {
1320 LLDB_LOGF(log,
"(plugin = %s, state = %s, restarted = %i)",
1331 "(plugin = %s, state = %s) -- unlocking run lock for detach",
1336 if ((old_state_is_stopped != new_state_is_stopped)) {
1337 if (new_state_is_stopped && !restarted) {
1338 LLDB_LOGF(log,
"(plugin = %s, state = %s) -- unlocking run lock",
1351 Status error(
"Resume request failed - process still running.");
1352 LLDB_LOGF(log,
"(plugin = %s) -- TrySetRunning failed, not resuming.",
1357 if (!
error.Success()) {
1366 LLDB_LOGF(log,
"Process::ResumeSynchronous -- locking run lock");
1368 Status error(
"Resume request failed - process still running.");
1369 LLDB_LOGF(log,
"Process::Resume: -- TrySetRunning failed, not resuming.");
1378 if (
error.Success()) {
1382 const bool must_be_alive =
1385 error.SetErrorStringWithFormat(
1386 "process not in stopped state after synchronous resume: %s",
1402 if (!hijacking_name.starts_with(
"lldb.internal"))
1430 bool state_changed =
false;
1439 state_changed = old_state != new_state;
1443 if (old_state_is_stopped != new_state_is_stopped) {
1444 if (new_state_is_stopped)
1450 if (state_changed) {
1474 LLDB_LOGF(log,
"(plugin = %s, state = %s, stop_id = %u",
1481 LLDB_LOGF(log,
"(plugin = %s, state = %s) state didn't change. Ignoring...",
1503 std::vector<LanguageRuntime *> language_runtimes;
1506 return language_runtimes;
1516 language_runtimes.emplace_back(runtime);
1519 return language_runtimes;
1529 LanguageRuntimeCollection::iterator pos;
1536 runtime = runtime_sp.get();
1538 runtime = pos->second.get();
1564 if (runtime->CouldHaveDynamicValue(in_value))
1594 if (
error.Success())
1604 if (bp_site_sp->IsEnabled())
1607 error.SetErrorStringWithFormat(
"invalid breakpoint site ID: %" PRIu64,
1618 if (!bp_site_sp->IsEnabled())
1621 error.SetErrorStringWithFormat(
"invalid breakpoint site ID: %" PRIu64,
1629 bool use_hardware) {
1632 bool show_error =
true;
1655 constituent->SetIsIndirect(
false);
1657 if (constituent->ShouldResolveIndirectFunctions()) {
1663 if (!
error.Success() && show_error) {
1665 "warning: failed to resolve indirect function at 0x%" PRIx64
1666 " for breakpoint %i.%i: %s\n",
1668 constituent->GetBreakpoint().GetID(), constituent->GetID(),
1669 error.AsCString() ?
error.AsCString() :
"unknown error");
1672 Address resolved_address(load_addr);
1674 constituent->SetIsIndirect(
true);
1676 load_addr = constituent->GetAddress().GetOpcodeLoadAddress(&
GetTarget());
1678 load_addr = constituent->GetAddress().GetOpcodeLoadAddress(&
GetTarget());
1689 bp_site_sp->AddConstituent(constituent);
1690 constituent->SetBreakpointSite(bp_site_sp);
1691 return bp_site_sp->GetID();
1697 if (
error.Success()) {
1698 constituent->SetBreakpointSite(bp_site_sp);
1701 if (show_error || use_hardware) {
1704 "warning: failed to set breakpoint site at 0x%" PRIx64
1705 " for breakpoint %i.%i: %s\n",
1706 load_addr, constituent->GetBreakpoint().GetID(),
1707 constituent->GetID(),
1708 error.AsCString() ?
error.AsCString() :
"unknown error");
1721 uint32_t num_constituents =
1722 bp_site_sp->RemoveConstituent(constituent_id, constituent_loc_id);
1723 if (num_constituents == 0) {
1732 uint8_t *buf)
const {
1733 size_t bytes_removed = 0;
1737 bp_sites_in_range)) {
1738 bp_sites_in_range.
ForEach([bp_addr, size,
1741 addr_t intersect_addr;
1742 size_t intersect_size;
1743 size_t opcode_offset;
1744 if (bp_site->IntersectsRange(bp_addr, size, &intersect_addr,
1745 &intersect_size, &opcode_offset)) {
1746 assert(bp_addr <= intersect_addr && intersect_addr < bp_addr + size);
1747 assert(bp_addr < intersect_addr + intersect_size &&
1748 intersect_addr + intersect_size <= bp_addr + size);
1749 assert(opcode_offset + intersect_size <= bp_site->GetByteSize());
1750 size_t buf_offset = intersect_addr - bp_addr;
1751 ::memcpy(buf + buf_offset,
1752 bp_site->GetSavedOpcodeBytes() + opcode_offset,
1758 return bytes_removed;
1764 return platform_sp->GetSoftwareBreakpointTrapOpcode(
GetTarget(), bp_site);
1770 assert(bp_site !=
nullptr);
1774 log,
"Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64,
1775 bp_site->
GetID(), (uint64_t)bp_addr);
1779 "Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
1780 " -- already enabled",
1781 bp_site->
GetID(), (uint64_t)bp_addr);
1786 error.SetErrorString(
"BreakpointSite contains an invalid load address.");
1793 if (bp_opcode_size == 0) {
1794 error.SetErrorStringWithFormat(
"Process::GetSoftwareBreakpointTrapOpcode() "
1795 "returned zero, unable to get breakpoint "
1796 "trap for address 0x%" PRIx64,
1801 if (bp_opcode_bytes ==
nullptr) {
1802 error.SetErrorString(
1803 "BreakpointSite doesn't contain a valid breakpoint trap opcode.");
1809 error) == bp_opcode_size) {
1813 uint8_t verify_bp_opcode_bytes[64];
1814 if (
DoReadMemory(bp_addr, verify_bp_opcode_bytes, bp_opcode_size,
1815 error) == bp_opcode_size) {
1816 if (::memcmp(bp_opcode_bytes, verify_bp_opcode_bytes,
1817 bp_opcode_size) == 0) {
1821 "Process::EnableSoftwareBreakpoint (site_id = %d) "
1822 "addr = 0x%" PRIx64
" -- SUCCESS",
1823 bp_site->
GetID(), (uint64_t)bp_addr);
1825 error.SetErrorString(
1826 "failed to verify the breakpoint trap in memory.");
1828 error.SetErrorString(
1829 "Unable to read memory to verify breakpoint trap.");
1831 error.SetErrorString(
"Unable to write breakpoint trap to memory.");
1833 error.SetErrorString(
"Unable to read memory at breakpoint address.");
1835 if (log &&
error.Fail())
1838 "Process::EnableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
1840 bp_site->
GetID(), (uint64_t)bp_addr,
error.AsCString());
1846 assert(bp_site !=
nullptr);
1851 "Process::DisableSoftwareBreakpoint (breakID = %" PRIu64
1852 ") addr = 0x%" PRIx64,
1853 breakID, (uint64_t)bp_addr);
1856 error.SetErrorString(
"Breakpoint site is a hardware breakpoint.");
1858 const size_t break_op_size = bp_site->
GetByteSize();
1860 if (break_op_size > 0) {
1862 uint8_t curr_break_op[8];
1863 assert(break_op_size <=
sizeof(curr_break_op));
1864 bool break_op_found =
false;
1869 bool verify =
false;
1871 if (::memcmp(curr_break_op, break_op, break_op_size) == 0) {
1872 break_op_found =
true;
1876 break_op_size,
error) == break_op_size) {
1879 error.SetErrorString(
1880 "Memory write failed when restoring original opcode.");
1882 error.SetErrorString(
1883 "Original breakpoint trap is no longer in memory.");
1890 uint8_t verify_opcode[8];
1891 assert(break_op_size <
sizeof(verify_opcode));
1897 break_op_size) == 0) {
1901 "Process::DisableSoftwareBreakpoint (site_id = %d) "
1902 "addr = 0x%" PRIx64
" -- SUCCESS",
1903 bp_site->
GetID(), (uint64_t)bp_addr);
1907 error.SetErrorString(
"Failed to restore original opcode.");
1910 error.SetErrorString(
"Failed to read memory to verify that "
1911 "breakpoint trap was restored.");
1914 error.SetErrorString(
1915 "Unable to read memory that should contain the breakpoint trap.");
1920 "Process::DisableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
1921 " -- already disabled",
1922 bp_site->
GetID(), (uint64_t)bp_addr);
1928 "Process::DisableSoftwareBreakpoint (site_id = %d) addr = 0x%" PRIx64
1930 bp_site->
GetID(), (uint64_t)bp_addr,
error.AsCString());
1940 addr = abi_sp->FixAnyAddress(addr);
1944#if defined(VERIFY_MEMORY_READS)
1956 std::string verify_buf(size,
'\0');
1957 assert(verify_buf.size() == size);
1958 const size_t cache_bytes_read =
1961 const size_t verify_bytes_read =
1963 verify_buf.size(), verify_error);
1964 assert(cache_bytes_read == verify_bytes_read);
1965 assert(memcmp(buf, verify_buf.data(), verify_buf.size()) == 0);
1967 return cache_bytes_read;
1991 out_str.append(buf, length);
1994 if (length ==
sizeof(buf) - 1)
1995 curr_addr += length;
1999 return out_str.size();
2007 size_t total_cstr_len = 0;
2008 if (dst && dst_max_len) {
2009 result_error.
Clear();
2011 memset(dst, 0, dst_max_len);
2015 size_t bytes_left = dst_max_len - 1;
2016 char *curr_dst = dst;
2018 while (bytes_left > 0) {
2019 addr_t cache_line_bytes_left =
2020 cache_line_size - (curr_addr % cache_line_size);
2022 std::min<addr_t>(bytes_left, cache_line_bytes_left);
2023 size_t bytes_read =
ReadMemory(curr_addr, curr_dst, bytes_to_read,
error);
2025 if (bytes_read == 0) {
2026 result_error =
error;
2027 dst[total_cstr_len] =
'\0';
2030 const size_t len = strlen(curr_dst);
2032 total_cstr_len += len;
2034 if (len < bytes_to_read)
2037 curr_dst += bytes_read;
2038 curr_addr += bytes_read;
2039 bytes_left -= bytes_read;
2045 result_error.
Clear();
2047 return total_cstr_len;
2055 addr = abi_sp->FixAnyAddress(addr);
2057 if (buf ==
nullptr || size == 0)
2060 size_t bytes_read = 0;
2061 uint8_t *bytes = (uint8_t *)buf;
2063 while (bytes_read < size) {
2064 const size_t curr_size = size - bytes_read;
2065 const size_t curr_bytes_read =
2067 bytes_read += curr_bytes_read;
2068 if (curr_bytes_read == curr_size || curr_bytes_read == 0)
2080 size_t integer_byte_size,
2081 uint64_t fail_value,
2091 size_t integer_byte_size,
2113 if (addr_byte_size <= 4)
2114 scalar = (uint32_t)ptr_value;
2123 size_t bytes_written = 0;
2124 const uint8_t *bytes = (
const uint8_t *)buf;
2126 while (bytes_written < size) {
2127 const size_t curr_size = size - bytes_written;
2129 addr + bytes_written, bytes + bytes_written, curr_size,
error);
2130 bytes_written += curr_bytes_written;
2131 if (curr_bytes_written == curr_size || curr_bytes_written == 0)
2134 return bytes_written;
2140 addr = abi_sp->FixAnyAddress(addr);
2142#if defined(ENABLE_MEMORY_CACHING)
2146 if (buf ==
nullptr || size == 0)
2160 if (bp_sites_in_range.
IsEmpty())
2163 const uint8_t *ubuf = (
const uint8_t *)buf;
2164 uint64_t bytes_written = 0;
2166 bp_sites_in_range.
ForEach([
this, addr, size, &bytes_written, &ubuf,
2175 size_t intersect_size;
2176 size_t opcode_offset;
2178 addr, size, &intersect_addr, &intersect_size, &opcode_offset);
2181 assert(addr <= intersect_addr && intersect_addr < addr + size);
2182 assert(addr < intersect_addr + intersect_size &&
2183 intersect_addr + intersect_size <= addr + size);
2184 assert(opcode_offset + intersect_size <= bp->GetByteSize());
2187 const addr_t curr_addr = addr + bytes_written;
2188 if (intersect_addr > curr_addr) {
2191 size_t curr_size = intersect_addr - curr_addr;
2192 size_t curr_bytes_written =
2194 bytes_written += curr_bytes_written;
2195 if (curr_bytes_written != curr_size) {
2199 if (
error.Success())
2200 error.SetErrorToGenericError();
2207 bytes_written += intersect_size;
2211 if (bytes_written < size)
2214 size - bytes_written,
error);
2216 return bytes_written;
2223 if (byte_size > 0) {
2225 const size_t mem_size =
2230 error.SetErrorString(
"failed to get scalar as memory data");
2232 error.SetErrorString(
"invalid scalar value");
2238 bool is_signed,
Scalar &scalar,
2241 if (byte_size == 0) {
2242 error.SetErrorString(
"byte size is zero");
2243 }
else if (byte_size & (byte_size - 1)) {
2244 error.SetErrorStringWithFormat(
"byte size %u is not a power of 2",
2246 }
else if (byte_size <=
sizeof(uval)) {
2248 if (bytes_read == byte_size) {
2253 scalar = data.
GetMaxU32(&offset, byte_size);
2255 scalar = data.
GetMaxU64(&offset, byte_size);
2261 error.SetErrorStringWithFormat(
2262 "byte size of %u is too large for integer scalar type", byte_size);
2269 for (
const auto &
Entry : entries) {
2272 if (!
error.Success())
2278#define USE_ALLOCATE_MEMORY_CACHE 1
2282 error.SetErrorToGenericError();
2286#if defined(USE_ALLOCATE_MEMORY_CACHE)
2292 "Process::AllocateMemory(size=%" PRIu64
2293 ", permissions=%s) => 0x%16.16" PRIx64
2294 " (m_stop_id = %u m_memory_id = %u)",
2298 return allocated_addr;
2305 if (
error.Success()) {
2306 std::string buffer(size, 0);
2318 8, ePermissionsReadable | ePermissionsWritable | ePermissionsExecutable,
2324 "Process::%s pid %" PRIu64
2325 " allocation test passed, CanJIT () is true",
2326 __FUNCTION__,
GetID());
2330 "Process::%s pid %" PRIu64
2331 " allocation test failed, CanJIT () is false: %s",
2352#if defined(USE_ALLOCATE_MEMORY_CACHE)
2354 error.SetErrorStringWithFormat(
2355 "deallocation of memory at 0x%" PRIx64
" failed.", (uint64_t)ptr);
2362 "Process::DeallocateMemory(addr=0x%16.16" PRIx64
2363 ") => err = %s (m_stop_id = %u, m_memory_id = %u)",
2372 return *subclass_override;
2374 bool reported_after =
true;
2377 return reported_after;
2380 if (triple.isMIPS() || triple.isPPC64() || triple.isRISCV() ||
2381 triple.isAArch64() || triple.isArmMClass() || triple.isARM())
2382 reported_after =
false;
2384 return reported_after;
2389 size_t size_to_read) {
2393 "Process::ReadModuleFromMemory reading %s binary from memory",
2399 ObjectFile *objfile = module_sp->GetMemoryObjectFile(
2400 shared_from_this(), header_addr,
error, size_to_read);
2408 uint32_t &permissions) {
2412 if (!
error.Success())
2425 error.SetErrorString(
"watchpoints are not supported");
2431 error.SetErrorString(
"watchpoints are not supported");
2470 LaunchPrivate(launch_info, state_after_launch, first_stop_event_sp);
2492 if (launch_info.
GetFlags().
Test(eLaunchFlagStopAtEntry))
2524 error.SetErrorString(
"executable module does not exist");
2550 std::string local_exec_file_path = exe_spec_to_use.
GetPath();
2551 return Status(
"file doesn't exist: '%s'", local_exec_file_path.c_str());
2554 const bool restarted =
false;
2563 error.SetErrorString(
"failed to acquire process run lock");
2569 const char *error_string =
error.AsCString();
2570 if (error_string ==
nullptr)
2571 error_string =
"launch failed";
2584 error.SetErrorString(
"failed to catch stop after launch");
2626 return Status(
"Unexpected process state after the launch: %s, expected %s, "
2635 if (
error.Success()) {
2670 LLDB_LOGF(log,
"Process::Halt() failed to stop, state is: %s",
2672 error.SetErrorString(
2673 "Did not get stopped event after loading the core file.");
2711 uint32_t exec_count)
2716 "Process::AttachCompletionHandler::%s process=%p, exec_count=%" PRIu32,
2717 __FUNCTION__,
static_cast<void *
>(process), exec_count);
2726 "Process::AttachCompletionHandler::%s called with state %s (%d)",
2731 return eEventActionSuccess;
2735 return eEventActionRetry;
2746 if (m_exec_count > 0) {
2750 "Process::AttachCompletionHandler::%s state %s: reduced "
2751 "remaining exec count to %" PRIu32
", requesting resume",
2755 return eEventActionRetry;
2758 "Process::AttachCompletionHandler::%s state %s: no more "
2759 "execs expected to start, continuing with attach",
2763 return eEventActionSuccess;
2774 return eEventActionExit;
2779 return eEventActionSuccess;
2788 return m_listener_sp;
2802 bool wait_for_launch) {
2823 sizeof(process_name))) {
2826 if (wait_for_launch) {
2828 if (
error.Success()) {
2831 const bool restarted =
false;
2837 error.SetErrorString(
"failed to acquire process run lock");
2843 if (
error.AsCString() ==
nullptr)
2844 error.SetErrorString(
"attach failed");
2863 platform_sp->FindProcesses(match_info, process_infos);
2864 const uint32_t num_matches = process_infos.size();
2865 if (num_matches == 1) {
2866 attach_pid = process_infos[0].GetProcessID();
2870 process_name,
sizeof(process_name));
2871 if (num_matches > 1) {
2874 for (
size_t i = 0; i < num_matches; i++) {
2875 process_infos[i].DumpAsTableRow(
2876 s, platform_sp->GetUserIDResolver(),
true,
false);
2878 error.SetErrorStringWithFormat(
2879 "more than one process named %s:\n%s", process_name,
2882 error.SetErrorStringWithFormat(
2883 "could not find a process named %s", process_name);
2886 error.SetErrorString(
2887 "invalid platform, can't find processes by name");
2892 error.SetErrorString(
"invalid process name");
2898 if (
error.Success()) {
2903 const bool restarted =
false;
2908 error.SetErrorString(
"failed to acquire process run lock");
2911 if (
error.Success()) {
2919 const char *error_string =
error.AsCString();
2920 if (error_string ==
nullptr)
2921 error_string =
"attach failed";
2932 LLDB_LOGF(log,
"Process::%s()", __FUNCTION__);
2941 "Process::{0} replacing process architecture with DidAttach() "
2942 "architecture: \"{1}\"",
2943 __FUNCTION__, process_arch.
GetTriple().getTriple());
2951 assert(platform_sp);
2955 if (target_arch.
IsValid() && !platform_sp->IsCompatibleArchitecture(
2956 target_arch, process_host_arch,
2960 target_arch, process_host_arch, &platform_arch);
2965 "switching platform to {0} and architecture to {1} based on "
2967 platform_sp->GetName(), platform_arch.
GetTriple().getTriple());
2969 }
else if (!process_arch.
IsValid()) {
2979 "Process::%s switching architecture to %s based on info "
2980 "the platform retrieved for pid %" PRIu64,
2981 __FUNCTION__, process_arch.
GetTriple().getTriple().c_str(),
3001 "after DynamicLoader::DidAttach(), target "
3002 "executable is {0} (using {1} plugin)",
3003 exe_module_sp ? exe_module_sp->GetFileSpec() :
FileSpec(),
3011 if (system_runtime) {
3016 "after SystemRuntime::DidAttach(), target "
3017 "executable is {0} (using {1} plugin)",
3018 exe_module_sp ? exe_module_sp->GetFileSpec() :
FileSpec(),
3036 if (module_sp && module_sp->IsExecutable()) {
3037 if (
GetTarget().GetExecutableModulePointer() != module_sp.get())
3038 new_executable_module_sp = module_sp;
3042 if (new_executable_module_sp) {
3049 "Process::%s after looping through modules, target executable is %s",
3051 exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
3068 if (
error.Success()) {
3095 "Process::PrivateResume() m_stop_id = %u, public state: %s "
3096 "private state: %s",
3106 if (
error.Success()) {
3117 error.SetErrorString(
3118 "Process::PrivateResume PreResumeActions failed, not resuming.");
3122 if (
error.Success()) {
3125 LLDB_LOGF(log,
"Process thinks the process has resumed.");
3127 LLDB_LOGF(log,
"Process::PrivateResume() DoResume failed.");
3137 "Process::PrivateResume() asked to simulate a start & stop.");
3143 LLDB_LOGF(log,
"Process::PrivateResume() got an error \"%s\".",
3144 error.AsCString(
"<unknown error>"));
3150 return Status(
"Process is not running.");
3179 halt_listener_sp,
nullptr,
3180 use_run_lock, select_most_relevant);
3202 LLDB_LOGF(log,
"Process::%s() About to stop.", __FUNCTION__);
3212 &exit_event_sp,
true, listener_sp);
3222 LLDB_LOGF(log,
"Process::%s() Process exited while waiting to stop.",
3226 exit_event_sp.reset();
3229 LLDB_LOGF(log,
"Process::%s() failed to stop, state is: %s", __FUNCTION__,
3237 "Attempt to stop the target in order to detach timed out. "
3253 if (
error.Success()) {
3256 if (!
error.Success()) {
3259 }
else if (exit_event_sp) {
3272 if (
error.Success()) {
3283 if (exit_event_sp) {
3318 bool keep_stopped =
false;
3325 if (
error.Success()) {
3342 if (
error.Success()) {
3361 if (exit_event_sp) {
3381 if (
error.Success()) {
3383 if (
error.Success())
3390 assert(signals_sp &&
"null signals_sp");
3410 bool return_value =
true;
3428 return_value =
true;
3432 return_value =
false;
3444 return_value =
true;
3450 return_value =
false;
3463 return_value =
true;
3466 return_value =
false;
3485 "Process::ShouldBroadcastEvent (%p) stopped due to an "
3486 "interrupt, state: %s",
3491 return_value =
true;
3494 bool should_resume =
false;
3506 "Process::ShouldBroadcastEvent: should_resume: %i state: "
3507 "%s was_restarted: %i report_stop_vote: %d.",
3511 switch (report_stop_vote) {
3513 return_value =
true;
3517 return_value =
false;
3521 if (!was_restarted) {
3523 "Process::ShouldBroadcastEvent (%p) Restarting process "
3530 return_value =
true;
3553 "Process::ShouldBroadcastEvent (%p) => new state: %s, last "
3554 "broadcast state: %s - %s",
3557 return_value ?
"YES" :
"NO");
3558 return return_value;
3565 LLDB_LOGF(log,
"Process::%s()%s ", __FUNCTION__,
3566 already_running ?
" already running"
3567 :
" starting private state thread");
3569 if (!is_secondary_thread && already_running)
3574 char thread_name[1024];
3575 uint32_t max_len = llvm::get_max_thread_name_length();
3576 if (max_len > 0 && max_len <= 30) {
3579 if (already_running)
3580 snprintf(thread_name,
sizeof(thread_name),
"intern-state-OV");
3582 snprintf(thread_name,
sizeof(thread_name),
"intern-state");
3584 if (already_running)
3585 snprintf(thread_name,
sizeof(thread_name),
3586 "<lldb.process.internal-state-override(pid=%" PRIu64
")>",
3589 snprintf(thread_name,
sizeof(thread_name),
3590 "<lldb.process.internal-state(pid=%" PRIu64
")>",
GetID());
3593 llvm::Expected<HostThread> private_state_thread =
3596 [
this, is_secondary_thread] {
3600 if (!private_state_thread) {
3602 "failed to launch host thread: {0}");
3606 assert(private_state_thread->IsJoinable());
3627 "Went to stop the private state thread, but it was already invalid.");
3638 LLDB_LOGF(log,
"Process::%s (signal = %d)", __FUNCTION__, signal);
3647 LLDB_LOGF(log,
"Sending control event of type: %d.", signal);
3648 std::shared_ptr<EventDataReceipt> event_receipt_sp(
new EventDataReceipt());
3653 bool receipt_received =
false;
3655 while (!receipt_received) {
3660 if (!receipt_received) {
3677 "Private state thread already dead, no need to signal it to stop.");
3700 LLDB_LOGF(log,
"Ran next event action, result was %d.", action_result);
3702 switch (action_result) {
3728 if (should_broadcast) {
3732 "Process::%s (pid = %" PRIu64
3733 ") broadcasting new state %s (old state %s) to %s",
3736 is_hijacked ?
"hijacked" :
"public");
3743 if (!
GetTarget().GetDebugger().IsForwardingEvents() &&
3748 LLDB_LOGF(log,
"Process::%s updated m_iohandler_sync to %d",
3782 if (is_hijacked || !
GetTarget().GetDebugger().IsHandlingEvents())
3792 "Process::%s (pid = %" PRIu64
3793 ") suppressing state %s (old state %s): should_broadcast == false",
3815 bool control_only =
true;
3818 LLDB_LOGF(log,
"Process::%s (arg = %p, pid = %" PRIu64
") thread starting...",
3819 __FUNCTION__,
static_cast<void *
>(
this),
GetID());
3821 bool exit_now =
false;
3822 bool interrupt_requested =
false;
3828 "Process::%s (arg = %p, pid = %" PRIu64
3829 ") got a control event: %d",
3830 __FUNCTION__,
static_cast<void *
>(
this),
GetID(),
3831 event_sp->GetType());
3833 switch (event_sp->GetType()) {
3839 control_only =
true;
3843 control_only =
false;
3851 "Process::%s (arg = %p, pid = %" PRIu64
3852 ") woke up with an interrupt while attaching - "
3853 "forwarding interrupt.",
3854 __FUNCTION__,
static_cast<void *
>(
this),
GetID());
3865 "Process::%s (arg = %p, pid = %" PRIu64
3866 ") woke up with an interrupt - Halting.",
3867 __FUNCTION__,
static_cast<void *
>(
this),
GetID());
3869 if (
error.Fail() && log)
3871 "Process::%s (arg = %p, pid = %" PRIu64
3872 ") failed to halt the process: %s",
3873 __FUNCTION__,
static_cast<void *
>(
this),
GetID(),
3880 interrupt_requested =
true;
3889 "Process::%s ignoring interrupt as we have already stopped.",
3905 if (interrupt_requested) {
3910 interrupt_requested =
false;
3913 "Process::%s interrupt_requested, but a non-stopped "
3914 "state '%s' received.",
3925 "Process::%s (arg = %p, pid = %" PRIu64
3926 ") about to exit with internal state %s...",
3927 __FUNCTION__,
static_cast<void *
>(
this),
GetID(),
3935 LLDB_LOGF(log,
"Process::%s (arg = %p, pid = %" PRIu64
") thread exiting...",
3936 __FUNCTION__,
static_cast<void *
>(
this),
GetID());
3941 if (!is_secondary_thread)
3952 :
EventData(), m_process_wp(), m_state(state) {
3960 return "Process::ProcessEventData";
3968 bool &found_valid_stopinfo) {
3969 found_valid_stopinfo =
false;
3971 ProcessSP process_sp(m_process_wp.lock());
3975 ThreadList &curr_thread_list = process_sp->GetThreadList();
3976 uint32_t num_threads = curr_thread_list.
GetSize();
3989 ThreadList not_suspended_thread_list(process_sp.get());
3990 std::vector<uint32_t> thread_index_array(num_threads);
3991 uint32_t not_suspended_idx = 0;
3992 for (idx = 0; idx < num_threads; ++idx) {
4000 not_suspended_thread_list.
AddThread(thread_sp);
4001 thread_index_array[not_suspended_idx] = thread_sp->GetIndexID();
4002 not_suspended_idx++;
4011 bool still_should_stop =
false;
4019 for (idx = 0; idx < not_suspended_thread_list.
GetSize(); ++idx) {
4020 curr_thread_list = process_sp->GetThreadList();
4021 if (curr_thread_list.
GetSize() != num_threads) {
4025 "Number of threads changed from %u to %u while processing event.",
4026 num_threads, curr_thread_list.
GetSize());
4032 if (thread_sp->GetIndexID() != thread_index_array[idx]) {
4035 "The thread at position %u changed from %u to %u while "
4036 "processing event.",
4037 idx, thread_index_array[idx], thread_sp->GetIndexID());
4041 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
4042 if (stop_info_sp && stop_info_sp->IsValid()) {
4043 found_valid_stopinfo =
true;
4044 bool this_thread_wants_to_stop;
4045 if (stop_info_sp->GetOverrideShouldStop()) {
4046 this_thread_wants_to_stop =
4047 stop_info_sp->GetOverriddenShouldStopValue();
4049 stop_info_sp->PerformAction(event_ptr);
4057 if (stop_info_sp->HasTargetRunSinceMe()) {
4062 this_thread_wants_to_stop = stop_info_sp->ShouldStop(event_ptr);
4065 if (!still_should_stop)
4066 still_should_stop = this_thread_wants_to_stop;
4070 return still_should_stop;
4074 ProcessSP process_sp(m_process_wp.lock());
4087 if (m_update_state != 1)
4090 process_sp->SetPublicState(
4097 process_sp->WillPublicStop();
4112 bool does_anybody_have_an_opinion =
false;
4113 bool still_should_stop = ShouldStop(event_ptr, does_anybody_have_an_opinion);
4115 if (GetRestarted()) {
4119 if (!still_should_stop && does_anybody_have_an_opinion) {
4124 process_sp->PrivateResume();
4127 !process_sp->StateChangedIsHijackedForSynchronousResume();
4135 if (process_sp->GetTarget().RunStopHooks())
4142 ProcessSP process_sp(m_process_wp.lock());
4145 s->
Printf(
" process = %p (pid = %" PRIu64
"), ",
4146 static_cast<void *
>(process_sp.get()), process_sp->GetID());
4175 if (data ==
nullptr)
4183 if (data ==
nullptr)
4193 if (data !=
nullptr)
4201 if (data !=
nullptr)
4212 if (data !=
nullptr)
4219 const char *reason) {
4222 if (data !=
nullptr)
4227 const Event *event_ptr) {
4229 if (data ==
nullptr)
4239 if (data !=
nullptr)
4282 auto event_data_sp =
4283 std::make_shared<ProcessEventData>(shared_from_this(),
GetState());
4284 return std::make_shared<Event>(event_type, event_data_sp);
4310 auto data_sp = std::make_shared<EventDataStructuredData>(
4311 shared_from_this(), object_sp, plugin_sp);
4319 return find_it->second;
4330 size_t bytes_available = one_profile_data.size();
4331 if (bytes_available > 0) {
4333 LLDB_LOGF(log,
"Process::GetProfileData (buf = %p, size = %" PRIu64
")",
4334 static_cast<void *
>(buf),
static_cast<uint64_t
>(buf_size));
4335 if (bytes_available > buf_size) {
4336 memcpy(buf, one_profile_data.c_str(), buf_size);
4337 one_profile_data.erase(0, buf_size);
4338 bytes_available = buf_size;
4340 memcpy(buf, one_profile_data.c_str(), bytes_available);
4344 return bytes_available;
4352 if (bytes_available > 0) {
4354 LLDB_LOGF(log,
"Process::GetSTDOUT (buf = %p, size = %" PRIu64
")",
4355 static_cast<void *
>(buf),
static_cast<uint64_t
>(buf_size));
4356 if (bytes_available > buf_size) {
4359 bytes_available = buf_size;
4365 return bytes_available;
4371 if (bytes_available > 0) {
4373 LLDB_LOGF(log,
"Process::GetSTDERR (buf = %p, size = %" PRIu64
")",
4374 static_cast<void *
>(buf),
static_cast<uint64_t
>(buf_size));
4375 if (bytes_available > buf_size) {
4378 bytes_available = buf_size;
4384 return bytes_available;
4390 process->
AppendSTDOUT(
static_cast<const char *
>(src), src_len);
4396 :
IOHandler(process->GetTarget().GetDebugger(),
4399 m_read_file(GetInputFD(),
File::eOpenOptionReadOnly, false),
4400 m_write_file(write_fd,
File::eOpenOptionWriteOnly, false) {
4401 m_pipe.CreateNew(
false);
4407 std::lock_guard<std::mutex> guard(m_mutex);
4408 SetIsDone(!running);
4409 m_is_running = running;
4415 if (!m_read_file.IsValid() || !m_write_file.IsValid() ||
4416 !m_pipe.CanRead() || !m_pipe.CanWrite()) {
4422 const int read_fd = m_read_file.GetDescriptor();
4427 llvm::consumeError(terminal.
SetEcho(
false));
4430 const int pipe_read_fd = m_pipe.GetReadFileDescriptor();
4434 std::lock_guard<std::mutex> guard(m_mutex);
4451 if (m_read_file.Read(&ch, n).Success() && n == 1) {
4452 if (m_write_file.Write(&ch, n).Fail() || n != 1)
4462 if (
error.Success()) {
4467 m_process->SendAsyncInterrupt();
4471 SetIsRunning(
false);
4476 std::lock_guard<std::mutex> guard(m_mutex);
4491 size_t bytes_written = 0;
4492 m_pipe.Write(&ch, 1, bytes_written);
4504 size_t bytes_written = 0;
4505 Status result = m_pipe.Write(&ch, 1, bytes_written);
4518 m_process->SendAsyncInterrupt();
4534 bool m_is_running =
false;
4540 std::make_unique<ConnectionFileDescriptor>(fd,
true));
4551 std::make_shared<IOHandlerProcessSTDIO>(
this, fd);
4567 if (io_handler_sp) {
4569 LLDB_LOGF(log,
"Process::%s pushing IO handler", __FUNCTION__);
4571 io_handler_sp->SetIsDone(
false);
4578 cancel_top_handler);
4604class RestorePlanState {
4607 : m_thread_plan_sp(thread_plan_sp) {
4608 if (m_thread_plan_sp) {
4609 m_private = m_thread_plan_sp->GetPrivate();
4610 m_is_controlling = m_thread_plan_sp->IsControllingPlan();
4611 m_okay_to_discard = m_thread_plan_sp->OkayToDiscard();
4615 ~RestorePlanState() { Clean(); }
4618 if (!m_already_reset && m_thread_plan_sp) {
4619 m_already_reset =
true;
4620 m_thread_plan_sp->SetPrivate(m_private);
4621 m_thread_plan_sp->SetIsControllingPlan(m_is_controlling);
4622 m_thread_plan_sp->SetOkayToDiscard(m_okay_to_discard);
4628 bool m_already_reset =
false;
4629 bool m_private =
false;
4630 bool m_is_controlling =
false;
4631 bool m_okay_to_discard =
false;
4637 const milliseconds default_one_thread_timeout(250);
4642 : default_one_thread_timeout;
4651 return std::min<microseconds>(default_one_thread_timeout,
4657 bool before_first_timeout) {
4663 if (before_first_timeout)
4667 return std::nullopt;
4672static std::optional<ExpressionResults>
4674 RestorePlanState &restorer,
const EventSP &event_sp,
4675 EventSP &event_to_broadcast_sp,
4677 bool handle_interrupts) {
4680 ThreadSP thread_sp = thread_plan_sp->GetTarget()
4683 .FindThreadByID(thread_id);
4686 "The thread on which we were running the "
4687 "expression: tid = {0}, exited while "
4688 "the expression was running.",
4694 if (plan == thread_plan_sp && plan->PlanSucceeded()) {
4695 LLDB_LOG(log,
"execution completed successfully");
4703 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
4705 stop_info_sp->ShouldNotify(event_sp.get())) {
4706 LLDB_LOG(log,
"stopped for breakpoint: {0}.", stop_info_sp->GetDescription());
4713 thread_plan_sp->SetPrivate(
false);
4714 event_to_broadcast_sp = event_sp;
4719 if (!handle_interrupts &&
4721 return std::nullopt;
4723 LLDB_LOG(log,
"thread plan did not successfully complete");
4725 event_to_broadcast_sp = event_sp;
4738 if (!thread_plan_sp) {
4741 "RunThreadPlan called with empty thread plan.");
4745 if (!thread_plan_sp->ValidatePlan(
nullptr)) {
4748 "RunThreadPlan called with an invalid thread plan.");
4754 "RunThreadPlan called on wrong process.");
4759 if (thread ==
nullptr) {
4761 "RunThreadPlan called with invalid thread.");
4772 RestorePlanState thread_plan_restorer(thread_plan_sp);
4779 thread_plan_sp->SetPrivate(
false);
4785 thread_plan_sp->SetIsControllingPlan(
true);
4786 thread_plan_sp->SetOkayToDiscard(
false);
4796 "RunThreadPlan called while the private state was not stopped.");
4801 const uint32_t thread_idx_id = thread->
GetIndexID();
4804 if (!selected_frame_sp) {
4807 if (!selected_frame_sp) {
4808 diagnostic_manager.
Printf(
4810 "RunThreadPlan called without a selected frame on thread %d",
4821 "RunThreadPlan called with one thread "
4822 "timeout greater than total timeout");
4826 StackID ctx_frame_id = selected_frame_sp->GetStackID();
4834 uint32_t selected_tid;
4836 if (selected_thread_sp) {
4837 selected_tid = selected_thread_sp->GetIndexID();
4856 LLDB_LOGF(log,
"Running thread plan on private state thread, spinning up "
4857 "another state thread to handle the events.");
4880 thread_plan_sp,
false);
4913 "Process::RunThreadPlan(): Resuming thread %u - 0x%4.4" PRIx64
4914 " to run thread plan \"%s\".",
4915 thread_idx_id, expr_thread_id, s.
GetData());
4922 bool before_first_timeout =
true;
4924 bool do_resume =
true;
4925 bool handle_running_event =
true;
4928 uint32_t num_resumes = 0;
4934 before_first_timeout =
false;
4936 LLDB_LOGF(log,
"Stop others: %u, try all: %u, before_first: %u.\n",
4938 before_first_timeout);
4945 Event *other_events = listener_sp->PeekAtNextEvent();
4946 if (other_events !=
nullptr) {
4949 "RunThreadPlan called with pending events on the queue.");
4962#ifdef LLDB_RUN_THREAD_HALT_WITH_EVENT
4970 bool miss_first_event =
true;
4978 "Top of while loop: do_resume: %i handle_running_event: %i "
4979 "before_first_timeout: %i.",
4980 do_resume, handle_running_event, before_first_timeout);
4982 if (do_resume || handle_running_event) {
4989 if (!resume_error.
Success()) {
4990 diagnostic_manager.
Printf(
4992 "couldn't resume inferior the %d time: \"%s\".", num_resumes,
5003 "Process::RunThreadPlan(): didn't get any event after "
5004 "resume %" PRIu32
", exiting.",
5008 "didn't get any event after resume %" PRIu32
5019 bool restarted =
false;
5026 "Process::RunThreadPlan(): didn't get running event after "
5027 "resume %d, got %s instead (restarted: %i, do_resume: %i, "
5028 "handle_running_event: %i).",
5030 handle_running_event);
5037 const bool clear_thread_plans =
false;
5038 const bool use_run_lock =
false;
5039 Halt(clear_thread_plans, use_run_lock);
5042 diagnostic_manager.
Printf(
5044 "didn't get running event after initial resume, got %s instead.",
5051 log->
PutCString(
"Process::RunThreadPlan(): resuming succeeded.");
5059 log->
PutCString(
"Process::RunThreadPlan(): waiting for next event.");
5063 handle_running_event =
true;
5072 auto now = system_clock::now();
5074 "Process::RunThreadPlan(): about to wait - now is %s - "
5076 llvm::to_string(now).c_str(),
5077 llvm::to_string(now + *timeout).c_str());
5079 LLDB_LOGF(log,
"Process::RunThreadPlan(): about to wait forever.");
5083#ifdef LLDB_RUN_THREAD_HALT_WITH_EVENT
5085 if (miss_first_event) {
5086 std::this_thread::sleep_for(std::chrono::milliseconds(1));
5087 miss_first_event =
false;
5091 got_event = listener_sp->GetEvent(event_sp, timeout);
5095 bool keep_going =
false;
5097 const bool clear_thread_plans =
false;
5098 const bool use_run_lock =
false;
5099 Halt(clear_thread_plans, use_run_lock);
5102 "execution halted by user interrupt.");
5103 LLDB_LOGF(log,
"Process::RunThreadPlan(): Got interrupted by "
5104 "eBroadcastBitInterrupted, exiting.");
5110 "Process::RunThreadPlan(): in while loop, got event: %s.",
5113 switch (stop_state) {
5119 LLDB_LOGF(log,
"Process::RunThreadPlan(): Got a stop and "
5120 "restart, so we'll continue waiting.");
5123 handle_running_event =
true;
5125 const bool handle_interrupts =
true;
5127 expr_thread_id, thread_plan_sp, thread_plan_restorer,
5128 event_sp, event_to_broadcast_sp, options,
5141 handle_running_event =
false;
5146 "Process::RunThreadPlan(): execution stopped with "
5147 "unexpected state: %s.",
5151 event_to_broadcast_sp = event_sp;
5155 "execution stopped with unexpected state.");
5167 log->
PutCString(
"Process::RunThreadPlan(): got_event was true, but "
5168 "the event pointer was null. How odd...");
5180 if (before_first_timeout) {
5182 "Running function with one thread timeout timed out.");
5184 LLDB_LOG(log,
"Restarting function with all threads enabled and "
5185 "timeout: {0} timed out, abandoning execution.",
5188 LLDB_LOG(log,
"Running function with timeout: {0} timed out, "
5189 "abandoning execution.",
5202 bool back_to_top =
true;
5203 uint32_t try_halt_again = 0;
5204 bool do_halt =
true;
5205 const uint32_t num_retries = 5;
5206 while (try_halt_again < num_retries) {
5209 LLDB_LOGF(log,
"Process::RunThreadPlan(): Running Halt.");
5210 const bool clear_thread_plans =
false;
5211 const bool use_run_lock =
false;
5212 Halt(clear_thread_plans, use_run_lock);
5216 log->
PutCString(
"Process::RunThreadPlan(): Halt succeeded.");
5226 "Process::RunThreadPlan(): Stopped with event: %s",
5231 log->
PutCString(
" Event was the Halt interruption event.");
5238 log->
PutCString(
"Process::RunThreadPlan(): Went to halt "
5239 "but got a restarted event, there must be "
5240 "an un-restarted stopped event so try "
5242 "Exiting wait loop.");
5251 const bool handle_interrupts =
false;
5253 expr_thread_id, thread_plan_sp, thread_plan_restorer,
5254 event_sp, event_to_broadcast_sp, options,
5255 handle_interrupts)) {
5256 return_value = *result;
5257 back_to_top =
false;
5263 log->
PutCString(
"Process::RunThreadPlan(): try_all_threads "
5264 "was false, we stopped so now we're "
5267 back_to_top =
false;
5271 if (before_first_timeout) {
5274 before_first_timeout =
false;
5275 thread_plan_sp->SetStopOthers(
false);
5278 "Process::RunThreadPlan(): about to resume.");
5285 log->
PutCString(
"Process::RunThreadPlan(): running all "
5286 "threads timed out.");
5288 back_to_top =
false;
5294 log->
PutCString(
"Process::RunThreadPlan(): halt said it "
5295 "succeeded, but I got no event. "
5296 "I'm getting out of here passing Interrupted.");
5298 back_to_top =
false;
5307 if (!back_to_top || try_halt_again > num_retries)
5316 if (backup_private_state_thread.
IsJoinable()) {
5320 if (stopper_base_plan_sp) {
5331 return return_value;
5337 s.
PutCString(
"Thread state after unsuccessful completion: \n");
5351 thread_plan_sp->RestoreThreadState();
5362 log->
PutCString(
"Process::RunThreadPlan(): Stop event that "
5363 "interrupted us is NULL.");
5368 const char *event_explanation =
nullptr;
5372 event_explanation =
"<no event>";
5375 event_explanation =
"<user interrupt>";
5383 event_explanation =
"<no event data>";
5390 event_explanation =
"<no process>";
5396 uint32_t num_threads = thread_list.
GetSize();
5397 uint32_t thread_index;
5399 ts.
Printf(
"<%u threads> ", num_threads);
5401 for (thread_index = 0; thread_index < num_threads; ++thread_index) {
5413 if (register_context)
5414 ts.
Printf(
"[ip 0x%" PRIx64
"] ", register_context->
GetPC());
5416 ts.
Printf(
"[ip unknown] ");
5422 const char *stop_desc = stop_info_sp->GetDescription();
5429 event_explanation = ts.
GetData();
5433 if (event_explanation)
5435 "Process::RunThreadPlan(): execution interrupted: %s %s",
5436 s.
GetData(), event_explanation);
5438 LLDB_LOGF(log,
"Process::RunThreadPlan(): execution interrupted: %s",
5442 if (should_unwind) {
5444 "Process::RunThreadPlan: ExecutionInterrupted - "
5445 "discarding thread plans up to %p.",
5446 static_cast<void *
>(thread_plan_sp.get()));
5450 "Process::RunThreadPlan: ExecutionInterrupted - for "
5451 "plan: %p not discarding.",
5452 static_cast<void *
>(thread_plan_sp.get()));
5456 log->
PutCString(
"Process::RunThreadPlan(): execution set up error.");
5464 log->
PutCString(
"Process::RunThreadPlan(): thread plan is done");
5469 "Process::RunThreadPlan(): thread plan was discarded");
5474 "Process::RunThreadPlan(): thread plan stopped in mid course");
5477 log->
PutCString(
"Process::RunThreadPlan(): discarding thread plan "
5478 "'cause unwind_on_error is set.");
5496 if (
GetThreadList().SetSelectedThreadByIndexID(selected_tid) &&
5497 selected_stack_id.
IsValid()) {
5499 std::lock_guard<std::recursive_mutex> guard(
GetThreadList().GetMutex());
5505 old_frame_sp.get());
5512 if (event_to_broadcast_sp) {
5514 log->
PutCString(
"Process::RunThreadPlan(): rebroadcasting event.");
5518 return return_value;
5522 const char *result_name =
"<unknown>";
5526 result_name =
"eExpressionCompleted";
5529 result_name =
"eExpressionDiscarded";
5532 result_name =
"eExpressionInterrupted";
5535 result_name =
"eExpressionHitBreakpoint";
5538 result_name =
"eExpressionSetupError";
5541 result_name =
"eExpressionParseError";
5544 result_name =
"eExpressionResultUnavailable";
5547 result_name =
"eExpressionTimedOut";
5550 result_name =
"eExpressionStoppedForDebug";
5553 result_name =
"eExpressionThreadVanished";
5564 strm.
Printf(
"Process %" PRIu64
" exited with status = %i (0x%8.8x) %s\n",
5565 GetID(), exit_status, exit_status,
5566 exit_description ? exit_description :
"");
5569 strm.
Printf(
"Connected to remote target.\n");
5574 strm.
Printf(
"Process %" PRIu64
" is running.\n",
GetID());
5579 bool only_threads_with_stop_reason,
5580 uint32_t start_frame, uint32_t num_frames,
5581 uint32_t num_frames_with_source,
5583 size_t num_thread_infos_dumped = 0;
5590 uint32_t num_threads;
5591 std::vector<lldb::tid_t> thread_id_array;
5594 std::lock_guard<std::recursive_mutex> guard(
GetThreadList().GetMutex());
5596 num_threads = curr_thread_list.
GetSize();
5598 thread_id_array.resize(num_threads);
5599 for (idx = 0; idx < num_threads; ++idx)
5603 for (uint32_t i = 0; i < num_threads; i++) {
5606 if (only_threads_with_stop_reason) {
5607 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
5608 if (!stop_info_sp || !stop_info_sp->IsValid())
5611 thread_sp->GetStatus(strm, start_frame, num_frames,
5612 num_frames_with_source,
5614 ++num_thread_infos_dumped;
5617 LLDB_LOGF(log,
"Process::GetThreadStatus - thread 0x" PRIu64
5618 " vanished while running Thread::GetStatus.");
5621 return num_thread_infos_dumped;
5645 result = this_result;
5717 "Setting Process code address mask to {0:x}", code_address_mask);
5723 "Setting Process data address mask to {0:x}", data_address_mask);
5729 "Setting Process highmem code address mask to {0:x}",
5736 "Setting Process highmem data address mask to {0:x}",
5743 addr = abi_sp->FixCodeAddress(addr);
5749 addr = abi_sp->FixDataAddress(addr);
5755 addr = abi_sp->FixAnyAddress(addr);
5761 LLDB_LOGF(log,
"Process::%s()", __FUNCTION__);
5796 if (address ==
nullptr) {
5797 error.SetErrorString(
"Invalid address argument");
5804 std::map<addr_t, addr_t>::const_iterator iter =
5807 function_addr = (*iter).second;
5811 error.SetErrorStringWithFormat(
5812 "Unable to call resolver for indirect function %s",
5817 function_addr = abi_sp->FixCodeAddress(function_addr);
5819 std::pair<addr_t, addr_t>(addr, function_addr));
5822 return function_addr;
5838 runtime.second->ModulesDidLoad(module_list);
5844 runtime->ModulesDidLoad(module_list);
5855 pair.second->ModulesDidLoad(*
this, module_list);
5877 if (plugins[language])
5879 sc.
module_sp->ReportWarningUnsupportedLanguage(
5890 return platform_sp->GetProcessInfo(
GetID(), info);
5899 if (!memory_history) {
5903 threads = std::make_shared<ThreadCollection>(
5904 memory_history->GetHistoryThreads(addr));
5911 InstrumentationRuntimeCollection::iterator pos;
5916 return (*pos).second;
5921 module_spec.
Clear();
5948 Address retval = default_stop_addr;
5952 if (!default_stop_addr.
IsValid())
5955 const char *plugin_name =
nullptr;
5956 const char *flavor =
nullptr;
5959 if (disassembler_sp)
5960 insn_list = &disassembler_sp->GetInstructionList();
5962 if (insn_list ==
nullptr) {
5966 size_t insn_offset =
5973 insn_offset,
false ,
nullptr);
5978 if (branch_index > insn_offset) {
5979 Address next_branch_insn_address =
5981 if (next_branch_insn_address.
IsValid() &&
5983 retval = next_branch_insn_address;
5993 load_addr = abi->FixAnyAddress(load_addr);
6003 region_list.clear();
6009 region_list.clear();
6020 region_list.push_back(std::move(region_info));
6028 !(abi && (abi->FixAnyAddress(range_end) != range_end)));
6039 return Status(
"unimplemented");
6047 if (supported_type_names.
GetSize() == 0) {
6048 LLDB_LOG(log,
"no structured data types supported");
6053 std::set<llvm::StringRef> type_names;
6056 "the process supports the following async structured data types:");
6065 const llvm::StringRef type_name =
object->GetStringValue();
6066 if (type_name.empty())
6069 type_names.insert(type_name);
6079 for (uint32_t plugin_index = 0; !type_names.empty(); plugin_index++) {
6080 auto create_instance =
6083 if (!create_instance)
6095 std::vector<llvm::StringRef> names_to_remove;
6096 for (llvm::StringRef type_name : type_names) {
6097 if (plugin_sp->SupportsStructuredDataType(type_name)) {
6099 std::make_pair(type_name, plugin_sp));
6100 names_to_remove.push_back(type_name);
6101 LLDB_LOG(log,
"using plugin {0} for type name {1}",
6102 plugin_sp->GetPluginName(), type_name);
6107 for (llvm::StringRef type_name : names_to_remove)
6108 type_names.erase(type_name);
6125 llvm::StringRef type_name;
6137 find_it->second->HandleArrivalOfStructuredData(*
this, type_name, object_sp);
6149 llvm::function_ref<std::unique_ptr<UtilityFunction>()> factory) {
6150 if (platform !=
GetTarget().GetPlatform().get())
6159 return llvm::createStringError(llvm::inconvertibleErrorCode(),
6160 "Can't trace a non-live process.");
6161 return llvm::make_error<UnimplementedError>();
6166 bool trap_exceptions) {
6168 if (thread ==
nullptr || address ==
nullptr)
6180 auto type_system_or_err =
6182 if (!type_system_or_err) {
6183 llvm::consumeError(type_system_or_err.takeError());
6186 auto ts = *type_system_or_err;
6192 *thread, *address, void_ptr_type, llvm::ArrayRef<addr_t>(), options));
6204 call_plan_sp->GetReturnValueObject()->GetValueAsUnsigned(
6226 if (!arch || !tag_manager) {
6227 return llvm::createStringError(
6228 llvm::inconvertibleErrorCode(),
6229 "This architecture does not support memory tagging");
6233 return llvm::createStringError(llvm::inconvertibleErrorCode(),
6234 "Process does not support memory tagging");
6240llvm::Expected<std::vector<lldb::addr_t>>
6242 llvm::Expected<const MemoryTagManager *> tag_manager_or_err =
6244 if (!tag_manager_or_err)
6245 return tag_manager_or_err.takeError();
6248 llvm::Expected<std::vector<uint8_t>> tag_data =
6251 return tag_data.takeError();
6258 const std::vector<lldb::addr_t> &tags) {
6259 llvm::Expected<const MemoryTagManager *> tag_manager_or_err =
6261 if (!tag_manager_or_err)
6262 return Status(tag_manager_or_err.takeError());
6265 llvm::Expected<std::vector<uint8_t>> packed_tags =
6268 return Status(packed_tags.takeError());
6289 if (!dirty_page_list)
6295 llvm::AddressRange range(0, 0);
6296 for (
addr_t page_addr : *dirty_page_list) {
6297 if (range.empty()) {
6299 range = llvm::AddressRange(page_addr, page_addr + page_size);
6301 if (range.end() == page_addr) {
6303 range = llvm::AddressRange(range.start(), page_addr + page_size);
6307 ranges.push_back({range, lldb_permissions});
6308 range = llvm::AddressRange(page_addr, page_addr + page_size);
6314 ranges.push_back({range, lldb_permissions});
6342const bool try_dirty_pages =
false;
6343 for (
const auto ®ion : regions)
6344 AddRegion(region, try_dirty_pages, ranges);
6356 bool have_dirty_page_info =
false;
6357 for (
const auto ®ion : regions) {
6359 have_dirty_page_info =
true;
6362 if (!have_dirty_page_info) {
6365 const bool try_dirty_pages =
false;
6366 for (
const auto ®ion : regions)
6368 AddRegion(region, try_dirty_pages, ranges);
6388 std::set<addr_t> stack_bases;
6390 const bool try_dirty_pages =
true;
6391 for (
const auto ®ion : regions) {
6393 stack_bases.insert(region.GetRange().GetRangeBase());
6394 AddRegion(region, try_dirty_pages, ranges);
6403 StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(0);
6409 const addr_t sp = reg_ctx_sp->GetSP();
6415 AddRegion(sp_region, try_dirty_pages, ranges);
6426 if (regions.empty())
6427 return Status(
"failed to get any valid memory regions from the process");
6429 switch (core_style) {
6431 err =
Status(
"callers must set the core_style to something other than "
6432 "eSaveCoreUnspecified");
6452 return Status(
"no valid address ranges found for core style");
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
static std::optional< ExpressionResults > HandleStoppedEvent(lldb::tid_t thread_id, const ThreadPlanSP &thread_plan_sp, RestorePlanState &restorer, const EventSP &event_sp, EventSP &event_to_broadcast_sp, const EvaluateExpressionOptions &options, bool handle_interrupts)
static void GetCoreFileSaveRangesFull(Process &process, const MemoryRegionInfos ®ions, Process::CoreFileMemoryRanges &ranges)
static void GetCoreFileSaveRangesStackOnly(Process &process, const MemoryRegionInfos ®ions, Process::CoreFileMemoryRanges &ranges)
static constexpr OptionEnumValueElement g_follow_fork_mode_values[]
static void GetCoreFileSaveRangesDirtyOnly(Process &process, const MemoryRegionInfos ®ions, Process::CoreFileMemoryRanges &ranges)
static Timeout< std::micro > GetExpressionTimeout(const EvaluateExpressionOptions &options, bool before_first_timeout)
static microseconds GetOneThreadExpressionTimeout(const EvaluateExpressionOptions &options)
static Process::CoreFileMemoryRange CreateCoreFileMemoryRange(const MemoryRegionInfo ®ion)
static void AddRegion(const MemoryRegionInfo ®ion, bool try_dirty_pages, Process::CoreFileMemoryRanges &ranges)
static bool AddDirtyPages(const MemoryRegionInfo ®ion, Process::CoreFileMemoryRanges &ranges)
#define LLDB_SCOPED_TIMER()
void SetIsRunning(bool running)
~IOHandlerProcessSTDIO() override=default
bool Interrupt() override
IOHandlerProcessSTDIO(Process *process, int write_fd)
A windows-based implementation of Pipe, a class that abtracts unix style pipes.
ProcessExperimentalOptionValueProperties()
const Property * GetPropertyAtIndex(size_t idx, const ExecutionContext *exe_ctx) const override
ProcessOptionValueProperties(llvm::StringRef name)
lldb_private::Status Select()
void FDSetRead(lldb::socket_t fd)
bool FDIsSetRead(lldb::socket_t fd) const
static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch)
A section + offset based address range class.
bool ContainsFileAddress(const Address &so_addr) const
Check if a section offset address is contained in this range.
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
lldb::addr_t GetOpcodeLoadAddress(Target *target, AddressClass addr_class=AddressClass::eInvalid) const
Get the load address as an opcode load address.
bool IsValid() const
Check if the object state is valid.
Symbol * CalculateSymbolContextSymbol() const
static lldb::addr_t AddressableBitToMask(uint32_t addressable_bits)
lldb::addr_t AllocateMemory(size_t byte_size, uint32_t permissions, Status &error)
void Clear(bool deallocate_memory)
bool DeallocateMemory(lldb::addr_t ptr)
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
bool IsExactMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, ExactMatch).
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
virtual const MemoryTagManager * GetMemoryTagManager() const
A command line argument class.
Class that manages the actual breakpoint that will be inserted into the running program.
BreakpointSite::Type GetType() const
void SetType(BreakpointSite::Type type)
bool IntersectsRange(lldb::addr_t addr, size_t size, lldb::addr_t *intersect_addr, size_t *intersect_size, size_t *opcode_offset) const
Says whether addr and size size intersects with the address intersect_addr.
uint8_t * GetTrapOpcodeBytes()
Returns the Opcode Bytes for this breakpoint.
uint8_t * GetSavedOpcodeBytes()
Gets the original instruction bytes that were overwritten by the trap.
bool IsHardware() const override
bool IsEnabled() const
Tells whether the current breakpoint site is enabled or not.
void SetEnabled(bool enabled)
Sets whether the current breakpoint site is enabled or not.
An event broadcasting class.
lldb::ListenerSP GetPrimaryListener()
void RestoreBroadcaster()
Restore the state of the Broadcaster from a previous hijack attempt.
void SetEventName(uint32_t event_mask, const char *name)
Set the name for an event bit.
bool HijackBroadcaster(const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX)
Provides a simple mechanism to temporarily redirect events from broadcaster.
void BroadcastEventIfUnique(lldb::EventSP &event_sp)
void SetPrimaryListener(lldb::ListenerSP listener_sp)
const char * GetHijackingListenerName()
void BroadcastEvent(lldb::EventSP &event_sp)
Broadcast an event which has no associated data.
bool IsHijackedForEvent(uint32_t event_mask)
void CheckInWithManager()
A class that implements CRTP-based "virtual constructor" idiom.
bool IsConnected() const
Check if the connection is valid.
Generic representation of a type in a programming language.
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const
Create related types using the current type's AST.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
A class to manage flag bits.
static lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid)
StreamFile & GetErrorStream()
TargetList & GetTargetList()
Get accessor for the target list.
bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp)
bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp)
Remove the given IO handler if it's currently active.
void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Run the given IO handler and return immediately.
lldb::StreamSP GetAsyncErrorStream()
PlatformList & GetPlatformList()
lldb::ListenerSP GetListener()
size_t Printf(DiagnosticSeverity severity, const char *format,...) __attribute__((format(printf
size_t void PutString(DiagnosticSeverity severity, llvm::StringRef str)
static lldb::DisassemblerSP DisassembleRange(const ArchSpec &arch, const char *plugin_name, const char *flavor, Target &target, const AddressRange &disasm_range, bool force_live_memory=false)
Encapsulates dynamic check functions used by expressions.
A plug-in interface definition class for dynamic loaders.
virtual void DidAttach()=0
Called after attaching a process.
virtual void DidLaunch()=0
Called after launching a process.
static DynamicLoader * FindPlugin(Process *process, llvm::StringRef plugin_name)
Find a dynamic loader plugin for a given process.
void SetUnwindOnError(bool unwind=false)
bool GetStopOthers() const
bool DoesIgnoreBreakpoints() const
bool IsForUtilityExpr() const
bool GetTryAllThreads() const
void SetTrapExceptions(bool b)
void SetTryAllThreads(bool try_others=true)
void SetTimeout(const Timeout< std::micro > &timeout)
void SetStopOthers(bool stop_others=true)
bool DoesUnwindOnError() const
const Timeout< std::micro > & GetTimeout() const
void SetIgnoreBreakpoints(bool ignore=false)
const Timeout< std::micro > & GetOneThreadTimeout() const
virtual llvm::StringRef GetFlavor() const =0
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void SetFrameSP(const lldb::StackFrameSP &frame_sp)
Set accessor to set only the frame shared pointer.
void SetProcessPtr(Process *process)
Set accessor to set only the process shared pointer from a process pointer.
void SetThreadPtr(Thread *thread)
Set accessor to set only the thread shared pointer from a thread pointer.
void SetTargetPtr(Target *target)
Set accessor to set only the target shared pointer from a target pointer.
void SetFramePtr(StackFrame *frame)
Set accessor to set only the frame shared pointer from a frame pointer.
Process * GetProcessPtr() const
Returns a pointer to the process object.
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
static FileSystem & Instance()
An abstract base class for files.
bool Test(ValueType bit) const
Test a single flag bit.
bool GetIsOptimized()
Get whether compiler optimizations were enabled for this function.
Status Join(lldb::thread_result_t *result)
bool EqualsThread(lldb::thread_t thread) const
static lldb::thread_t GetCurrentThread()
Get the thread token (the one returned by ThreadCreate when the thread was created) for the calling t...
uint32_t GetIndexOfInstructionAtAddress(const Address &addr)
lldb::InstructionSP GetInstructionAtIndex(size_t idx) const
uint32_t GetIndexOfNextBranchInstruction(uint32_t start, bool ignore_calls, bool *found_calls) const
Get the index of the next branch instruction.
static void ModulesDidLoad(lldb_private::ModuleList &module_list, Process *process, InstrumentationRuntimeCollection &runtimes)
Class used by the Process to hold a list of its JITLoaders.
void ModulesDidLoad(ModuleList &module_list)
static void LoadPlugins(Process *process, lldb_private::JITLoaderList &list)
Find a JIT loader plugin for a given process.
virtual lldb::LanguageType GetLanguageType() const =0
static LanguageRuntime * FindPlugin(Process *process, lldb::LanguageType language)
virtual bool CouldHaveDynamicValue(ValueObject &in_value)=0
static lldb::LanguageType GetPrimaryLanguage(lldb::LanguageType language)
static std::set< lldb::LanguageType > GetSupportedLanguages()
static lldb::ListenerSP MakeListener(const char *name)
void PutCString(const char *cstr)
void PutString(llvm::StringRef str)
uint32_t GetMemoryCacheLineSize() const
bool RemoveInvalidRange(lldb::addr_t base_addr, lldb::addr_t byte_size)
void Flush(lldb::addr_t addr, size_t size)
void Clear(bool clear_invalid_ranges=false)
size_t Read(lldb::addr_t addr, void *dst, size_t dst_len, Status &error)
void AddInvalidRange(lldb::addr_t base_addr, lldb::addr_t byte_size)
static lldb::MemoryHistorySP FindPlugin(const lldb::ProcessSP process)
OptionalBool GetWritable() const
OptionalBool GetMapped() const
int GetPageSize() const
Get the target system's VM page size in bytes.
uint32_t GetLLDBPermissions() const
const std::optional< std::vector< lldb::addr_t > > & GetDirtyPageList() const
Get a vector of target VM pages that are dirty – that have been modified – within this memory region.
OptionalBool GetReadable() const
OptionalBool GetExecutable() const
virtual llvm::Expected< std::vector< lldb::addr_t > > UnpackTagsData(const std::vector< uint8_t > &tags, size_t granules=0) const =0
virtual lldb::addr_t GetGranuleSize() const =0
virtual llvm::Expected< std::vector< uint8_t > > PackTags(const std::vector< lldb::addr_t > &tags) const =0
virtual int32_t GetAllocationTagType() const =0
A collection class for Module objects.
A class that describes an executable image and its associated object and symbol files.
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
A plug-in interface definition class for object file parsers.
A plug-in interface definition class for halted OS helpers.
virtual lldb::ThreadSP CreateThread(lldb::tid_t tid, lldb::addr_t context)
static OperatingSystem * FindPlugin(Process *process, const char *plugin_name)
Find a halted OS plugin for a given process.
virtual bool UpdateThreadList(ThreadList &old_thread_list, ThreadList &real_thread_list, ThreadList &new_thread_list)=0
auto GetPropertyAtIndexAs(size_t idx, const ExecutionContext *exe_ctx=nullptr) const
Property * ProtectedGetPropertyAtIndex(size_t idx)
bool SetPropertyAtIndex(size_t idx, T t, const ExecutionContext *exe_ctx=nullptr) const
static lldb::OptionValuePropertiesSP CreateLocalCopy(const Properties &global_properties)
virtual llvm::StringRef GetPluginName()=0
static ProcessCreateInstance GetProcessCreateCallbackAtIndex(uint32_t idx)
static ProcessCreateInstance GetProcessCreateCallbackForPluginName(llvm::StringRef name)
static StructuredDataPluginCreateInstance GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx)
static LanguageSet GetAllTypeSystemSupportedLanguagesForTypes()
void SetValue(T value, PredicateBroadcastType broadcast_type)
Value set accessor.
T GetValue() const
Value get accessor.
std::optional< T > WaitForValueNotEqualTo(T value, const Timeout< std::micro > &timeout=std::nullopt)
Wait for m_value to not be equal to value.
uint32_t GetResumeCount() const
lldb::ListenerSP GetListenerForProcess(Debugger &debugger)
bool GetWaitForLaunch() const
ProcessExperimentalProperties()
lldb::pid_t GetProcessID() const
FileSpec & GetExecutableFile()
bool IsScriptedProcess() const
ArchSpec & GetArchitecture()
void SetNameMatchType(NameMatch name_match_type)
ProcessInstanceInfo & GetProcessInfo()
static void DumpTableHeader(Stream &s, bool show_args, bool verbose)
void SetRunningUserExpression(bool on)
uint32_t GetMemoryID() const
void SetStopEventForLastNaturalStopID(lldb::EventSP event_sp)
uint32_t GetStopID() const
bool IsRunningUtilityFunction() const
bool IsLastResumeForUserExpression() const
void SetRunningUtilityFunction(bool on)
bool GetDetachKeepsStopped() const
bool GetSteppingRunsAllThreads() const
void SetStopOnSharedLibraryEvents(bool stop)
Args GetExtraStartupCommands() const
std::unique_ptr< ProcessExperimentalProperties > m_experimental_properties_up
FollowForkMode GetFollowForkMode() const
uint32_t GetVirtualAddressableBits() const
~ProcessProperties() override
void SetIgnoreBreakpointsInExpressions(bool ignore)
bool GetUnwindOnErrorInExpressions() const
std::chrono::seconds GetInterruptTimeout() const
bool GetDisableLangRuntimeUnwindPlans() const
void SetDetachKeepsStopped(bool keep_stopped)
void SetDisableLangRuntimeUnwindPlans(bool disable)
std::chrono::seconds GetUtilityExpressionTimeout() const
void SetVirtualAddressableBits(uint32_t bits)
bool GetStopOnSharedLibraryEvents() const
void SetHighmemVirtualAddressableBits(uint32_t bits)
void SetOSPluginReportsAllThreads(bool does_report)
bool GetWarningsOptimization() const
void SetUnwindOnErrorInExpressions(bool ignore)
bool GetDisableMemoryCache() const
FileSpec GetPythonOSPluginPath() const
bool GetStopOnExec() const
void SetPythonOSPluginPath(const FileSpec &file)
void SetExtraStartupCommands(const Args &args)
bool GetOSPluginReportsAllThreads() const
bool GetWarningsUnsupportedLanguage() const
uint32_t GetHighmemVirtualAddressableBits() const
bool GetIgnoreBreakpointsInExpressions() const
uint64_t GetMemoryCacheLineSize() const
ProcessProperties(lldb_private::Process *process)
A class used to prevent the process from starting while other threads are accessing its data,...
EventActionResult HandleBeingInterrupted() override
const char * GetExitString() override
EventActionResult PerformAction(lldb::EventSP &event_sp) override
AttachCompletionHandler(Process *process, uint32_t exec_count)
lldb::ProcessWP m_process_wp
static bool GetRestartedFromEvent(const Event *event_ptr)
virtual bool ShouldStop(Event *event_ptr, bool &found_valid_stopinfo)
void SetUpdateStateOnRemoval()
static void AddRestartedReason(Event *event_ptr, const char *reason)
void SetInterrupted(bool new_value)
lldb::ProcessSP GetProcessSP() const
void SetRestarted(bool new_value)
static void SetRestartedInEvent(Event *event_ptr, bool new_value)
static lldb::ProcessSP GetProcessFromEvent(const Event *event_ptr)
static void SetInterruptedInEvent(Event *event_ptr, bool new_value)
llvm::StringRef GetFlavor() const override
~ProcessEventData() override
bool GetInterrupted() const
bool GetRestarted() const
size_t GetNumRestartedReasons()
static bool GetInterruptedFromEvent(const Event *event_ptr)
const char * GetRestartedReasonAtIndex(size_t idx)
static bool SetUpdateStateOnRemoval(Event *event_ptr)
static lldb::StateType GetStateFromEvent(const Event *event_ptr)
lldb::StateType GetState() const
static const Process::ProcessEventData * GetEventDataFromEvent(const Event *event_ptr)
static llvm::StringRef GetFlavorString()
void DoOnRemoval(Event *event_ptr) override
void Dump(Stream *s) const override
A plug-in interface definition class for debugging a process.
virtual Status EnableBreakpointSite(BreakpointSite *bp_site)
Status WillAttachToProcessWithName(const char *process_name, bool wait_for_launch)
Called before attaching to a process.
virtual llvm::Expected< TraceSupportedResponse > TraceSupported()
Get the processor tracing type supported for this process.
lldb::IOHandlerSP m_process_input_reader
friend class ProcessProperties
UtilityFunction * GetLoadImageUtilityFunction(Platform *platform, llvm::function_ref< std::unique_ptr< UtilityFunction >()> factory)
Get the cached UtilityFunction that assists in loading binary images into the process.
virtual Status DoSignal(int signal)
Sends a process a UNIX signal signal.
virtual Status WillResume()
Called before resuming to a process.
std::mutex m_process_input_reader_mutex
lldb::addr_t m_code_address_mask
Mask for code an data addresses.
StopPointSiteList< lldb_private::BreakpointSite > & GetBreakpointSiteList()
std::vector< lldb::addr_t > m_image_tokens
bool PrivateStateThreadIsValid() const
virtual Status DoHalt(bool &caused_stop)
Halts a running process.
virtual void DidLaunch()
Called after launching a process.
virtual Status DisableSoftwareBreakpoint(BreakpointSite *bp_site)
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
lldb::break_id_t CreateBreakpointSite(const lldb::BreakpointLocationSP &owner, bool use_hardware)
virtual Status WillSignal()
Called before sending a signal to a process.
void ResetImageToken(size_t token)
lldb::JITLoaderListUP m_jit_loaders_up
lldb::addr_t CallocateMemory(size_t size, uint32_t permissions, Status &error)
The public interface to allocating memory in the process, this also clears the allocated memory.
void SetNextEventAction(Process::NextEventAction *next_event_action)
Status Destroy(bool force_kill)
Kills the process and shuts down all threads that were spawned to track and monitor the process.
virtual Status WillDetach()
Called before detaching from a process.
virtual Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info)
Launch a new process.
StopPointSiteList< lldb_private::BreakpointSite > m_breakpoint_site_list
This is the list of breakpoint locations we intend to insert in the target.
void ControlPrivateStateThread(uint32_t signal)
ThreadList & GetThreadList()
void ClearPreResumeActions()
virtual DataExtractor GetAuxvData()
Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
Construct with a shared pointer to a target, and the Process listener.
lldb::ExpressionResults RunThreadPlan(ExecutionContext &exe_ctx, lldb::ThreadPlanSP &thread_plan_sp, const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager)
void PrintWarningUnsupportedLanguage(const SymbolContext &sc)
Print a user-visible warning about a function written in a language that this version of LLDB doesn't...
lldb::StateType GetPrivateState()
Status LaunchPrivate(ProcessLaunchInfo &launch_info, lldb::StateType &state, lldb::EventSP &event_sp)
std::vector< std::string > m_profile_data
bool m_can_interpret_function_calls
Status Resume()
Resumes all of a process's threads as configured using the Thread run control functions.
void PruneThreadPlans()
Prune ThreadPlanStacks for all unreported threads.
void SetUnixSignals(lldb::UnixSignalsSP &&signals_sp)
std::string m_stdout_data
Remember if stdin must be forwarded to remote debug server.
bool RemoveInvalidMemoryRange(const LoadRange ®ion)
uint32_t GetNextThreadIndexID(uint64_t thread_id)
Status PrivateResume()
The "private" side of resuming a process.
void SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers)
enum lldb_private::Process::@32 m_can_jit
void AddInvalidMemoryRegion(const LoadRange ®ion)
virtual void ModulesDidLoad(ModuleList &module_list)
InstrumentationRuntimeCollection m_instrumentation_runtimes
std::atomic< bool > m_destructing
virtual Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has removed non address bits from loa...
int GetExitStatus()
Get the exit status for a process.
OperatingSystem * GetOperatingSystem()
Status WillAttachToProcessWithID(lldb::pid_t pid)
Called before attaching to a process.
virtual Status DoDetach(bool keep_stopped)
Detaches from a running or stopped process.
std::unique_ptr< UtilityFunction > m_dlopen_utility_func_up
void SetRunningUtilityFunction(bool on)
void DisableAllBreakpointSites()
int64_t ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, int64_t fail_value, Status &error)
Address AdvanceAddressToNextBranchInstruction(Address default_stop_addr, AddressRange range_bounds)
Find the next branch instruction to set a breakpoint on.
virtual bool GetLoadAddressPermissions(lldb::addr_t load_addr, uint32_t &permissions)
Attempt to get the attributes for a region of memory in the process.
static bool HandleProcessStateChangedEvent(const lldb::EventSP &event_sp, Stream *stream, SelectMostRelevant select_most_relevant, bool &pop_process_io_handler)
Centralize the code that handles and prints descriptions for process state changes.
virtual size_t GetAsyncProfileData(char *buf, size_t buf_size, Status &error)
Get any available profile data.
lldb::addr_t FixDataAddress(lldb::addr_t pc)
lldb::addr_t AllocateMemory(size_t size, uint32_t permissions, Status &error)
The public interface to allocating memory in the process.
std::unique_ptr< NextEventAction > m_next_event_action_up
void SetHighmemDataAddressMask(lldb::addr_t data_address_mask)
bool PruneThreadPlansForTID(lldb::tid_t tid)
Prune ThreadPlanStacks for unreported threads.
virtual void DidDetach()
Called after detaching from a process.
void PausePrivateStateThread()
HostThread m_private_state_thread
Thread ID for the thread that watches internal state events.
Status EnableBreakpointSiteByID(lldb::user_id_t break_id)
size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
size_t ReadScalarIntegerFromMemory(lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Status &error)
virtual Status Launch(ProcessLaunchInfo &launch_info)
Launch a new process.
std::mutex m_run_thread_plan_lock
static void SettingsInitialize()
void BroadcastStructuredData(const StructuredData::ObjectSP &object_sp, const lldb::StructuredDataPluginSP &plugin_sp)
Broadcasts the given structured data object from the given plugin.
void Flush()
Flush all data in the process.
bool m_clear_thread_plans_on_stop
virtual Status DoResume()
Resumes all of a process's threads as configured using the Thread run control functions.
ProcessRunLock m_public_run_lock
size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr, size_t cstr_max_len, Status &error)
Read a NULL terminated C string from memory.
void ResumePrivateStateThread()
void SendAsyncInterrupt()
void MapSupportedStructuredDataPlugins(const StructuredData::Array &supported_type_names)
Loads any plugins associated with asynchronous structured data and maps the relevant supported type n...
bool GetEventsPrivate(lldb::EventSP &event_sp, const Timeout< std::micro > &timeout, bool control_only)
lldb::ABISP m_abi_sp
This is the current signal set for this process.
virtual void DidSignal()
Called after sending a signal to a process.
virtual SystemRuntime * GetSystemRuntime()
Get the system runtime plug-in for this process.
std::map< uint64_t, uint32_t > m_thread_id_to_index_id_map
bool DumpThreadPlansForTID(Stream &strm, lldb::tid_t tid, lldb::DescriptionLevel desc_level, bool internal, bool condense_trivial, bool skip_unreported_plans)
Dump the thread plans associated with thread with tid.
lldb::ListenerSP m_private_state_listener_sp
uint32_t m_extended_thread_stop_id
The natural stop id when extended_thread_list was last updated.
static constexpr llvm::StringRef ResumeSynchronousHijackListenerName
bool WritePointerToMemory(lldb::addr_t vm_addr, lldb::addr_t ptr_value, Status &error)
QueueList m_queue_list
The list of libdispatch queues at a given stop point.
void ClearPreResumeAction(PreResumeActionCallback callback, void *baton)
virtual Status WillDestroy()
lldb::ThreadSP CreateOSPluginThread(lldb::tid_t tid, lldb::addr_t context)
std::vector< PreResumeCallbackAndBaton > m_pre_resume_actions
void SetCanJIT(bool can_jit)
Sets whether executing JIT-compiled code in this process is possible.
lldb::StateType GetStateChangedEventsPrivate(lldb::EventSP &event_sp, const Timeout< std::micro > &timeout)
void LoadOperatingSystemPlugin(bool flush)
lldb::StructuredDataPluginSP GetStructuredDataPlugin(llvm::StringRef type_name) const
Returns the StructuredDataPlugin associated with a given type name, if there is one.
lldb::DynamicLoaderUP m_dyld_up
virtual bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, ModuleSpec &module_spec)
Try to fetch the module specification for a module with the given file name and architecture.
virtual size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error)
Actually do the writing of memory to a process.
virtual Status WriteObjectFile(std::vector< ObjectFile::LoadableData > entries)
std::recursive_mutex m_stdio_communication_mutex
static lldb::ProcessSP FindPlugin(lldb::TargetSP target_sp, llvm::StringRef plugin_name, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
Find a Process plug-in that can debug module using the currently selected architecture.
StopPointSiteList< lldb_private::WatchpointResource > m_watchpoint_resource_list
Watchpoint resources currently in use.
Status DisableBreakpointSiteByID(lldb::user_id_t break_id)
llvm::Expected< const MemoryTagManager * > GetMemoryTagManager()
If this architecture and process supports memory tagging, return a tag manager that can be used to ma...
~Process() override
Destructor.
virtual Status DoWriteMemoryTags(lldb::addr_t addr, size_t len, int32_t type, const std::vector< uint8_t > &tags)
Does the final operation to write memory tags.
std::recursive_mutex m_profile_data_comm_mutex
lldb::InstrumentationRuntimeSP GetInstrumentationRuntime(lldb::InstrumentationRuntimeType type)
Status ResumeSynchronous(Stream *stream)
Resume a process, and wait for it to stop.
lldb::addr_t FixAnyAddress(lldb::addr_t pc)
Use this method when you do not know, or do not care what kind of address you are fixing.
lldb::thread_result_t RunPrivateStateThread(bool is_secondary_thread)
virtual Status DoWillLaunch(Module *module)
Called before launching to a process.
virtual Status ConnectRemote(llvm::StringRef remote_url)
Attach to a remote system via a URL.
void AppendSTDOUT(const char *s, size_t len)
llvm::StringMap< lldb::StructuredDataPluginSP > m_structured_data_plugin_map
virtual Status DisableBreakpointSite(BreakpointSite *bp_site)
size_t GetThreadStatus(Stream &ostrm, bool only_threads_with_stop_reason, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source, bool stop_format)
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Event * PeekAtStateChangedEvents()
std::vector< Notifications > m_notifications
The list of notifications that this process can deliver.
bool HasAssignedIndexIDToThread(uint64_t sb_thread_id)
ThreadSafeValue< lldb::StateType > m_private_state
void StopPrivateStateThread()
size_t AddImageToken(lldb::addr_t image_ptr)
virtual bool DestroyRequiresHalt()
lldb::EventSP CreateEventFromProcessState(uint32_t event_type)
lldb::TargetSP CalculateTarget() override
void SetHighmemCodeAddressMask(lldb::addr_t code_address_mask)
lldb::ByteOrder GetByteOrder() const
Status Detach(bool keep_stopped)
Detaches from a running or stopped process.
void UpdateThreadListIfNeeded()
virtual llvm::Expected< std::vector< lldb::addr_t > > ReadMemoryTags(lldb::addr_t addr, size_t len)
Read memory tags for the range addr to addr+len.
virtual void DidResume()
Called after resuming a process.
virtual void DidExec()
Called after a process re-execs itself.
void SetCodeAddressMask(lldb::addr_t code_address_mask)
AllocatedMemoryCache m_allocated_memory_cache
virtual Status LoadCore()
@ eBroadcastBitStructuredData
@ eBroadcastBitStateChanged
@ eBroadcastBitProfileData
std::mutex m_exit_status_mutex
Mutex so m_exit_status m_exit_string can be safely accessed from multiple threads.
Status Signal(int signal)
Sends a process a UNIX signal signal.
void SetDynamicLoader(lldb::DynamicLoaderUP dyld)
ThreadPlanStackMap m_thread_plans
This is the list of thread plans for threads in m_thread_list, as well as threads we knew existed,...
std::recursive_mutex m_thread_mutex
virtual Status ConfigureStructuredData(llvm::StringRef type_name, const StructuredData::ObjectSP &config_sp)
Configure asynchronous structured data feature.
virtual Status DoWillAttachToProcessWithName(const char *process_name, bool wait_for_launch)
Called before attaching to a process.
bool StartPrivateStateThread(bool is_secondary_thread=false)
void HandlePrivateEvent(lldb::EventSP &event_sp)
void BroadcastAsyncProfileData(const std::string &one_profile_data)
lldb::StateType GetState()
Get accessor for the current process state.
virtual Status DoWillAttachToProcessWithID(lldb::pid_t pid)
Called before attaching to a process.
ProcessRunLock & GetRunLock()
virtual Status DoLoadCore()
Predicate< uint32_t > m_iohandler_sync
LanguageRuntimeCollection m_language_runtimes
Should we detach if the process object goes away with an explicit call to Kill or Detach?
virtual Status GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list)
Obtain all the mapped memory regions within this process.
size_t WriteMemoryPrivate(lldb::addr_t addr, const void *buf, size_t size, Status &error)
void GetStatus(Stream &ostrm)
void SetRunningUserExpression(bool on)
bool IsPossibleDynamicValue(ValueObject &in_value)
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 ().
void RemoveConstituentFromBreakpointSite(lldb::user_id_t site_id, lldb::user_id_t constituent_id, lldb::BreakpointSiteSP &bp_site_sp)
lldb::OperatingSystemUP m_os_up
uint32_t GetLastNaturalStopID() const
lldb::StateType WaitForProcessToStop(const Timeout< std::micro > &timeout, lldb::EventSP *event_sp_ptr=nullptr, bool wait_always=true, lldb::ListenerSP hijack_listener=lldb::ListenerSP(), Stream *stream=nullptr, bool use_run_lock=true, SelectMostRelevant select_most_relevant=DoNoSelectMostRelevantFrame)
lldb::UnixSignalsSP m_unix_signals_sp
bool StateChangedIsHijackedForSynchronousResume()
const char * GetExitDescription()
Get a textual description of what the process exited.
void SetPublicState(lldb::StateType new_state, bool restarted)
void SetDataAddressMask(lldb::addr_t data_address_mask)
virtual Status DoConnectRemote(llvm::StringRef remote_url)
Attach to a remote system via a URL.
bool() PreResumeActionCallback(void *)
uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Status &error)
Reads an unsigned integer of the specified byte size from process memory.
llvm::once_flag m_dlopen_utility_func_flag_once
virtual void UpdateQueueListIfNeeded()
virtual Status UpdateAutomaticSignalFiltering()
virtual lldb::addr_t GetImageInfoAddress()
Get the image information address for the current process.
std::map< lldb::addr_t, lldb::addr_t > m_resolved_indirect_addresses
This helps with the Public event coalescing in ShouldBroadcastEvent.
virtual Status DoAttachToProcessWithID(lldb::pid_t pid, const ProcessAttachInfo &attach_info)
Attach to an existing process using a process ID.
void SetCanRunCode(bool can_run_code)
Sets whether executing code in this process is possible.
Status ClearBreakpointSiteByID(lldb::user_id_t break_id)
virtual Status EnableSoftwareBreakpoint(BreakpointSite *bp_site)
void AppendSTDERR(const char *s, size_t len)
bool GetShouldDetach() const
Status CalculateCoreFileSaveRanges(lldb::SaveCoreStyle core_style, CoreFileMemoryRanges &ranges)
Helper function for Process::SaveCore(...) that calculates the address ranges that should be saved.
uint32_t m_thread_index_id
Each thread is created with a 1 based index that won't get re-used.
bool ProcessIOHandlerExists() const
bool RouteAsyncStructuredData(const StructuredData::ObjectSP object_sp)
Route the incoming structured data dictionary to the right plugin.
virtual void DidDestroy()
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
static const char * ExecutionResultAsCString(lldb::ExpressionResults result)
Broadcaster m_private_state_control_broadcaster
lldb::addr_t GetHighmemCodeAddressMask()
The highmem masks are for targets where we may have different masks for low memory versus high memory...
bool PushProcessIOHandler()
size_t RemoveBreakpointOpcodesFromBuffer(lldb::addr_t addr, size_t size, uint8_t *buf) const
Broadcaster m_private_state_broadcaster
virtual bool DetachRequiresHalt()
virtual bool IsAlive()
Check if a process is still alive.
bool m_destroy_in_process
ThreadList m_thread_list_real
The threads for this process as are known to the protocol we are debugging with.
ThreadSafeValue< lldb::StateType > m_public_state
lldb::addr_t m_data_address_mask
virtual ArchSpec GetSystemArchitecture()
Get the system architecture for this process.
Status DeallocateMemory(lldb::addr_t ptr)
The public interface to deallocating memory in the process.
virtual Status DisableWatchpoint(lldb::WatchpointSP wp_sp, bool notify=true)
void RegisterNotificationCallbacks(const Process::Notifications &callbacks)
Register for process and thread notifications.
virtual void DidAttach(ArchSpec &process_arch)
Called after attaching a process.
virtual lldb::addr_t ResolveIndirectFunction(const Address *address, Status &error)
Resolve dynamically loaded indirect functions.
lldb::StateType m_last_broadcast_state
LanguageRuntime * GetLanguageRuntime(lldb::LanguageType language)
ProcessModID m_mod_id
Tracks the state of the process over stops and other alterations.
void SetID(lldb::pid_t new_pid)
Sets the stored pid.
virtual JITLoaderList & GetJITLoaders()
uint32_t AssignIndexIDToThread(uint64_t thread_id)
virtual bool SetExitStatus(int exit_status, llvm::StringRef exit_string)
Set accessor for the process exit status (return code).
uint32_t m_queue_list_stop_id
The natural stop id when queue list was last fetched.
void PrintWarningOptimization(const SymbolContext &sc)
Print a user-visible warning about a module being built with optimization.
@ eBroadcastInternalStateControlResume
@ eBroadcastInternalStateControlStop
@ eBroadcastInternalStateControlPause
ProcessRunLock m_private_run_lock
virtual std::optional< bool > DoGetWatchpointReportedAfter()
Provide an override value in the subclass for lldb's CPU-based logic for whether watchpoint exception...
static ProcessProperties & GetGlobalProperties()
lldb::addr_t m_highmem_code_address_mask
lldb::addr_t GetImagePtrFromToken(size_t token) const
int m_exit_status
The exit status of the process, or -1 if not set.
std::vector< LanguageRuntime * > GetLanguageRuntimes()
MemoryCache m_memory_cache
static void STDIOReadThreadBytesReceived(void *baton, const void *src, size_t src_len)
virtual bool GetProcessInfo(ProcessInstanceInfo &info)
virtual void DidHalt()
Called after halting a process.
lldb::addr_t FixCodeAddress(lldb::addr_t pc)
Some targets might use bits in a code address to indicate a mode switch, ARM uses bit zero to signify...
lldb::StateType WaitForProcessStopPrivate(lldb::EventSP &event_sp, const Timeout< std::micro > &timeout)
void RestoreProcessEvents()
Restores the process event broadcasting to its normal state.
virtual bool SupportsMemoryTagging()
Check whether the process supports memory tagging.
void DumpThreadPlans(Stream &strm, lldb::DescriptionLevel desc_level, bool internal, bool condense_trivial, bool skip_unreported_plans)
Dump all the thread plans for this process.
uint32_t GetAddressByteSize() const
uint32_t GetStopID() const
void SetPrivateState(lldb::StateType state)
lldb::addr_t m_highmem_data_address_mask
virtual Status DoDestroy()=0
Status StopForDestroyOrDetach(lldb::EventSP &exit_event_sp)
bool GetWatchpointReportedAfter()
Whether lldb will be notified about watchpoints after the instruction has completed executing,...
lldb::StateType GetNextEvent(lldb::EventSP &event_sp)
virtual bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)=0
Update the thread list following process plug-in's specific logic.
virtual llvm::Expected< std::vector< uint8_t > > DoReadMemoryTags(lldb::addr_t addr, size_t len, int32_t type)
Does the final operation to read memory tags.
bool StateChangedIsExternallyHijacked()
bool RunPreResumeActions()
bool PopProcessIOHandler()
virtual size_t GetSTDERR(char *buf, size_t buf_size, Status &error)
Get any available STDERR.
size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error)
Write memory to a process.
virtual llvm::Expected< bool > SaveCore(llvm::StringRef outfile)
Save core dump into the specified file.
bool ProcessIOHandlerIsActive()
Status DestroyImpl(bool force_kill)
bool m_force_next_event_delivery
lldb::SystemRuntimeUP m_system_runtime_up
virtual Status WillHalt()
Called before halting to a process.
bool ShouldBroadcastEvent(Event *event_ptr)
This is the part of the event handling that for a process event.
virtual DynamicLoader * GetDynamicLoader()
Get the dynamic loader plug-in for this process.
std::string m_exit_string
A textual description of why a process exited.
lldb::DynamicCheckerFunctionsUP m_dynamic_checkers_up
The functions used by the expression parser to validate data that expressions use.
void SyncIOHandler(uint32_t iohandler_id, const Timeout< std::micro > &timeout)
Waits for the process state to be running within a given msec timeout.
void ForceNextEventDelivery()
ThreadPlanStack * FindThreadPlans(lldb::tid_t tid)
Find the thread plan stack associated with thread with tid.
std::vector< CoreFileMemoryRange > CoreFileMemoryRanges
void SetSTDIOFileDescriptor(int file_descriptor)
virtual Status Attach(ProcessAttachInfo &attach_info)
Attach to an existing process using the process attach info.
virtual void Finalize(bool destructing)
This object is about to be destroyed, do any necessary cleanup.
lldb::addr_t GetDataAddressMask()
void SynchronouslyNotifyStateChanged(lldb::StateType state)
bool CanJIT()
Determines whether executing JIT-compiled code in this process is possible.
static ConstString & GetStaticBroadcasterClass()
virtual Status DoAttachToProcessWithName(const char *process_name, const ProcessAttachInfo &attach_info)
Attach to an existing process using a partial process name.
ThreadList m_thread_list
The threads for this process as the user will see them.
bool UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
Update the thread list.
const lldb::UnixSignalsSP & GetUnixSignals()
Status WriteMemoryTags(lldb::addr_t addr, size_t len, const std::vector< lldb::addr_t > &tags)
Write memory tags for a range of memory.
virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)=0
Actually do the reading of memory from a process.
virtual bool IsLiveDebugSession() const
std::weak_ptr< Target > m_target_wp
The target that owns this process.
virtual void DoDidExec()
Subclasses of Process should implement this function if they need to do anything after a process exec...
virtual void RefreshStateAfterStop()=0
Currently called as part of ShouldStop.
lldb::addr_t GetCodeAddressMask()
Get the current address mask in the Process.
bool UnregisterNotificationCallbacks(const Process::Notifications &callbacks)
Unregister for process and thread notifications.
bool HijackProcessEvents(lldb::ListenerSP listener_sp)
If you need to ensure that you and only you will hear about some public event, then make a new listen...
virtual Status DoDeallocateMemory(lldb::addr_t ptr)
Actually deallocate memory in the process.
Status GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info)
Locate the memory region that contains load_addr.
static void SettingsTerminate()
lldb::addr_t GetHighmemDataAddressMask()
ThreadList m_extended_thread_list
Constituent for extended threads that may be generated, cleared on natural stops.
bool CallVoidArgVoidPtrReturn(const Address *address, lldb::addr_t &returned_func, bool trap_exceptions=false)
bool CurrentThreadIsPrivateStateThread()
void AddPreResumeAction(PreResumeActionCallback callback, void *baton)
size_t GetSoftwareBreakpointTrapOpcode(BreakpointSite *bp_site)
Status Halt(bool clear_thread_plans=false, bool use_run_lock=true)
Halts a running process.
const lldb::ABISP & GetABI()
Status WillLaunch(Module *module)
Called before launching to a process.
lldb::ModuleSP ReadModuleFromMemory(const FileSpec &file_spec, lldb::addr_t header_addr, size_t size_to_read=512)
size_t WriteScalarToMemory(lldb::addr_t vm_addr, const Scalar &scalar, size_t size, Status &error)
Write all or part of a scalar value to memory.
virtual size_t GetSTDOUT(char *buf, size_t buf_size, Status &error)
Get any available STDOUT.
lldb::ThreadCollectionSP GetHistoryThreads(lldb::addr_t addr)
lldb::StateType GetStateChangedEvents(lldb::EventSP &event_sp, const Timeout< std::micro > &timeout, lldb::ListenerSP hijack_listener)
ThreadedCommunication m_stdio_communication
virtual lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, Status &error)
Actually allocate memory in the process.
std::atomic< bool > m_finalizing
This is set at the beginning of Process::Finalize() to stop functions from looking up or creating thi...
std::recursive_mutex m_language_runtimes_mutex
std::string m_stderr_data
Target & GetTarget()
Get the target object pointer for this module.
virtual Status EnableWatchpoint(lldb::WatchpointSP wp_sp, bool notify=true)
lldb::OptionValuePropertiesSP m_collection_sp
static llvm::StringRef GetExperimentalSettingsName()
bool SetPropertyAtIndex(uint32_t idx, T t, const ExecutionContext *exe_ctx=nullptr) const
virtual lldb::OptionValuePropertiesSP GetValueProperties() const
const lldb::OptionValueSP & GetValue() const
uint32_t GetSize()
Get the number of libdispatch queues that are available.
void Clear()
Clear out the list of queues from the QueueList.
uint64_t GetPC(uint64_t fail_value=LLDB_INVALID_ADDRESS)
size_t GetByteSize() const
bool SignExtend(uint32_t bit_pos)
unsigned long long ULongLong(unsigned long long fail_value=0) const
size_t GetAsMemoryData(void *dst, size_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const
long long SLongLong(long long fail_value=0) const
This base class provides an interface to stack frames.
void CalculateExecutionContext(ExecutionContext &exe_ctx) override
Reconstruct the object's execution context into sc.
void Clear()
Clear the object state.
bool Fail() const
Test for error condition.
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
bool Success() const
Test for success condition.
static lldb::ValueObjectSP GetCrashingDereference(lldb::StopInfoSP &stop_info_sp, lldb::addr_t *crashing_address=nullptr)
StopPointSite::SiteID Add(const StopPointSiteSP &site_sp)
Add a site to the list.
void ForEach(std::function< void(StopPointSite *)> const &callback)
bool FindInRange(lldb::addr_t lower_bound, lldb::addr_t upper_bound, StopPointSiteList &bp_site_list) const
StopPointSiteSP FindByID(typename StopPointSite::SiteID site_id)
Returns a shared pointer to the site with id site_id.
bool Remove(typename StopPointSite::SiteID site_id)
Removes the site given by site_id from this list.
StopPointSiteSP FindByAddress(lldb::addr_t addr)
Returns a shared pointer to the site at address addr.
bool RemoveByAddress(lldb::addr_t addr)
Removes the site at address addr from this list.
lldb::break_id_t GetID() const
virtual lldb::addr_t GetLoadAddress() const
uint32_t GetByteSize() const
const char * GetData() const
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
bool ForEach(std::function< bool(Object *object)> const &foreach_callback) const
bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result) const
Dictionary * GetAsDictionary()
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
lldb::LanguageType GetLanguage() const
Function * function
The Function for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
lldb::addr_t GetLoadAddress(Target *target) const
ConstString GetName() const
Address GetAddress() const
A plug-in interface definition class for system runtimes.
virtual void DidAttach()
Called after attaching to a process.
void ModulesDidLoad(const ModuleList &module_list) override
Called when modules have been loaded in the process.
virtual void DidLaunch()
Called after launching a process.
static SystemRuntime * FindPlugin(Process *process)
Find a system runtime plugin for a given process.
uint32_t GetIndexOfTarget(lldb::TargetSP target_sp) const
lldb::TargetSP GetSelectedTarget()
bool SetPreferDynamicValue(lldb::DynamicValueType d)
bool GetUseFastStepping() const
lldb::DynamicValueType GetPreferDynamicValue() const
void SetFirstPrivateStopTime()
void SetFirstPublicStopTime()
Module * GetExecutableModulePointer()
void UpdateSignalsFromDummy(lldb::UnixSignalsSP signals_sp, lldb::StreamSP warning_stream_sp)
Updates the signals in signals_sp using the stored dummy signals.
void ClearModules(bool delete_locations)
Architecture * GetArchitecturePlugin() const
TargetStats & GetStatistics()
bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform=false, bool merge=true)
Set the architecture for this target.
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
void DidExec()
Called as the last function in Process::DidExec().
Status Install(ProcessLaunchInfo *launch_info)
lldb::PlatformSP GetPlatform()
const ArchSpec & GetArchitecture() const
void SetExecutableModule(lldb::ModuleSP &module_sp, LoadDependentFiles load_dependent_files=eLoadDependentsDefault)
Set the main executable module.
void SetPlatform(const lldb::PlatformSP &platform_sp)
A RAII-friendly terminal state saving/restoring class.
llvm::Error SetEcho(bool enabled)
llvm::Error SetCanonical(bool enabled)
void AddThread(const lldb::ThreadSP &thread_sp)
virtual ThreadIterable Threads()
static llvm::Expected< HostThread > LaunchThread(llvm::StringRef name, std::function< lldb::thread_result_t()> thread_function, size_t min_stack_byte_size=0)
lldb::ThreadSP GetSelectedThread()
bool ShouldStop(Event *event_ptr)
Vote ShouldReportStop(Event *event_ptr)
uint32_t GetStopID() const
uint32_t GetSize(bool can_update=true)
bool SetSelectedThreadByID(lldb::tid_t tid, bool notify=false)
lldb::ThreadSP FindThreadByIndexID(uint32_t index_id, bool can_update=true)
Vote ShouldReportRun(Event *event_ptr)
void SetStopID(uint32_t stop_id)
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
std::recursive_mutex & GetMutex() const override
lldb::ThreadSP GetExpressionExecutionThread()
void DiscardThreadPlans()
void Update(ThreadList &rhs)
bool WillResume()
The thread list asks tells all the threads it is about to resume.
void SetShouldReportStop(Vote vote)
void ClearThreadCache()
Clear the Thread* cache that each ThreadPlan contains.
void DumpPlans(Stream &strm, lldb::DescriptionLevel desc_level, bool internal, bool ignore_boring, bool skip_unreported)
bool PrunePlansForTID(lldb::tid_t tid)
ThreadPlanStack * Find(lldb::tid_t tid)
void Update(ThreadList ¤t_threads, bool delete_missing, bool check_for_new=true)
bool DumpPlansForTID(Stream &strm, lldb::tid_t tid, lldb::DescriptionLevel desc_level, bool internal, bool ignore_boring, bool skip_unreported)
void SetValue(const T &value)
const T & GetValueNoLock() const
void SetValueNoLock(const T &value)
std::recursive_mutex & GetMutex()
bool IsThreadPlanDone(ThreadPlan *plan) const
Checks whether the given plan is in the completed plans for this stop.
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans)
Queues a generic thread plan.
bool WasThreadPlanDiscarded(ThreadPlan *plan) const
Checks whether the given plan is in the discarded plans for this stop.
virtual lldb::RegisterContextSP GetRegisterContext()=0
static void SettingsInitialize()
virtual lldb::StopInfoSP GetPrivateStopInfo(bool calculate=true)
uint32_t GetIndexID() const
size_t GetStackFrameStatus(Stream &strm, uint32_t first_frame, uint32_t num_frames, bool show_frame_info, uint32_t num_frames_with_source)
lldb::StackFrameSP GetSelectedFrame(SelectMostRelevant select_most_relevant)
uint32_t SetSelectedFrame(lldb_private::StackFrame *frame, bool broadcast=false)
static void SettingsTerminate()
virtual lldb::StackFrameSP GetFrameWithStackID(const StackID &stack_id)
void DiscardThreadPlansUpToPlan(lldb::ThreadPlanSP &up_to_plan_sp)
Discards the plans queued on the plan stack of the current thread up to and including up_to_plan_sp.
static ThreadProperties & GetGlobalProperties()
void SetConnection(std::unique_ptr< Connection > connection) override
Sets the connection that it to be used by this class.
virtual bool StopReadThread(Status *error_ptr=nullptr)
Stops the read thread by cancelling it.
void SynchronizeWithReadThread()
Wait for the read thread to process all outstanding data.
lldb::ConnectionStatus Disconnect(Status *error_ptr=nullptr) override
Disconnect the communications connection if one is currently connected.
virtual bool StartReadThread(Status *error_ptr=nullptr)
Starts a read thread whose sole purpose it to read bytes from the current connection.
void SetReadThreadBytesReceivedCallback(ReadThreadBytesReceived callback, void *callback_baton)
RAII guard that should be acquired when an utility function is called within a given process.
"lldb/Expression/UtilityFunction.h" Encapsulates a bit of source code that provides a function that i...
@ eGetExpressionPathFormatHonorPointers
lldb::LanguageType GetObjectRuntimeLanguage()
#define LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_ADDRESS_MASK
Address Mask Bits not used for addressing are set to 1 in the mask; all mask bits set is an invalid v...
#define LLDB_INVALID_THREAD_ID
#define UNUSED_IF_ASSERT_DISABLED(x)
#define LLDB_INVALID_IMAGE_TOKEN
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_PROCESS_ID
@ DoNoSelectMostRelevantFrame
@ SelectMostRelevantFrame
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
@ eDiagnosticSeverityError
@ eDiagnosticSeverityRemark
bool StateIsStoppedState(lldb::StateType state, bool must_exist)
Check if a state represents a state where the process or thread is stopped.
void RegisterAssertFrameRecognizer(Process *process)
Registers the assert stack frame recognizer.
bool StateIsRunningState(lldb::StateType state)
Check if a state represents a state where the process or thread is running.
lldb::ProcessSP(* ProcessCreateInstance)(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
@ eBroadcastAlways
Always send a broadcast when the value is modified.
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
const char * GetPermissionsAsCString(uint32_t permissions)
static uint32_t bits(const uint32_t val, const uint32_t msbit, const uint32_t lsbit)
std::shared_ptr< lldb_private::OptionValueProperties > OptionValuePropertiesSP
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelVerbose
std::shared_ptr< lldb_private::IOHandler > IOHandlerSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
std::shared_ptr< lldb_private::Platform > PlatformSP
StateType
Process and Thread States.
@ eStateUnloaded
Process is object is valid, but not currently loaded.
@ eStateConnected
Process is connected to remote debug services, but not launched or attached to anything yet.
@ eStateDetached
Process has been detached and can't be examined.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateSuspended
Process or thread is in a suspended state as far as the debugger is concerned while other processes o...
@ eStateRunning
Process or thread is running and can't be examined.
@ eStateLaunching
Process is in the process of launching.
@ eStateAttaching
Process is currently trying to attach.
@ eStateExited
Process has exited and can't be examined.
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
@ eStateCrashed
Process or thread has crashed and can be examined.
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeC
Non-standardized C, such as K&R.
std::shared_ptr< lldb_private::MemoryHistory > MemoryHistorySP
std::shared_ptr< lldb_private::Stream > StreamSP
ExpressionResults
The results of expression evaluation.
@ eExpressionHitBreakpoint
@ eExpressionStoppedForDebug
@ eExpressionResultUnavailable
@ eExpressionThreadVanished
std::shared_ptr< lldb_private::StructuredDataPlugin > StructuredDataPluginSP
std::shared_ptr< lldb_private::Process > ProcessSP
InstrumentationRuntimeType
std::shared_ptr< lldb_private::Disassembler > DisassemblerSP
std::shared_ptr< lldb_private::LanguageRuntime > LanguageRuntimeSP
std::shared_ptr< lldb_private::Event > EventSP
std::unique_ptr< lldb_private::DynamicLoader > DynamicLoaderUP
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
std::shared_ptr< lldb_private::Listener > ListenerSP
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
StopReason
Thread stop reasons.
@ eStopReasonInstrumentation
@ eStopReasonPlanComplete
@ eStopReasonExec
Program was re-exec'ed.
@ eStopReasonProcessorTrace
@ eStopReasonThreadExiting
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
std::shared_ptr< lldb_private::InstrumentationRuntime > InstrumentationRuntimeSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::OptionValue > OptionValueSP
std::shared_ptr< lldb_private::ThreadCollection > ThreadCollectionSP
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
A notification structure that can be used by clients to listen for changes in a process's lifetime.
void(* process_state_changed)(void *baton, Process *process, lldb::StateType state)
void(* initialize)(void *baton, Process *process)
BaseType GetRangeBase() const
SizeType GetByteSize() const
BaseType GetRangeEnd() const
lldb::user_id_t GetID() const
Get accessor for the user ID.