aboutsummaryrefslogtreecommitdiff
path: root/source/Target
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-09-06 14:32:30 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-09-06 14:32:30 +0000
commit027f1c9655391dcb2b0117f931f720211ac933db (patch)
tree94980f450aa3daec3e1fec217374704ad62cfe45 /source/Target
parent5e95aa85bb660d45e9905ef1d7180b2678280660 (diff)
downloadsrc-5e79ed8ce3c1ca5e7fc7869dac06d6ce7f3686eb.tar.gz
src-5e79ed8ce3c1ca5e7fc7869dac06d6ce7f3686eb.zip
Vendor import of (stripped) lldb trunk r242221:vendor/lldb/lldb-trunk-r242221
Diffstat (limited to 'source/Target')
-rw-r--r--source/Target/Platform.cpp37
-rw-r--r--source/Target/Process.cpp35
-rw-r--r--source/Target/ProcessLaunchInfo.cpp7
-rw-r--r--source/Target/StopInfo.cpp12
-rw-r--r--source/Target/ThreadPlanCallFunction.cpp52
-rw-r--r--source/Target/ThreadPlanCallFunctionUsingABI.cpp91
-rw-r--r--source/Target/ThreadPlanStepOverRange.cpp2
-rw-r--r--source/Target/UnixSignals.cpp64
8 files changed, 248 insertions, 52 deletions
diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp
index 6758ecf7e22e..2b586933ccd4 100644
--- a/source/Target/Platform.cpp
+++ b/source/Target/Platform.cpp
@@ -36,6 +36,7 @@
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/Utils.h"
#include "llvm/Support/FileSystem.h"
@@ -1536,27 +1537,6 @@ Platform::CalculateMD5 (const FileSpec& file_spec,
return false;
}
-Error
-Platform::LaunchNativeProcess (
- ProcessLaunchInfo &launch_info,
- lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate,
- NativeProcessProtocolSP &process_sp)
-{
- // Platforms should override this implementation if they want to
- // support lldb-gdbserver.
- return Error("unimplemented");
-}
-
-Error
-Platform::AttachNativeProcess (lldb::pid_t pid,
- lldb_private::NativeProcessProtocol::NativeDelegate &native_delegate,
- NativeProcessProtocolSP &process_sp)
-{
- // Platforms should override this implementation if they want to
- // support lldb-gdbserver.
- return Error("unimplemented");
-}
-
void
Platform::SetLocalCacheDirectory (const char* local)
{
@@ -1951,3 +1931,18 @@ Platform::GetCacheHostname ()
{
return GetHostname ();
}
+
+const UnixSignalsSP &
+Platform::GetRemoteUnixSignals()
+{
+ static const auto s_default_unix_signals_sp = std::make_shared<UnixSignals>();
+ return s_default_unix_signals_sp;
+}
+
+const UnixSignalsSP &
+Platform::GetUnixSignals()
+{
+ if (IsHost())
+ return Host::GetUnixSignals();
+ return GetRemoteUnixSignals();
+}
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 41942829ca55..3abae4fce5b1 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -693,7 +693,7 @@ Process::GetStaticBroadcasterClass ()
// Process constructor
//----------------------------------------------------------------------
Process::Process(Target &target, Listener &listener) :
- Process(target, listener, Host::GetUnixSignals ())
+ Process(target, listener, UnixSignals::Create(HostInfo::GetArchitecture()))
{
// This constructor just delegates to the full Process constructor,
// defaulting to using the Host's UnixSignals.
@@ -754,6 +754,7 @@ Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_s
m_force_next_event_delivery (false),
m_last_broadcast_state (eStateInvalid),
m_destroy_in_process (false),
+ m_can_interpret_function_calls(false),
m_can_jit(eCanJITDontKnow)
{
CheckInWithManager ();
@@ -763,14 +764,14 @@ Process::Process(Target &target, Listener &listener, const UnixSignalsSP &unix_s
log->Printf ("%p Process::Process()", static_cast<void*>(this));
if (!m_unix_signals_sp)
- m_unix_signals_sp.reset (new UnixSignals ());
+ m_unix_signals_sp = std::make_shared<UnixSignals>();
SetEventName (eBroadcastBitStateChanged, "state-changed");
SetEventName (eBroadcastBitInterrupt, "interrupt");
SetEventName (eBroadcastBitSTDOUT, "stdout-available");
SetEventName (eBroadcastBitSTDERR, "stderr-available");
SetEventName (eBroadcastBitProfileData, "profile-data-available");
-
+
m_private_state_control_broadcaster.SetEventName (eBroadcastInternalStateControlStop , "control-stop" );
m_private_state_control_broadcaster.SetEventName (eBroadcastInternalStateControlPause , "control-pause" );
m_private_state_control_broadcaster.SetEventName (eBroadcastInternalStateControlResume, "control-resume");
@@ -1145,6 +1146,7 @@ Process::HandleProcessStateChangedEvent (const EventSP &event_sp,
// Prefer a thread that has just completed its plan over another thread as current thread.
ThreadSP plan_thread;
ThreadSP other_thread;
+
const size_t num_threads = thread_list.GetSize();
size_t i;
for (i = 0; i < num_threads; ++i)
@@ -1157,10 +1159,22 @@ Process::HandleProcessStateChangedEvent (const EventSP &event_sp,
case eStopReasonNone:
break;
+ case eStopReasonSignal:
+ {
+ // Don't select a signal thread if we weren't going to stop at that
+ // signal. We have to have had another reason for stopping here, and
+ // the user doesn't want to see this thread.
+ uint64_t signo = thread->GetStopInfo()->GetValue();
+ if (process_sp->GetUnixSignals()->GetShouldStop(signo))
+ {
+ if (!other_thread)
+ other_thread = thread;
+ }
+ break;
+ }
case eStopReasonTrace:
case eStopReasonBreakpoint:
case eStopReasonWatchpoint:
- case eStopReasonSignal:
case eStopReasonException:
case eStopReasonExec:
case eStopReasonThreadExiting:
@@ -1510,7 +1524,7 @@ Process::SetProcessExitStatus (void *callback_baton,
{
const char *signal_cstr = NULL;
if (signo)
- signal_cstr = process_sp->GetUnixSignals().GetSignalAsCString (signo);
+ signal_cstr = process_sp->GetUnixSignals()->GetSignalAsCString(signo);
process_sp->SetExitStatus (exit_status, signal_cstr);
}
@@ -2998,6 +3012,13 @@ Process::SetCanJIT (bool can_jit)
m_can_jit = (can_jit ? eCanJITYes : eCanJITNo);
}
+void
+Process::SetCanRunCode (bool can_run_code)
+{
+ SetCanJIT(can_run_code);
+ m_can_interpret_function_calls = can_run_code;
+}
+
Error
Process::DeallocateMemory (addr_t ptr)
{
@@ -4088,11 +4109,11 @@ Process::SetUnixSignals (const UnixSignalsSP &signals_sp)
m_unix_signals_sp = signals_sp;
}
-UnixSignals &
+const lldb::UnixSignalsSP &
Process::GetUnixSignals ()
{
assert (m_unix_signals_sp && "null m_unix_signals_sp");
- return *m_unix_signals_sp;
+ return m_unix_signals_sp;
}
lldb::ByteOrder
diff --git a/source/Target/ProcessLaunchInfo.cpp b/source/Target/ProcessLaunchInfo.cpp
index 30c5aee63cad..bd2e1bc4c4a1 100644
--- a/source/Target/ProcessLaunchInfo.cpp
+++ b/source/Target/ProcessLaunchInfo.cpp
@@ -284,6 +284,13 @@ ProcessLaunchInfo::FinalizeFileActions (Target *target, bool default_to_use_pty)
log->Printf ("ProcessLaunchInfo::%s at least one of stdin/stdout/stderr was not set, evaluating default handling",
__FUNCTION__);
+ if (m_flags.Test(eLaunchFlagLaunchInTTY))
+ {
+ // Do nothing, if we are launching in a remote terminal
+ // no file actions should be done at all.
+ return;
+ }
+
if (m_flags.Test(eLaunchFlagDisableSTDIO))
{
if (log)
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index 76e5f374f952..4f6ef7a92949 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -891,7 +891,7 @@ public:
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
- return thread_sp->GetProcess()->GetUnixSignals().GetShouldStop (m_value);
+ return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value);
return false;
}
@@ -900,7 +900,7 @@ public:
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
- return thread_sp->GetProcess()->GetUnixSignals().GetShouldStop (m_value);
+ return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value);
return false;
}
@@ -912,13 +912,13 @@ public:
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
- bool should_notify = thread_sp->GetProcess()->GetUnixSignals().GetShouldNotify (m_value);
+ bool should_notify = thread_sp->GetProcess()->GetUnixSignals()->GetShouldNotify(m_value);
if (should_notify)
{
StreamString strm;
strm.Printf ("thread %d received signal: %s",
thread_sp->GetIndexID(),
- thread_sp->GetProcess()->GetUnixSignals().GetSignalAsCString (m_value));
+ thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsCString(m_value));
Process::ProcessEventData::AddRestartedReason(event_ptr, strm.GetData());
}
return should_notify;
@@ -933,7 +933,7 @@ public:
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
- if (thread_sp->GetProcess()->GetUnixSignals().GetShouldSuppress(m_value) == false)
+ if (thread_sp->GetProcess()->GetUnixSignals()->GetShouldSuppress(m_value) == false)
thread_sp->SetResumeSignal(m_value);
}
}
@@ -947,7 +947,7 @@ public:
if (thread_sp)
{
StreamString strm;
- const char *signal_name = thread_sp->GetProcess()->GetUnixSignals().GetSignalAsCString (m_value);
+ const char *signal_name = thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsCString(m_value);
if (signal_name)
strm.Printf("signal %s", signal_name);
else
diff --git a/source/Target/ThreadPlanCallFunction.cpp b/source/Target/ThreadPlanCallFunction.cpp
index e742ece7ec50..e7b3abd3c941 100644
--- a/source/Target/ThreadPlanCallFunction.cpp
+++ b/source/Target/ThreadPlanCallFunction.cpp
@@ -147,15 +147,16 @@ ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
m_trap_exceptions (options.GetTrapExceptions()),
m_function_addr (function),
m_function_sp (0),
- m_return_type (return_type),
m_takedown_done (false),
m_should_clear_objc_exception_bp(false),
m_should_clear_cxx_exception_bp (false),
- m_stop_address (LLDB_INVALID_ADDRESS)
+ m_stop_address (LLDB_INVALID_ADDRESS),
+ m_return_type (return_type)
{
- lldb::addr_t start_load_addr;
- ABI *abi;
- lldb::addr_t function_load_addr;
+ lldb::addr_t start_load_addr = LLDB_INVALID_ADDRESS;
+ lldb::addr_t function_load_addr = LLDB_INVALID_ADDRESS;
+ ABI *abi = nullptr;
+
if (!ConstructorSetup (thread, abi, start_load_addr, function_load_addr))
return;
@@ -171,6 +172,27 @@ ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
m_valid = true;
}
+ThreadPlanCallFunction::ThreadPlanCallFunction(Thread &thread,
+ const Address &function,
+ const EvaluateExpressionOptions &options) :
+ ThreadPlan(ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
+ m_valid(false),
+ m_stop_other_threads(options.GetStopOthers()),
+ m_unwind_on_error(options.DoesUnwindOnError()),
+ m_ignore_breakpoints(options.DoesIgnoreBreakpoints()),
+ m_debug_execution(options.GetDebug()),
+ m_trap_exceptions(options.GetTrapExceptions()),
+ m_function_addr(function),
+ m_function_sp(0),
+ m_takedown_done(false),
+ m_should_clear_objc_exception_bp(false),
+ m_should_clear_cxx_exception_bp(false),
+ m_stop_address(LLDB_INVALID_ADDRESS),
+ m_return_type(ClangASTType())
+{
+
+}
+
ThreadPlanCallFunction::~ThreadPlanCallFunction ()
{
DoTakedown(PlanSucceeded());
@@ -222,13 +244,7 @@ ThreadPlanCallFunction::DoTakedown (bool success)
{
if (success)
{
- ProcessSP process_sp (m_thread.GetProcess());
- const ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
- if (abi && m_return_type.IsValid())
- {
- const bool persistent = false;
- m_return_valobj_sp = abi->GetReturnValueObject (m_thread, m_return_type, persistent);
- }
+ SetReturnValue();
}
if (log)
log->Printf ("ThreadPlanCallFunction(%p): DoTakedown called for thread 0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
@@ -574,3 +590,15 @@ ThreadPlanCallFunction::RestoreThreadState()
return GetThread().RestoreThreadStateFromCheckpoint(m_stored_thread_state);
}
+
+void
+ThreadPlanCallFunction::SetReturnValue()
+{
+ ProcessSP process_sp(m_thread.GetProcess());
+ const ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+ if (abi && m_return_type.IsValid())
+ {
+ const bool persistent = false;
+ m_return_valobj_sp = abi->GetReturnValueObject(m_thread, m_return_type, persistent);
+ }
+}
diff --git a/source/Target/ThreadPlanCallFunctionUsingABI.cpp b/source/Target/ThreadPlanCallFunctionUsingABI.cpp
new file mode 100644
index 000000000000..53fabd2464e6
--- /dev/null
+++ b/source/Target/ThreadPlanCallFunctionUsingABI.cpp
@@ -0,0 +1,91 @@
+//===-- ThreadPlanCallFunctionUsingABI.cpp ------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Target/ThreadPlanCallFunctionUsingABI.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+
+// Project includes
+#include "lldb/Core/Address.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Stream.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+//--------------------------------------------------------------------------------------------
+// ThreadPlanCallFunctionUsingABI: Plan to call a single function using the ABI instead of JIT
+//-------------------------------------------------------------------------------------------
+ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI (Thread &thread,
+ const Address &function,
+ llvm::Type &prototype,
+ llvm::Type &return_type,
+ llvm::ArrayRef<ABI::CallArgument> args,
+ const EvaluateExpressionOptions &options) :
+ ThreadPlanCallFunction(thread,function,options),
+ m_return_type(return_type)
+{
+ lldb::addr_t start_load_addr = LLDB_INVALID_ADDRESS;
+ lldb::addr_t function_load_addr = LLDB_INVALID_ADDRESS;
+ ABI *abi = nullptr;
+
+ if (!ConstructorSetup(thread, abi, start_load_addr, function_load_addr))
+ return;
+
+ if (!abi->PrepareTrivialCall(thread,
+ m_function_sp,
+ function_load_addr,
+ start_load_addr,
+ prototype,
+ args))
+ return;
+
+ ReportRegisterState("ABI Function call was set up. Register state was:");
+
+ m_valid = true;
+}
+
+ThreadPlanCallFunctionUsingABI::~ThreadPlanCallFunctionUsingABI()
+{
+
+}
+
+void
+ThreadPlanCallFunctionUsingABI::GetDescription(Stream *s, DescriptionLevel level)
+{
+ if (level == eDescriptionLevelBrief)
+ {
+ s->Printf("Function call thread plan using ABI instead of JIT");
+ }
+ else
+ {
+ TargetSP target_sp(m_thread.CalculateTarget());
+ s->Printf("Thread plan to call 0x%" PRIx64" using ABI instead of JIT", m_function_addr.GetLoadAddress(target_sp.get()));
+ }
+}
+
+void
+ThreadPlanCallFunctionUsingABI::SetReturnValue()
+{
+ ProcessSP process_sp(m_thread.GetProcess());
+ const ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+
+ // Ask the abi for the return value
+ if (abi)
+ {
+ const bool persistent = false;
+ m_return_valobj_sp = abi->GetReturnValueObject(m_thread, m_return_type, persistent);
+ }
+}
diff --git a/source/Target/ThreadPlanStepOverRange.cpp b/source/Target/ThreadPlanStepOverRange.cpp
index 701e93d3c4de..aba89224239c 100644
--- a/source/Target/ThreadPlanStepOverRange.cpp
+++ b/source/Target/ThreadPlanStepOverRange.cpp
@@ -430,7 +430,7 @@ ThreadPlanStepOverRange::DoWillResume (lldb::StateType resume_state, bool curren
const InlineFunctionInfo *inline_info = frame_block->GetInlinedFunctionInfo();
const char *name;
if (inline_info)
- name = inline_info->GetName().AsCString();
+ name = inline_info->GetName(frame_block->CalculateSymbolContextFunction()->GetLanguage()).AsCString();
else
name = "<unknown-notinlined>";
diff --git a/source/Target/UnixSignals.cpp b/source/Target/UnixSignals.cpp
index 7f57579c1ee5..91579e8d7852 100644
--- a/source/Target/UnixSignals.cpp
+++ b/source/Target/UnixSignals.cpp
@@ -13,16 +13,21 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Core/ArchSpec.h"
#include "lldb/Host/StringConvert.h"
+#include "Plugins/Process/Utility/FreeBSDSignals.h"
+#include "Plugins/Process/Utility/LinuxSignals.h"
+#include "Plugins/Process/Utility/MipsLinuxSignals.h"
+
using namespace lldb_private;
-UnixSignals::Signal::Signal
+UnixSignals::Signal::Signal
(
- const char *name,
- const char *short_name,
- bool default_suppress,
- bool default_stop,
+ const char *name,
+ const char *short_name,
+ bool default_suppress,
+ bool default_stop,
bool default_notify,
const char *description
) :
@@ -37,6 +42,34 @@ UnixSignals::Signal::Signal
m_description.assign (description);
}
+lldb::UnixSignalsSP
+UnixSignals::Create(const ArchSpec &arch)
+{
+ const auto &triple = arch.GetTriple();
+ switch (triple.getOS())
+ {
+ case llvm::Triple::Linux:
+ {
+ switch (triple.getArch())
+ {
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel:
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
+ return std::make_shared<MipsLinuxSignals>();
+ default:
+ return std::make_shared<LinuxSignals>();
+ }
+ }
+ case llvm::Triple::FreeBSD:
+ case llvm::Triple::OpenBSD:
+ case llvm::Triple::NetBSD:
+ return std::make_shared<FreeBSDSignals>();
+ default:
+ return std::make_shared<UnixSignals>();
+ }
+}
+
//----------------------------------------------------------------------
// UnixSignals constructor
//----------------------------------------------------------------------
@@ -45,6 +78,11 @@ UnixSignals::UnixSignals ()
Reset ();
}
+UnixSignals::UnixSignals(const UnixSignals &rhs)
+ : m_signals(rhs.m_signals)
+{
+}
+
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
@@ -291,3 +329,19 @@ UnixSignals::SetShouldNotify (const char *signal_name, bool value)
return SetShouldNotify (signo, value);
return false;
}
+
+int32_t
+UnixSignals::GetNumSignals() const
+{
+ return m_signals.size();
+}
+
+int32_t
+UnixSignals::GetSignalAtIndex(int32_t index) const
+{
+ if (index < 0 || m_signals.size() <= static_cast<size_t>(index))
+ return LLDB_INVALID_SIGNAL_NUMBER;
+ auto it = m_signals.begin();
+ std::advance(it, index);
+ return it->first;
+}