summaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectTarget.cpp
diff options
context:
space:
mode:
authorjimingham <jingham@apple.com>2025-05-01 13:46:19 -0700
committerGitHub <noreply@github.com>2025-05-01 13:46:19 -0700
commit4fdb8cb42f73ebec9a3bdd37b2f27c222f9afd87 (patch)
tree2aa248832488e93bb90af39a49417a4099ec0598 /lldb/source/Commands/CommandObjectTarget.cpp
parent42f5d716cbb8b391203eb880ac81f6272fd611f1 (diff)
Make stop-hooks fire when lldb first gains control of a process. (#137410)
stop-hooks are supposed to trigger every time the process stops, but as initially implemented they would only fire when control was returned to the user. So for instance when a process was launched the stop hook would only trigger when the process hit a breakpoint or crashed. However, it would be really useful to be able to trigger a stop hook when lldb first gains control over the process. One way to do that would be to implement general "target lifecycle events" and then send process created events that users could bind actions to. OTOH, extending the stop hooks to fire when lldb first gains control over the process is a pretty natural extension to the notion of a stop hook. So this patch takes the shorter route to that ability by making stop-hooks fire when lldb first gains control over the process. I also added the ability to specify whether to trigger the stop hook "on gaining control". I'm on the fence about whether to set the default to be "trigger on gaining control" or "don't trigger on gaining control". Since I think it's a generally useful feature, I've set the default to "trigger on gaining control".
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index e5421e566cd5..8c877fc97105 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -4794,6 +4794,17 @@ public:
m_one_liner.push_back(std::string(option_arg));
break;
+ case 'I': {
+ bool value, success;
+ value = OptionArgParser::ToBoolean(option_arg, false, &success);
+ if (success)
+ m_at_initial_stop = value;
+ else
+ error = Status::FromErrorStringWithFormat(
+ "invalid boolean value '%s' passed for -F option",
+ option_arg.str().c_str());
+ } break;
+
default:
llvm_unreachable("Unimplemented option");
}
@@ -4820,6 +4831,7 @@ public:
m_use_one_liner = false;
m_one_liner.clear();
m_auto_continue = false;
+ m_at_initial_stop = true;
}
std::string m_class_name;
@@ -4840,6 +4852,7 @@ public:
// Instance variables to hold the values for one_liner options.
bool m_use_one_liner = false;
std::vector<std::string> m_one_liner;
+ bool m_at_initial_stop;
bool m_auto_continue = false;
};
@@ -5005,6 +5018,9 @@ protected:
if (specifier_up)
new_hook_sp->SetSpecifier(specifier_up.release());
+ // Should we run at the initial stop:
+ new_hook_sp->SetRunAtInitialStop(m_options.m_at_initial_stop);
+
// Next see if any of the thread options have been entered:
if (m_options.m_thread_specified) {