aboutsummaryrefslogtreecommitdiffstats
path: root/source/Target
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-18 20:12:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-18 20:12:36 +0000
commitef5d0b5e97ec8e6fa395d377b09aa7755e345b4f (patch)
tree27916256fdeeb57d10d2f3d6948be5d71a703215 /source/Target
parent76e0736e7fcfeb179779e49c05604464b1ccd704 (diff)
downloadsrc-ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f.tar.gz
src-ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f.zip
Vendor import of lldb trunk r321017:vendor/lldb/lldb-trunk-r321017
Notes
Notes: svn path=/vendor/lldb/dist/; revision=326949 svn path=/vendor/lldb/lldb-trunk-r321017/; revision=326950; tag=vendor/lldb/lldb-trunk-r321017
Diffstat (limited to 'source/Target')
-rw-r--r--source/Target/PathMappingList.cpp1
-rw-r--r--source/Target/Platform.cpp52
-rw-r--r--source/Target/Process.cpp39
-rw-r--r--source/Target/ProcessLaunchInfo.cpp14
-rw-r--r--source/Target/RegisterContext.cpp136
-rw-r--r--source/Target/StackFrame.cpp4
-rw-r--r--source/Target/StopInfo.cpp54
-rw-r--r--source/Target/Target.cpp257
-rw-r--r--source/Target/Thread.cpp8
-rw-r--r--source/Target/ThreadPlanStepInRange.cpp8
-rw-r--r--source/Target/ThreadPlanTracer.cpp3
-rw-r--r--source/Target/UnixSignals.cpp2
12 files changed, 348 insertions, 230 deletions
diff --git a/source/Target/PathMappingList.cpp b/source/Target/PathMappingList.cpp
index b834a3600d0b..782c6e49623c 100644
--- a/source/Target/PathMappingList.cpp
+++ b/source/Target/PathMappingList.cpp
@@ -85,7 +85,6 @@ void PathMappingList::Insert(const ConstString &path,
bool PathMappingList::Replace(const ConstString &path,
const ConstString &replacement, uint32_t index,
bool notify) {
- iterator insert_iter;
if (index >= m_pairs.size())
return false;
++m_mod_id;
diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp
index 498facf8e0d0..5d60bb791555 100644
--- a/source/Target/Platform.cpp
+++ b/source/Target/Platform.cpp
@@ -356,6 +356,12 @@ PlatformSP Platform::Create(const ArchSpec &arch, ArchSpec *platform_arch_ptr,
return platform_sp;
}
+ArchSpec Platform::GetAugmentedArchSpec(Platform *platform, llvm::StringRef triple) {
+ if (platform)
+ return platform->GetAugmentedArchSpec(triple);
+ return HostInfo::GetAugmentedArchSpec(triple);
+}
+
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
@@ -963,6 +969,34 @@ const ArchSpec &Platform::GetSystemArchitecture() {
return m_system_arch;
}
+ArchSpec Platform::GetAugmentedArchSpec(llvm::StringRef triple) {
+ if (triple.empty())
+ return ArchSpec();
+ llvm::Triple normalized_triple(llvm::Triple::normalize(triple));
+ if (!ArchSpec::ContainsOnlyArch(normalized_triple))
+ return ArchSpec(triple);
+
+ if (auto kind = HostInfo::ParseArchitectureKind(triple))
+ return HostInfo::GetArchitecture(*kind);
+
+ ArchSpec compatible_arch;
+ ArchSpec raw_arch(triple);
+ if (!IsCompatibleArchitecture(raw_arch, false, &compatible_arch))
+ return raw_arch;
+
+ if (!compatible_arch.IsValid())
+ return ArchSpec(normalized_triple);
+
+ const llvm::Triple &compatible_triple = compatible_arch.GetTriple();
+ if (normalized_triple.getVendorName().empty())
+ normalized_triple.setVendor(compatible_triple.getVendor());
+ if (normalized_triple.getOSName().empty())
+ normalized_triple.setOS(compatible_triple.getOS());
+ if (normalized_triple.getEnvironmentName().empty())
+ normalized_triple.setEnvironment(compatible_triple.getEnvironment());
+ return ArchSpec(normalized_triple);
+}
+
Status Platform::ConnectRemote(Args &args) {
Status error;
if (IsHost())
@@ -1162,7 +1196,7 @@ Platform::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
// open for stdin/out/err after we have already opened the master
// so we can read/write stdin/out/err.
int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
- if (pty_fd != lldb_utility::PseudoTerminal::invalid_fd) {
+ if (pty_fd != PseudoTerminal::invalid_fd) {
process_sp->SetSTDIOFileDescriptor(pty_fd);
}
} else {
@@ -1316,14 +1350,18 @@ Status Platform::Unlink(const FileSpec &path) {
return error;
}
-uint64_t Platform::ConvertMmapFlagsToPlatform(const ArchSpec &arch,
- unsigned flags) {
+MmapArgList Platform::GetMmapArgumentList(const ArchSpec &arch, addr_t addr,
+ addr_t length, unsigned prot,
+ unsigned flags, addr_t fd,
+ addr_t offset) {
uint64_t flags_platform = 0;
if (flags & eMmapFlagsPrivate)
flags_platform |= MAP_PRIVATE;
if (flags & eMmapFlagsAnon)
flags_platform |= MAP_ANON;
- return flags_platform;
+
+ MmapArgList args({addr, length, prot, flags_platform, fd, offset});
+ return args;
}
lldb_private::Status Platform::RunShellCommand(
@@ -1874,6 +1912,12 @@ size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
trap_opcode_size = sizeof(g_ppc_opcode);
} break;
+ case llvm::Triple::ppc64le: {
+ static const uint8_t g_ppc64le_opcode[] = {0x08, 0x00, 0xe0, 0x7f}; // trap
+ trap_opcode = g_ppc64le_opcode;
+ trap_opcode_size = sizeof(g_ppc64le_opcode);
+ } break;
+
case llvm::Triple::x86:
case llvm::Triple::x86_64: {
static const uint8_t g_i386_opcode[] = {0xCC};
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 6cbe289ef26b..8fb149fab063 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -144,6 +144,9 @@ static PropertyDefinition g_properties[] = {
{"optimization-warnings", OptionValue::eTypeBoolean, false, true, nullptr,
nullptr, "If true, warn when stopped in code that is optimized where "
"stepping and variable availability may not behave as expected."},
+ {"stop-on-exec", OptionValue::eTypeBoolean, true, true,
+ nullptr, nullptr,
+ "If true, stop when a shared library is loaded or unloaded."},
{nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, nullptr, nullptr}};
enum {
@@ -155,7 +158,8 @@ enum {
ePropertyStopOnSharedLibraryEvents,
ePropertyDetachKeepsStopped,
ePropertyMemCacheLineSize,
- ePropertyWarningOptimization
+ ePropertyWarningOptimization,
+ ePropertyStopOnExec
};
ProcessProperties::ProcessProperties(lldb_private::Process *process)
@@ -272,6 +276,12 @@ bool ProcessProperties::GetWarningsOptimization() const {
nullptr, idx, g_properties[idx].default_uint_value != 0);
}
+bool ProcessProperties::GetStopOnExec() const {
+ const uint32_t idx = ePropertyStopOnExec;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_properties[idx].default_uint_value != 0);
+}
+
void ProcessInstanceInfo::Dump(Stream &s, Platform *platform) const {
const char *cstr;
if (m_pid != LLDB_INVALID_PROCESS_ID)
@@ -480,8 +490,8 @@ Status ProcessLaunchCommandOptions::SetOptionValue(
execution_context ? execution_context->GetTargetSP() : TargetSP();
PlatformSP platform_sp =
target_sp ? target_sp->GetPlatform() : PlatformSP();
- if (!launch_info.GetArchitecture().SetTriple(option_arg, platform_sp.get()))
- launch_info.GetArchitecture().SetTriple(option_arg);
+ launch_info.GetArchitecture() =
+ Platform::GetAugmentedArchSpec(platform_sp.get(), option_arg);
} break;
case 'A': // Disable ASLR.
@@ -743,8 +753,7 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,
m_profile_data_comm_mutex(), m_profile_data(), m_iohandler_sync(0),
m_memory_cache(*this), m_allocated_memory_cache(*this),
m_should_detach(false), m_next_event_action_ap(), m_public_run_lock(),
- m_private_run_lock(), m_stop_info_override_callback(nullptr),
- m_finalizing(false), m_finalize_called(false),
+ m_private_run_lock(), m_finalizing(false), m_finalize_called(false),
m_clear_thread_plans_on_stop(false), m_force_next_event_delivery(false),
m_last_broadcast_state(eStateInvalid), m_destroy_in_process(false),
m_can_interpret_function_calls(false), m_warnings_issued(),
@@ -871,7 +880,6 @@ void Process::Finalize() {
m_language_runtimes.clear();
m_instrumentation_runtimes.clear();
m_next_event_action_ap.reset();
- m_stop_info_override_callback = nullptr;
// Clear the last natural stop ID since it has a strong
// reference to this process
m_mod_id.SetStopEventForLastNaturalStopID(EventSP());
@@ -1562,7 +1570,6 @@ uint32_t Process::AssignIndexIDToThread(uint64_t thread_id) {
}
StateType Process::GetState() {
- // If any other threads access this we will need a mutex for it
return m_public_state.GetValue();
}
@@ -1621,7 +1628,12 @@ Status Process::Resume() {
log->Printf("Process::Resume: -- TrySetRunning failed, not resuming.");
return error;
}
- return PrivateResume();
+ Status error = PrivateResume();
+ if (!error.Success()) {
+ // Undo running state change
+ m_public_run_lock.SetStopped();
+ }
+ return error;
}
Status Process::ResumeSynchronous(Stream *stream) {
@@ -1650,6 +1662,9 @@ Status Process::ResumeSynchronous(Stream *stream) {
error.SetErrorStringWithFormat(
"process not in stopped state after synchronous resume: %s",
StateAsCString(state));
+ } else {
+ // Undo running state change
+ m_public_run_lock.SetStopped();
}
// Undo the hijacking of process events...
@@ -2712,7 +2727,6 @@ Status Process::Launch(ProcessLaunchInfo &launch_info) {
m_system_runtime_ap.reset();
m_os_ap.reset();
m_process_input_reader.reset();
- m_stop_info_override_callback = nullptr;
Module *exe_module = GetTarget().GetExecutableModulePointer();
if (exe_module) {
@@ -2800,9 +2814,6 @@ Status Process::Launch(ProcessLaunchInfo &launch_info) {
else
StartPrivateStateThread();
- m_stop_info_override_callback =
- GetTarget().GetArchitecture().GetStopInfoOverrideCallback();
-
// Target was stopped at entry as was intended. Need to notify the
// listeners
// about it.
@@ -2986,7 +2997,6 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
m_jit_loaders_ap.reset();
m_system_runtime_ap.reset();
m_os_ap.reset();
- m_stop_info_override_callback = nullptr;
lldb::pid_t attach_pid = attach_info.GetProcessID();
Status error;
@@ -3219,8 +3229,6 @@ void Process::CompleteAttach() {
: "<none>");
}
}
-
- m_stop_info_override_callback = process_arch.GetStopInfoOverrideCallback();
}
Status Process::ConnectRemote(Stream *strm, llvm::StringRef remote_url) {
@@ -5849,7 +5857,6 @@ void Process::DidExec() {
m_instrumentation_runtimes.clear();
m_thread_list.DiscardThreadPlans();
m_memory_cache.Clear(true);
- m_stop_info_override_callback = nullptr;
DoDidExec();
CompleteAttach();
// Flush the process (threads and all stack frames) after running
diff --git a/source/Target/ProcessLaunchInfo.cpp b/source/Target/ProcessLaunchInfo.cpp
index 3fa40dcc5cab..284df9fd8b58 100644
--- a/source/Target/ProcessLaunchInfo.cpp
+++ b/source/Target/ProcessLaunchInfo.cpp
@@ -39,10 +39,9 @@ using namespace lldb_private;
ProcessLaunchInfo::ProcessLaunchInfo()
: ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(0),
- m_file_actions(), m_pty(new lldb_utility::PseudoTerminal),
- m_resume_count(0), m_monitor_callback(nullptr),
- m_monitor_callback_baton(nullptr), m_monitor_signals(false),
- m_listener_sp(), m_hijack_listener_sp() {}
+ m_file_actions(), m_pty(new PseudoTerminal), m_resume_count(0),
+ m_monitor_callback(nullptr), m_monitor_callback_baton(nullptr),
+ m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp() {}
ProcessLaunchInfo::ProcessLaunchInfo(const FileSpec &stdin_file_spec,
const FileSpec &stdout_file_spec,
@@ -50,10 +49,9 @@ ProcessLaunchInfo::ProcessLaunchInfo(const FileSpec &stdin_file_spec,
const FileSpec &working_directory,
uint32_t launch_flags)
: ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(launch_flags),
- m_file_actions(), m_pty(new lldb_utility::PseudoTerminal),
- m_resume_count(0), m_monitor_callback(nullptr),
- m_monitor_callback_baton(nullptr), m_monitor_signals(false),
- m_listener_sp(), m_hijack_listener_sp() {
+ m_file_actions(), m_pty(new PseudoTerminal), m_resume_count(0),
+ m_monitor_callback(nullptr), m_monitor_callback_baton(nullptr),
+ m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp() {
if (stdin_file_spec) {
FileAction file_action;
const bool read = true;
diff --git a/source/Target/RegisterContext.cpp b/source/Target/RegisterContext.cpp
index 66164c175e41..28beb7bcb5e8 100644
--- a/source/Target/RegisterContext.cpp
+++ b/source/Target/RegisterContext.cpp
@@ -93,10 +93,9 @@ RegisterContext::UpdateDynamicRegisterSize(const lldb_private::ArchSpec &arch,
Value result;
Status error;
const lldb::offset_t offset = 0;
- if (dwarf_expr.Evaluate(&exe_ctx, nullptr, nullptr, this, opcode_ctx,
- dwarf_data, nullptr, offset, dwarf_opcode_len,
- eRegisterKindDWARF, nullptr, nullptr, result,
- &error)) {
+ if (dwarf_expr.Evaluate(&exe_ctx, this, opcode_ctx, dwarf_data, nullptr,
+ offset, dwarf_opcode_len, eRegisterKindDWARF, nullptr,
+ nullptr, result, &error)) {
expr_result = result.GetScalar().SInt(-1);
switch (expr_result) {
case 0:
@@ -457,132 +456,3 @@ bool RegisterContext::ConvertBetweenRegisterKinds(lldb::RegisterKind source_rk,
}
return false;
}
-
-// bool
-// RegisterContext::ReadRegisterValue (uint32_t reg, Scalar &value)
-//{
-// DataExtractor data;
-// if (!ReadRegisterBytes (reg, data))
-// return false;
-//
-// const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg);
-// uint32_t offset = 0;
-// switch (reg_info->encoding)
-// {
-// case eEncodingInvalid:
-// case eEncodingVector:
-// break;
-//
-// case eEncodingUint:
-// switch (reg_info->byte_size)
-// {
-// case 1:
-// {
-// value = data.GetU8 (&offset);
-// return true;
-// }
-// case 2:
-// {
-// value = data.GetU16 (&offset);
-// return true;
-// }
-// case 4:
-// {
-// value = data.GetU32 (&offset);
-// return true;
-// }
-// case 8:
-// {
-// value = data.GetU64 (&offset);
-// return true;
-// }
-// }
-// break;
-// case eEncodingSint:
-// switch (reg_info->byte_size)
-// {
-// case 1:
-// {
-// int8_t v;
-// if (data.ExtractBytes (0, sizeof (int8_t),
-// endian::InlHostByteOrder(), &v) != sizeof (int8_t))
-// return false;
-// value = v;
-// return true;
-// }
-// case 2:
-// {
-// int16_t v;
-// if (data.ExtractBytes (0, sizeof (int16_t),
-// endian::InlHostByteOrder(), &v) != sizeof (int16_t))
-// return false;
-// value = v;
-// return true;
-// }
-// case 4:
-// {
-// int32_t v;
-// if (data.ExtractBytes (0, sizeof (int32_t),
-// endian::InlHostByteOrder(), &v) != sizeof (int32_t))
-// return false;
-// value = v;
-// return true;
-// }
-// case 8:
-// {
-// int64_t v;
-// if (data.ExtractBytes (0, sizeof (int64_t),
-// endian::InlHostByteOrder(), &v) != sizeof (int64_t))
-// return false;
-// value = v;
-// return true;
-// }
-// }
-// break;
-// case eEncodingIEEE754:
-// switch (reg_info->byte_size)
-// {
-// case sizeof (float):
-// {
-// float v;
-// if (data.ExtractBytes (0, sizeof (float),
-// endian::InlHostByteOrder(), &v) != sizeof (float))
-// return false;
-// value = v;
-// return true;
-// }
-// case sizeof (double):
-// {
-// double v;
-// if (data.ExtractBytes (0, sizeof (double),
-// endian::InlHostByteOrder(), &v) != sizeof (double))
-// return false;
-// value = v;
-// return true;
-// }
-// case sizeof (long double):
-// {
-// double v;
-// if (data.ExtractBytes (0, sizeof (long double),
-// endian::InlHostByteOrder(), &v) != sizeof (long double))
-// return false;
-// value = v;
-// return true;
-// }
-// }
-// break;
-// }
-// return false;
-//}
-//
-// bool
-// RegisterContext::WriteRegisterValue (uint32_t reg, const Scalar &value)
-//{
-// DataExtractor data;
-// if (!value.IsValid())
-// return false;
-// if (!value.GetData (data))
-// return false;
-//
-// return WriteRegisterBytes (reg, data);
-//}
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index 30fceb11c11f..dd44eac8e50c 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -1089,8 +1089,8 @@ bool StackFrame::GetFrameBaseValue(Scalar &frame_base, Status *error_ptr) {
exe_ctx.GetTargetPtr());
if (m_sc.function->GetFrameBaseExpression().Evaluate(
- &exe_ctx, nullptr, nullptr, nullptr, loclist_base_addr, nullptr,
- nullptr, expr_value, &m_frame_base_error) == false) {
+ &exe_ctx, nullptr, loclist_base_addr, nullptr, nullptr,
+ expr_value, &m_frame_base_error) == false) {
// We should really have an error if evaluate returns, but in case
// we don't, lets set the error to something at least.
if (m_frame_base_error.Success())
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index 6af5ce1b2ebf..652ad8a05445 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -393,7 +393,10 @@ protected:
for (size_t j = 0; j < num_owners; j++) {
lldb::BreakpointLocationSP bp_loc_sp = site_locations.GetByIndex(j);
-
+ StreamString loc_desc;
+ if (log) {
+ bp_loc_sp->GetDescription(&loc_desc, eDescriptionLevelBrief);
+ }
// If another action disabled this breakpoint or its location, then
// don't run the actions.
if (!bp_loc_sp->IsEnabled() ||
@@ -405,16 +408,16 @@ protected:
// this thread. Skip the ones that aren't:
if (!bp_loc_sp->ValidForThisThread(thread_sp.get())) {
if (log) {
- StreamString s;
- bp_loc_sp->GetDescription(&s, eDescriptionLevelBrief);
log->Printf("Breakpoint %s hit on thread 0x%llx but it was not "
"for this thread, continuing.",
- s.GetData(), static_cast<unsigned long long>(
+ loc_desc.GetData(), static_cast<unsigned long long>(
thread_sp->GetID()));
}
continue;
}
+ internal_breakpoint = bp_loc_sp->GetBreakpoint().IsInternal();
+
// First run the precondition, but since the precondition is per
// breakpoint, only run it once
// per breakpoint.
@@ -458,11 +461,10 @@ protected:
error_sp->Flush();
} else {
if (log) {
- StreamString s;
- bp_loc_sp->GetDescription(&s, eDescriptionLevelBrief);
log->Printf("Condition evaluated for breakpoint %s on thread "
"0x%llx conditon_says_stop: %i.",
- s.GetData(), static_cast<unsigned long long>(
+ loc_desc.GetData(),
+ static_cast<unsigned long long>(
thread_sp->GetID()),
condition_says_stop);
}
@@ -477,7 +479,26 @@ protected:
}
}
- bool callback_says_stop;
+ // Check the auto-continue bit on the location, do this before the
+ // callback since it may change this, but that would be for the
+ // NEXT hit. Note, you might think you could check auto-continue
+ // before the condition, and not evaluate the condition if it says
+ // to continue. But failing the condition means the breakpoint was
+ // effectively NOT HIT. So these two states are different.
+ bool auto_continue_says_stop = true;
+ if (bp_loc_sp->IsAutoContinue())
+ {
+ if (log)
+ log->Printf("Continuing breakpoint %s as AutoContinue was set.",
+ loc_desc.GetData());
+ // We want this stop reported, so you will know we auto-continued
+ // but only for external breakpoints:
+ if (!internal_breakpoint)
+ thread_sp->SetShouldReportStop(eVoteYes);
+ auto_continue_says_stop = false;
+ }
+
+ bool callback_says_stop = true;
// FIXME: For now the callbacks have to run in async mode - the
// first time we restart we need
@@ -493,11 +514,8 @@ protected:
debugger.SetAsyncExecution(old_async);
- if (callback_says_stop)
+ if (callback_says_stop && auto_continue_says_stop)
m_should_stop = true;
-
- if (m_should_stop && !bp_loc_sp->GetBreakpoint().IsInternal())
- internal_breakpoint = false;
// If we are going to stop for this breakpoint, then remove the
// breakpoint.
@@ -506,7 +524,6 @@ protected:
thread_sp->GetProcess()->GetTarget().RemoveBreakpointByID(
bp_loc_sp->GetBreakpoint().GetID());
}
-
// Also make sure that the callback hasn't continued the target.
// If it did, when we'll set m_should_start to false and get out of
// here.
@@ -1071,6 +1088,10 @@ private:
ExpressionVariableSP m_expression_variable_sp;
};
+//----------------------------------------------------------------------
+// StopInfoExec
+//----------------------------------------------------------------------
+
class StopInfoExec : public StopInfo {
public:
StopInfoExec(Thread &thread)
@@ -1078,6 +1099,13 @@ public:
~StopInfoExec() override = default;
+ bool ShouldStop(Event *event_ptr) override {
+ ThreadSP thread_sp(m_thread_wp.lock());
+ if (thread_sp)
+ return thread_sp->GetProcess()->GetStopOnExec();
+ return false;
+ }
+
StopReason GetStopReason() const override { return eStopReasonExec; }
const char *GetDescription() override { return "exec"; }
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index d97f651ca08b..903f50887fec 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -26,6 +26,7 @@
#include "lldb/Core/Event.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/SourceManager.h"
#include "lldb/Core/State.h"
@@ -65,6 +66,16 @@ using namespace lldb_private;
constexpr std::chrono::milliseconds EvaluateExpressionOptions::default_timeout;
+Target::Arch::Arch(const ArchSpec &spec)
+ : m_spec(spec),
+ m_plugin_up(PluginManager::CreateArchitectureInstance(spec)) {}
+
+const Target::Arch& Target::Arch::operator=(const ArchSpec &spec) {
+ m_spec = spec;
+ m_plugin_up = PluginManager::CreateArchitectureInstance(spec);
+ return *this;
+}
+
ConstString &Target::GetStaticBroadcasterClass() {
static ConstString class_name("lldb.target");
return class_name;
@@ -76,12 +87,12 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch,
Broadcaster(debugger.GetBroadcasterManager(),
Target::GetStaticBroadcasterClass().AsCString()),
ExecutionContextScope(), m_debugger(debugger), m_platform_sp(platform_sp),
- m_mutex(), m_arch(target_arch), m_images(this), m_section_load_history(),
- m_breakpoint_list(false), m_internal_breakpoint_list(true),
- m_watchpoint_list(), m_process_sp(), m_search_filter_sp(),
- m_image_search_paths(ImageSearchPathsChanged, this), m_ast_importer_sp(),
- m_source_manager_ap(), m_stop_hooks(), m_stop_hook_next_id(0),
- m_valid(true), m_suppress_stop_hooks(false),
+ m_mutex(), m_arch(target_arch),
+ m_images(this), m_section_load_history(), m_breakpoint_list(false),
+ m_internal_breakpoint_list(true), m_watchpoint_list(), m_process_sp(),
+ m_search_filter_sp(), m_image_search_paths(ImageSearchPathsChanged, this),
+ m_ast_importer_sp(), m_source_manager_ap(), m_stop_hooks(),
+ m_stop_hook_next_id(0), m_valid(true), m_suppress_stop_hooks(false),
m_is_dummy_target(is_dummy_target)
{
@@ -96,10 +107,11 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch,
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log)
log->Printf("%p Target::Target()", static_cast<void *>(this));
- if (m_arch.IsValid()) {
- LogIfAnyCategoriesSet(
- LIBLLDB_LOG_TARGET, "Target::Target created with architecture %s (%s)",
- m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str());
+ if (target_arch.IsValid()) {
+ LogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET,
+ "Target::Target created with architecture %s (%s)",
+ target_arch.GetArchitectureName(),
+ target_arch.GetTriple().getTriple().c_str());
}
}
@@ -123,6 +135,13 @@ void Target::PrimeFromDummyTarget(Target *target) {
BreakpointSP new_bp(new Breakpoint(*this, *breakpoint_sp.get()));
AddBreakpoint(new_bp, false);
}
+
+ for (auto bp_name_entry : target->m_breakpoint_names)
+ {
+
+ BreakpointName *new_bp_name = new BreakpointName(*bp_name_entry.second);
+ AddBreakpointName(new_bp_name);
+ }
}
void Target::Dump(Stream *s, lldb::DescriptionLevel description_level) {
@@ -243,7 +262,7 @@ void Target::Destroy() {
m_valid = false;
DeleteCurrentProcess();
m_platform_sp.reset();
- m_arch.Clear();
+ m_arch = ArchSpec();
ClearModules(true);
m_section_load_history.Clear();
const bool notify = false;
@@ -601,6 +620,112 @@ void Target::AddBreakpoint(lldb::BreakpointSP bp_sp, bool internal) {
}
}
+void Target::AddNameToBreakpoint(BreakpointID &id,
+ const char *name,
+ Status &error)
+ {
+ BreakpointSP bp_sp
+ = m_breakpoint_list.FindBreakpointByID(id.GetBreakpointID());
+ if (!bp_sp)
+ {
+ StreamString s;
+ id.GetDescription(&s, eDescriptionLevelBrief);
+ error.SetErrorStringWithFormat("Could not find breakpoint %s",
+ s.GetData());
+ return;
+ }
+ AddNameToBreakpoint(bp_sp, name, error);
+ }
+
+void Target::AddNameToBreakpoint(BreakpointSP &bp_sp,
+ const char *name,
+ Status &error)
+ {
+ if (!bp_sp)
+ return;
+
+ BreakpointName *bp_name = FindBreakpointName(ConstString(name), true, error);
+ if (!bp_name)
+ return;
+
+ bp_name->ConfigureBreakpoint(bp_sp);
+ bp_sp->AddName(name);
+ }
+
+void Target::AddBreakpointName(BreakpointName *bp_name) {
+ m_breakpoint_names.insert(std::make_pair(bp_name->GetName(), bp_name));
+}
+
+BreakpointName *Target::FindBreakpointName(const ConstString &name,
+ bool can_create,
+ Status &error)
+{
+ BreakpointID::StringIsBreakpointName(name.GetStringRef(), error);
+ if (!error.Success())
+ return nullptr;
+
+ BreakpointNameList::iterator iter = m_breakpoint_names.find(name);
+ if (iter == m_breakpoint_names.end()) {
+ if (!can_create)
+ {
+ error.SetErrorStringWithFormat("Breakpoint name \"%s\" doesn't exist and "
+ "can_create is false.", name.AsCString());
+ return nullptr;
+ }
+
+ iter = m_breakpoint_names.insert(std::make_pair(name,
+ new BreakpointName(name)))
+ .first;
+ }
+ return (iter->second);
+}
+
+void
+Target::DeleteBreakpointName(const ConstString &name)
+{
+ BreakpointNameList::iterator iter = m_breakpoint_names.find(name);
+
+ if (iter != m_breakpoint_names.end()) {
+ const char *name_cstr = name.AsCString();
+ m_breakpoint_names.erase(iter);
+ for (auto bp_sp : m_breakpoint_list.Breakpoints())
+ bp_sp->RemoveName(name_cstr);
+ }
+}
+
+void Target::RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp,
+ const ConstString &name)
+{
+ bp_sp->RemoveName(name.AsCString());
+}
+
+void Target::ConfigureBreakpointName(BreakpointName &bp_name,
+ const BreakpointOptions &new_options,
+ const BreakpointName::Permissions &new_permissions)
+{
+ bp_name.GetOptions().CopyOverSetOptions(new_options);
+ bp_name.GetPermissions().MergeInto(new_permissions);
+ ApplyNameToBreakpoints(bp_name);
+}
+
+void Target::ApplyNameToBreakpoints(BreakpointName &bp_name) {
+ BreakpointList bkpts_with_name(false);
+ m_breakpoint_list.FindBreakpointsByName(bp_name.GetName().AsCString(),
+ bkpts_with_name);
+
+ for (auto bp_sp : bkpts_with_name.Breakpoints())
+ bp_name.ConfigureBreakpoint(bp_sp);
+}
+
+void Target::GetBreakpointNames(std::vector<std::string> &names)
+{
+ names.clear();
+ for (auto bp_name : m_breakpoint_names) {
+ names.push_back(bp_name.first.AsCString());
+ }
+ std::sort(names.begin(), names.end());
+}
+
bool Target::ProcessIsValid() {
return (m_process_sp && m_process_sp->IsAlive());
}
@@ -703,6 +828,17 @@ WatchpointSP Target::CreateWatchpoint(lldb::addr_t addr, size_t size,
return wp_sp;
}
+void Target::RemoveAllowedBreakpoints ()
+{
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+ if (log)
+ log->Printf("Target::%s \n", __FUNCTION__);
+
+ m_breakpoint_list.RemoveAllowed(true);
+
+ m_last_created_breakpoint.reset();
+}
+
void Target::RemoveAllBreakpoints(bool internal_also) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
if (log)
@@ -727,6 +863,14 @@ void Target::DisableAllBreakpoints(bool internal_also) {
m_internal_breakpoint_list.SetEnabledAll(false);
}
+void Target::DisableAllowedBreakpoints() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+ if (log)
+ log->Printf("Target::%s", __FUNCTION__);
+
+ m_breakpoint_list.SetEnabledAllowed(false);
+}
+
void Target::EnableAllBreakpoints(bool internal_also) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
if (log)
@@ -738,6 +882,14 @@ void Target::EnableAllBreakpoints(bool internal_also) {
m_internal_breakpoint_list.SetEnabledAll(true);
}
+void Target::EnableAllowedBreakpoints() {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+ if (log)
+ log->Printf("Target::%s", __FUNCTION__);
+
+ m_breakpoint_list.SetEnabledAllowed(true);
+}
+
bool Target::RemoveBreakpointByID(break_id_t break_id) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
if (log)
@@ -1226,8 +1378,8 @@ void Target::ClearModules(bool delete_locations) {
void Target::DidExec() {
// When a process exec's we need to know about it so we can do some cleanup.
- m_breakpoint_list.RemoveInvalidLocations(m_arch);
- m_internal_breakpoint_list.RemoveInvalidLocations(m_arch);
+ m_breakpoint_list.RemoveInvalidLocations(m_arch.GetSpec());
+ m_internal_breakpoint_list.RemoveInvalidLocations(m_arch.GetSpec());
}
void Target::SetExecutableModule(ModuleSP &executable_sp,
@@ -1245,13 +1397,12 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
// If we haven't set an architecture yet, reset our architecture based on
// what we found in the executable module.
- if (!m_arch.IsValid()) {
+ if (!m_arch.GetSpec().IsValid()) {
m_arch = executable_sp->GetArchitecture();
- if (log)
- log->Printf("Target::SetExecutableModule setting architecture to %s "
- "(%s) based on executable file",
- m_arch.GetArchitectureName(),
- m_arch.GetTriple().getTriple().c_str());
+ LLDB_LOG(log,
+ "setting architecture to {0} ({1}) based on executable file",
+ m_arch.GetSpec().GetArchitectureName(),
+ m_arch.GetSpec().GetTriple().getTriple());
}
FileSpecList dependent_files;
@@ -1269,7 +1420,7 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
else
platform_dependent_file_spec = dependent_file_spec;
- ModuleSpec module_spec(platform_dependent_file_spec, m_arch);
+ ModuleSpec module_spec(platform_dependent_file_spec, m_arch.GetSpec());
ModuleSP image_module_sp(GetSharedModule(module_spec));
if (image_module_sp) {
ObjectFile *objfile = image_module_sp->GetObjectFile();
@@ -1283,21 +1434,21 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
bool Target::SetArchitecture(const ArchSpec &arch_spec) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TARGET));
- bool missing_local_arch = !m_arch.IsValid();
+ bool missing_local_arch = !m_arch.GetSpec().IsValid();
bool replace_local_arch = true;
bool compatible_local_arch = false;
ArchSpec other(arch_spec);
if (!missing_local_arch) {
- if (m_arch.IsCompatibleMatch(arch_spec)) {
- other.MergeFrom(m_arch);
+ if (m_arch.GetSpec().IsCompatibleMatch(arch_spec)) {
+ other.MergeFrom(m_arch.GetSpec());
- if (m_arch.IsCompatibleMatch(other)) {
+ if (m_arch.GetSpec().IsCompatibleMatch(other)) {
compatible_local_arch = true;
bool arch_changed, vendor_changed, os_changed, os_ver_changed,
env_changed;
- m_arch.PiecewiseTripleCompare(other, arch_changed, vendor_changed,
+ m_arch.GetSpec().PiecewiseTripleCompare(other, arch_changed, vendor_changed,
os_changed, os_ver_changed, env_changed);
if (!arch_changed && !vendor_changed && !os_changed && !env_changed)
@@ -1311,10 +1462,9 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec) {
// update the architecture, unless the one we already have is more specified
if (replace_local_arch)
m_arch = other;
- if (log)
- log->Printf("Target::SetArchitecture set architecture to %s (%s)",
- m_arch.GetArchitectureName(),
- m_arch.GetTriple().getTriple().c_str());
+ LLDB_LOG(log, "set architecture to {0} ({1})",
+ m_arch.GetSpec().GetArchitectureName(),
+ m_arch.GetSpec().GetTriple().getTriple());
return true;
}
@@ -1351,12 +1501,12 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec) {
bool Target::MergeArchitecture(const ArchSpec &arch_spec) {
if (arch_spec.IsValid()) {
- if (m_arch.IsCompatibleMatch(arch_spec)) {
+ if (m_arch.GetSpec().IsCompatibleMatch(arch_spec)) {
// The current target arch is compatible with "arch_spec", see if we
// can improve our current architecture using bits from "arch_spec"
// Merge bits from arch_spec into "merged_arch" and set our architecture
- ArchSpec merged_arch(m_arch);
+ ArchSpec merged_arch(m_arch.GetSpec());
merged_arch.MergeFrom(arch_spec);
return SetArchitecture(merged_arch);
} else {
@@ -1684,8 +1834,8 @@ size_t Target::ReadScalarIntegerFromMemory(const Address &addr,
size_t bytes_read =
ReadMemory(addr, prefer_file_cache, &uval, byte_size, error);
if (bytes_read == byte_size) {
- DataExtractor data(&uval, sizeof(uval), m_arch.GetByteOrder(),
- m_arch.GetAddressByteSize());
+ DataExtractor data(&uval, sizeof(uval), m_arch.GetSpec().GetByteOrder(),
+ m_arch.GetSpec().GetAddressByteSize());
lldb::offset_t offset = 0;
if (byte_size <= 4)
scalar = data.GetMaxU32(&offset, byte_size);
@@ -1719,7 +1869,7 @@ bool Target::ReadPointerFromMemory(const Address &addr, bool prefer_file_cache,
Status &error, Address &pointer_addr) {
Scalar scalar;
if (ReadScalarIntegerFromMemory(addr, prefer_file_cache,
- m_arch.GetAddressByteSize(), false, scalar,
+ m_arch.GetSpec().GetAddressByteSize(), false, scalar,
error)) {
addr_t pointer_vm_addr = scalar.ULongLong(LLDB_INVALID_ADDRESS);
if (pointer_vm_addr != LLDB_INVALID_ADDRESS) {
@@ -2212,7 +2362,7 @@ lldb::addr_t Target::GetPersistentSymbol(const ConstString &name) {
lldb::addr_t Target::GetCallableLoadAddress(lldb::addr_t load_addr,
AddressClass addr_class) const {
addr_t code_addr = load_addr;
- switch (m_arch.GetMachine()) {
+ switch (m_arch.GetSpec().GetMachine()) {
case llvm::Triple::mips:
case llvm::Triple::mipsel:
case llvm::Triple::mips64:
@@ -2271,7 +2421,7 @@ lldb::addr_t Target::GetCallableLoadAddress(lldb::addr_t load_addr,
lldb::addr_t Target::GetOpcodeLoadAddress(lldb::addr_t load_addr,
AddressClass addr_class) const {
addr_t opcode_addr = load_addr;
- switch (m_arch.GetMachine()) {
+ switch (m_arch.GetSpec().GetMachine()) {
case llvm::Triple::mips:
case llvm::Triple::mipsel:
case llvm::Triple::mips64:
@@ -2303,7 +2453,7 @@ lldb::addr_t Target::GetBreakableLoadAddress(lldb::addr_t addr) {
addr_t breakable_addr = addr;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
- switch (m_arch.GetMachine()) {
+ switch (m_arch.GetSpec().GetMachine()) {
default:
break;
case llvm::Triple::mips:
@@ -2314,7 +2464,7 @@ lldb::addr_t Target::GetBreakableLoadAddress(lldb::addr_t addr) {
addr_t current_offset = 0;
uint32_t loop_count = 0;
Address resolved_addr;
- uint32_t arch_flags = m_arch.GetFlags();
+ uint32_t arch_flags = m_arch.GetSpec().GetFlags();
bool IsMips16 = arch_flags & ArchSpec::eMIPSAse_mips16;
bool IsMicromips = arch_flags & ArchSpec::eMIPSAse_micromips;
SectionLoadList &section_load_list = GetSectionLoadList();
@@ -2367,7 +2517,7 @@ lldb::addr_t Target::GetBreakableLoadAddress(lldb::addr_t addr) {
// Create Disassembler Instance
lldb::DisassemblerSP disasm_sp(
- Disassembler::FindPlugin(m_arch, nullptr, nullptr));
+ Disassembler::FindPlugin(m_arch.GetSpec(), nullptr, nullptr));
ExecutionContext exe_ctx;
CalculateExecutionContext(exe_ctx);
@@ -2529,6 +2679,10 @@ void Target::RunStopHooks() {
if (!m_process_sp)
return;
+
+ // Somebody might have restarted the process:
+ if (m_process_sp->GetState() != eStateStopped)
+ return;
// <rdar://problem/12027563> make sure we check that we are not stopped
// because of us running a user expression
@@ -2634,9 +2788,12 @@ void Target::RunStopHooks() {
// running the stop hooks.
if ((result.GetStatus() == eReturnStatusSuccessContinuingNoResult) ||
(result.GetStatus() == eReturnStatusSuccessContinuingResult)) {
- result.AppendMessageWithFormat("Aborting stop hooks, hook %" PRIu64
- " set the program running.",
- cur_hook_sp->GetID());
+ // But only complain if there were more stop hooks to do:
+ StopHookCollection::iterator tmp = pos;
+ if (++tmp != end)
+ result.AppendMessageWithFormat("\nAborting stop hooks, hook %" PRIu64
+ " set the program running.\n",
+ cur_hook_sp->GetID());
keep_going = false;
}
}
@@ -3505,9 +3662,11 @@ static PropertyDefinition g_experimental_properties[]{
"This will fix symbol resolution when there are name collisions between "
"ivars and local variables. "
"But it can make expressions run much more slowly."},
+ {"use-modern-type-lookup", OptionValue::eTypeBoolean, true, false, nullptr,
+ nullptr, "If true, use Clang's modern type lookup infrastructure."},
{nullptr, OptionValue::eTypeInvalid, true, 0, nullptr, nullptr, nullptr}};
-enum { ePropertyInjectLocalVars = 0 };
+enum { ePropertyInjectLocalVars = 0, ePropertyUseModernTypeLookup };
class TargetExperimentalOptionValueProperties : public OptionValueProperties {
public:
@@ -3618,6 +3777,18 @@ void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx,
true);
}
+bool TargetProperties::GetUseModernTypeLookup() const {
+ const Property *exp_property = m_collection_sp->GetPropertyAtIndex(
+ nullptr, false, ePropertyExperimental);
+ OptionValueProperties *exp_values =
+ exp_property->GetValue()->GetAsProperties();
+ if (exp_values)
+ return exp_values->GetPropertyAtIndexAsBoolean(
+ nullptr, ePropertyUseModernTypeLookup, true);
+ else
+ return true;
+}
+
ArchSpec TargetProperties::GetDefaultArchitecture() const {
OptionValueArch *value = m_collection_sp->GetPropertyAtIndexAsOptionValueArch(
nullptr, ePropertyDefaultArch);
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 505d14012d65..217cbccedf6e 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -442,10 +442,9 @@ lldb::StopInfoSP Thread::GetPrivateStopInfo() {
if (m_stop_info_override_stop_id != process_stop_id) {
m_stop_info_override_stop_id = process_stop_id;
if (m_stop_info_sp) {
- ArchSpec::StopInfoOverrideCallbackType callback =
- GetProcess()->GetStopInfoOverrideCallback();
- if (callback)
- callback(*this);
+ if (Architecture *arch =
+ process_sp->GetTarget().GetArchitecturePlugin())
+ arch->OverrideStopInfo(*this);
}
}
}
@@ -2075,6 +2074,7 @@ Unwind *Thread::GetUnwinder() {
case llvm::Triple::mips64el:
case llvm::Triple::ppc:
case llvm::Triple::ppc64:
+ case llvm::Triple::ppc64le:
case llvm::Triple::systemz:
case llvm::Triple::hexagon:
m_unwinder_ap.reset(new UnwindLLDB(*this));
diff --git a/source/Target/ThreadPlanStepInRange.cpp b/source/Target/ThreadPlanStepInRange.cpp
index caaaffea8e8a..6c5a9954f23f 100644
--- a/source/Target/ThreadPlanStepInRange.cpp
+++ b/source/Target/ThreadPlanStepInRange.cpp
@@ -191,8 +191,12 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
if (!m_sub_plan_sp) {
// Otherwise check the ShouldStopHere for step out:
m_sub_plan_sp = CheckShouldStopHereAndQueueStepOut(frame_order);
- if (log)
- log->Printf("ShouldStopHere says we should step out of this frame.");
+ if (log) {
+ if (m_sub_plan_sp)
+ log->Printf("ShouldStopHere found plan to step out of this frame.");
+ else
+ log->Printf("ShouldStopHere no plan to step out of this frame.");
+ }
} else if (log) {
log->Printf(
"Thought I stepped out, but in fact arrived at a trampoline.");
diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp
index 014c7fd27975..5057ca0a711b 100644
--- a/source/Target/ThreadPlanTracer.cpp
+++ b/source/Target/ThreadPlanTracer.cpp
@@ -11,9 +11,6 @@
// C++ Includes
#include <cstring>
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
diff --git a/source/Target/UnixSignals.cpp b/source/Target/UnixSignals.cpp
index a4ec32bd0075..150c6619859f 100644
--- a/source/Target/UnixSignals.cpp
+++ b/source/Target/UnixSignals.cpp
@@ -16,8 +16,8 @@
#include "Plugins/Process/Utility/LinuxSignals.h"
#include "Plugins/Process/Utility/MipsLinuxSignals.h"
#include "Plugins/Process/Utility/NetBSDSignals.h"
-#include "lldb/Core/ArchSpec.h"
#include "lldb/Host/StringConvert.h"
+#include "lldb/Utility/ArchSpec.h"
using namespace lldb_private;