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.cpp39
1 files changed, 23 insertions, 16 deletions
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