summaryrefslogtreecommitdiff
path: root/source/Target/Process.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Target/Process.cpp')
-rw-r--r--source/Target/Process.cpp106
1 files changed, 82 insertions, 24 deletions
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 700afdb7981a..1de322aee148 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -1023,6 +1023,8 @@ Process::Process(Target &target, Listener &listener) :
m_thread_mutex (Mutex::eMutexTypeRecursive),
m_thread_list_real (this),
m_thread_list (this),
+ m_extended_thread_list (this),
+ m_extended_thread_stop_id (0),
m_notifications (),
m_image_tokens (),
m_listener (listener),
@@ -1148,6 +1150,7 @@ Process::Finalize()
m_dyld_ap.reset();
m_thread_list_real.Destroy();
m_thread_list.Destroy();
+ m_extended_thread_list.Destroy();
std::vector<Notifications> empty_notifications;
m_notifications.swap(empty_notifications);
m_image_tokens.clear();
@@ -1591,6 +1594,13 @@ Process::UpdateThreadListIfNeeded ()
m_thread_list_real.Update(real_thread_list);
m_thread_list.Update (new_thread_list);
m_thread_list.SetStopID (stop_id);
+
+ if (GetLastNaturalStopID () != m_extended_thread_stop_id)
+ {
+ // Clear any extended threads that we may have accumulated previously
+ m_extended_thread_list.Clear();
+ m_extended_thread_stop_id = GetLastNaturalStopID ();
+ }
}
}
}
@@ -2103,12 +2113,37 @@ Process::CreateBreakpointSite (const BreakpointLocationSP &owner, bool use_hardw
}
else
{
- // Report error for setting breakpoint...
- m_target.GetDebugger().GetErrorFile().Printf ("warning: failed to set breakpoint site at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
- load_addr,
- owner->GetBreakpoint().GetID(),
- owner->GetID(),
- error.AsCString() ? error.AsCString() : "unkown error");
+ bool show_error = true;
+ switch (GetState())
+ {
+ case eStateInvalid:
+ case eStateUnloaded:
+ case eStateConnected:
+ case eStateAttaching:
+ case eStateLaunching:
+ case eStateDetached:
+ case eStateExited:
+ show_error = false;
+ break;
+
+ case eStateStopped:
+ case eStateRunning:
+ case eStateStepping:
+ case eStateCrashed:
+ case eStateSuspended:
+ show_error = IsAlive();
+ break;
+ }
+
+ if (show_error)
+ {
+ // Report error for setting breakpoint...
+ m_target.GetDebugger().GetErrorFile().Printf ("warning: failed to set breakpoint site at 0x%" PRIx64 " for breakpoint %i.%i: %s\n",
+ load_addr,
+ owner->GetBreakpoint().GetID(),
+ owner->GetID(),
+ error.AsCString() ? error.AsCString() : "unkown error");
+ }
}
}
}
@@ -2350,6 +2385,7 @@ Process::DisableSoftwareBreakpoint (BreakpointSite *bp_site)
size_t
Process::ReadMemory (addr_t addr, void *buf, size_t size, Error &error)
{
+ error.Clear();
if (!GetDisableMemoryCache())
{
#if defined (VERIFY_MEMORY_READS)
@@ -2873,7 +2909,7 @@ Process::WaitForProcessStopPrivate (const TimeValue *timeout, EventSP &event_sp)
}
Error
-Process::Launch (const ProcessLaunchInfo &launch_info)
+Process::Launch (ProcessLaunchInfo &launch_info)
{
Error error;
m_abi_sp.reset();
@@ -2891,6 +2927,13 @@ Process::Launch (const ProcessLaunchInfo &launch_info)
exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path, sizeof(platform_exec_file_path));
if (exe_module->GetFileSpec().Exists())
{
+ // Install anything that might need to be installed prior to launching.
+ // For host systems, this will do nothing, but if we are connected to a
+ // remote platform it will install any needed binaries
+ error = GetTarget().Install(&launch_info);
+ if (error.Fail())
+ return error;
+
if (PrivateStateThreadIsValid ())
PausePrivateStateThread ();
@@ -4697,11 +4740,7 @@ Process::SettingsTerminate ()
ExecutionResults
Process::RunThreadPlan (ExecutionContext &exe_ctx,
lldb::ThreadPlanSP &thread_plan_sp,
- bool stop_others,
- bool run_others,
- bool unwind_on_error,
- bool ignore_breakpoints,
- uint32_t timeout_usec,
+ const EvaluateExpressionOptions &options,
Stream &errors)
{
ExecutionResults return_value = eExecutionSetupError;
@@ -4812,6 +4851,17 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
thread->QueueThreadPlan(thread_plan_sp, false); // This used to pass "true" does that make sense?
+ if (options.GetDebug())
+ {
+ // In this case, we aren't actually going to run, we just want to stop right away.
+ // Flush this thread so we will refetch the stacks and show the correct backtrace.
+ // FIXME: To make this prettier we should invent some stop reason for this, but that
+ // is only cosmetic, and this functionality is only of use to lldb developers who can
+ // live with not pretty...
+ thread->Flush();
+ return eExecutionStoppedForDebug;
+ }
+
Listener listener("lldb.process.listener.run-thread-plan");
lldb::EventSP event_to_broadcast_sp;
@@ -4853,11 +4903,12 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
TimeValue one_thread_timeout = TimeValue::Now();
TimeValue final_timeout = one_thread_timeout;
- if (run_others)
+ uint32_t timeout_usec = options.GetTimeoutUsec();
+ if (options.GetTryAllThreads())
{
// If we are running all threads then we take half the time to run all threads, bounded by
// .25 sec.
- if (timeout_usec == 0)
+ if (options.GetTimeoutUsec() == 0)
one_thread_timeout.OffsetWithMicroSeconds(default_one_thread_timeout_usec);
else
{
@@ -4969,7 +5020,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (before_first_timeout)
{
- if (run_others)
+ if (options.GetTryAllThreads())
timeout_ptr = &one_thread_timeout;
else
{
@@ -5085,7 +5136,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (log)
log->Printf ("Process::RunThreadPlan() stopped for breakpoint: %s.", stop_info_sp->GetDescription());
return_value = eExecutionHitBreakpoint;
- if (!ignore_breakpoints)
+ if (!options.DoesIgnoreBreakpoints())
{
event_to_broadcast_sp = event_sp;
}
@@ -5094,7 +5145,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
{
if (log)
log->PutCString ("Process::RunThreadPlan(): thread plan didn't successfully complete.");
- if (!unwind_on_error)
+ if (!options.DoesUnwindOnError())
event_to_broadcast_sp = event_sp;
return_value = eExecutionInterrupted;
}
@@ -5145,7 +5196,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
// either exit, or try with all threads running for the same timeout.
if (log) {
- if (run_others)
+ if (options.GetTryAllThreads())
{
uint64_t remaining_time = final_timeout - TimeValue::Now();
if (before_first_timeout)
@@ -5228,7 +5279,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
continue;
}
- if (!run_others)
+ if (!options.GetTryAllThreads())
{
if (log)
log->PutCString ("Process::RunThreadPlan(): try_all_threads was false, we stopped so now we're quitting.");
@@ -5301,8 +5352,8 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
// 1) The execution successfully completed
// 2) We hit a breakpoint, and ignore_breakpoints was true
// 3) We got some other error, and discard_on_error was true
- bool should_unwind = (return_value == eExecutionInterrupted && unwind_on_error)
- || (return_value == eExecutionHitBreakpoint && ignore_breakpoints);
+ bool should_unwind = (return_value == eExecutionInterrupted && options.DoesUnwindOnError())
+ || (return_value == eExecutionHitBreakpoint && options.DoesIgnoreBreakpoints());
if (return_value == eExecutionCompleted
|| should_unwind)
@@ -5422,7 +5473,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
if (log)
log->PutCString("Process::RunThreadPlan(): execution set up error.");
- if (unwind_on_error)
+ if (options.DoesUnwindOnError())
{
thread->DiscardThreadPlansUpToPlan (thread_plan_sp);
thread_plan_sp->SetPrivate (orig_plan_private);
@@ -5446,7 +5497,7 @@ Process::RunThreadPlan (ExecutionContext &exe_ctx,
{
if (log)
log->PutCString("Process::RunThreadPlan(): thread plan stopped in mid course");
- if (unwind_on_error && thread_plan_sp)
+ if (options.DoesUnwindOnError() && thread_plan_sp)
{
if (log)
log->PutCString("Process::RunThreadPlan(): discarding thread plan 'cause unwind_on_error is set.");
@@ -5518,6 +5569,9 @@ Process::ExecutionResultAsCString (ExecutionResults result)
case eExecutionTimedOut:
result_name = "eExecutionTimedOut";
break;
+ case eExecutionStoppedForDebug:
+ result_name = "eExecutionStoppedForDebug";
+ break;
}
return result_name;
}
@@ -5633,7 +5687,7 @@ Process::DidExec ()
{
Target &target = GetTarget();
target.CleanupProcess ();
- target.ClearModules();
+ target.ClearModules(false);
m_dynamic_checkers_ap.reset();
m_abi_sp.reset();
m_system_runtime_ap.reset();
@@ -5649,5 +5703,9 @@ Process::DidExec ()
// Flush the process (threads and all stack frames) after running CompleteAttach()
// in case the dynamic loader loaded things in new locations.
Flush();
+
+ // After we figure out what was loaded/unloaded in CompleteAttach,
+ // we need to let the target know so it can do any cleanup it needs to.
+ target.DidExec();
}