Skip to content

Commit 66c10fe

Browse files
committed
Switch at_first_stop to at_initial_stop, and address review comments.
1 parent 3ba6a55 commit 66c10fe

File tree

7 files changed

+27
-25
lines changed

7 files changed

+27
-25
lines changed

lldb/include/lldb/Target/Target.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,11 +1370,11 @@ class Target : public std::enable_shared_from_this<Target>,
13701370

13711371
bool GetAutoContinue() const { return m_auto_continue; }
13721372

1373-
void SetRunAtFirstStop(bool at_first_stop) {
1374-
m_at_first_stop = at_first_stop;
1373+
void SetRunAtInitialStop(bool at_initial_stop) {
1374+
m_at_initial_stop = at_initial_stop;
13751375
}
13761376

1377-
bool GetRunAtFirstStop() const { return m_at_first_stop; }
1377+
bool GetRunAtInitialStop() const { return m_at_initial_stop; }
13781378

13791379
void GetDescription(Stream &s, lldb::DescriptionLevel level) const;
13801380
virtual void GetSubclassDescription(Stream &s,
@@ -1386,7 +1386,7 @@ class Target : public std::enable_shared_from_this<Target>,
13861386
std::unique_ptr<ThreadSpec> m_thread_spec_up;
13871387
bool m_active = true;
13881388
bool m_auto_continue = false;
1389-
bool m_at_first_stop = true;
1389+
bool m_at_initial_stop = true;
13901390

13911391
StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid);
13921392
};

lldb/source/Commands/CommandObjectTarget.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4796,12 +4796,12 @@ class CommandObjectTargetStopHookAdd : public CommandObjectParsed,
47964796
m_one_liner.push_back(std::string(option_arg));
47974797
break;
47984798

4799-
case 'F': {
4799+
case 'I': {
48004800
bool value, success;
48014801
value = OptionArgParser::ToBoolean(option_arg, false, &success);
4802-
if (success) {
4803-
m_at_first_stop = value;
4804-
} else
4802+
if (success)
4803+
m_at_initial_stop = value;
4804+
else
48054805
error = Status::FromErrorStringWithFormat(
48064806
"invalid boolean value '%s' passed for -F option",
48074807
option_arg.str().c_str());
@@ -4833,7 +4833,7 @@ class CommandObjectTargetStopHookAdd : public CommandObjectParsed,
48334833
m_use_one_liner = false;
48344834
m_one_liner.clear();
48354835
m_auto_continue = false;
4836-
m_at_first_stop = true;
4836+
m_at_initial_stop = true;
48374837
}
48384838

48394839
std::string m_class_name;
@@ -4854,7 +4854,7 @@ class CommandObjectTargetStopHookAdd : public CommandObjectParsed,
48544854
// Instance variables to hold the values for one_liner options.
48554855
bool m_use_one_liner = false;
48564856
std::vector<std::string> m_one_liner;
4857-
bool m_at_first_stop;
4857+
bool m_at_initial_stop;
48584858

48594859
bool m_auto_continue = false;
48604860
};
@@ -5020,8 +5020,8 @@ Filter Options:
50205020
if (specifier_up)
50215021
new_hook_sp->SetSpecifier(specifier_up.release());
50225022

5023-
// Should we run at first stop:
5024-
new_hook_sp->SetRunAtFirstStop(m_options.m_at_first_stop);
5023+
// Should we run at the initial stop:
5024+
new_hook_sp->SetRunAtInitialStop(m_options.m_at_initial_stop);
50255025

50265026
// Next see if any of the thread options have been entered:
50275027

lldb/source/Commands/Options.td

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,11 +1052,12 @@ let Command = "target stop hook add" in {
10521052
def target_stop_hook_add_auto_continue : Option<"auto-continue", "G">,
10531053
Arg<"Boolean">, Desc<"The stop-hook will auto-continue after running its"
10541054
" commands.">;
1055-
def target_stop_hook_add_at_first_stop : Option<"at-first-stop", "F">,
1056-
Arg<"Boolean">, Desc<"Whether the stop-hook will trigger when lldb first "
1057-
"gains control of the process. For a process launch, this first stop "
1058-
"may happen very early on - before the loader has run. You might not want "
1059-
"some stop-hooks to run then. Defaults to true.">;
1055+
def target_stop_hook_add_at_initial_stop : Option<"at-initial-stop", "I">,
1056+
Arg<"Boolean">, Desc<"Whether the stop-hook will trigger when lldb "
1057+
"initially gains control of the process. For a process launch, this "
1058+
"initial stop may happen very early on - before the loader has run. You "
1059+
"can use this option if you do not want some stop-hooks to run then. "
1060+
"Defaults to true.">;
10601061
}
10611062

10621063
let Command = "thread backtrace" in {

lldb/source/Target/Process.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,7 +2832,7 @@ Status Process::LoadCore() {
28322832
RestoreProcessEvents();
28332833
// Since we hijacked the event stream, we will have we won't have run the
28342834
// stop hooks. Make sure we do that here:
2835-
GetTarget().RunStopHooks(true /* at_initial_stop */);
2835+
GetTarget().RunStopHooks(/* at_initial_stop= */ true);
28362836
}
28372837
return error;
28382838
}
@@ -3205,7 +3205,7 @@ void Process::CompleteAttach() {
32053205
}
32063206
// Since we hijacked the event stream, we will have we won't have run the
32073207
// stop hooks. Make sure we do that here:
3208-
GetTarget().RunStopHooks(true /* at_initial_stop */);
3208+
GetTarget().RunStopHooks(/* at_initial_stop= */ true);
32093209
}
32103210

32113211
Status Process::ConnectRemote(llvm::StringRef remote_url) {

lldb/source/Target/Target.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3056,7 +3056,7 @@ bool Target::RunStopHooks(bool at_initial_stop) {
30563056

30573057
bool no_active_hooks =
30583058
llvm::none_of(m_stop_hooks, [at_initial_stop](auto &p) {
3059-
bool should_run_now = !at_initial_stop || p.second->GetRunAtFirstStop();
3059+
bool should_run_now = !at_initial_stop || p.second->GetRunAtInitialStop();
30603060
return p.second->IsActive() && should_run_now;
30613061
});
30623062
if (no_active_hooks)
@@ -3100,8 +3100,9 @@ bool Target::RunStopHooks(bool at_initial_stop) {
31003100
m_process_sp.get(), thread_to_use_sp.get(),
31013101
thread_to_use_sp->GetStackFrameAtIndex(0).get());
31023102
num_exe_ctx = 1;
3103-
} else
3103+
} else {
31043104
return false;
3105+
}
31053106
}
31063107

31073108
StreamSP output_sp = m_debugger.GetAsyncOutputStream();
@@ -3116,7 +3117,7 @@ bool Target::RunStopHooks(bool at_initial_stop) {
31163117
StopHookSP cur_hook_sp = stop_entry.second;
31173118
if (!cur_hook_sp->IsActive())
31183119
continue;
3119-
if (at_initial_stop && !cur_hook_sp->GetRunAtFirstStop())
3120+
if (at_initial_stop && !cur_hook_sp->GetRunAtInitialStop())
31203121
continue;
31213122

31223123
bool any_thread_matched = false;
@@ -3606,7 +3607,7 @@ Status Target::Attach(ProcessAttachInfo &attach_info, Stream *stream) {
36063607

36073608
// Run the stop hooks here. Since we were hijacking the events, they
36083609
// wouldn't have gotten run as part of event delivery.
3609-
RunStopHooks(true /* at_initial_stop */);
3610+
RunStopHooks(/* at_initial_stop= */ true);
36103611

36113612
if (state != eStateStopped) {
36123613
const char *exit_desc = process_sp->GetExitDescription();

lldb/test/API/commands/target/stop-hooks/TestStopHookScripted.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_bad_handler(self):
5050

5151
def test_stop_hooks_scripted(self):
5252
"""Test that a scripted stop hook works with no specifiers"""
53-
self.stop_hooks_scripted(5, "-F false")
53+
self.stop_hooks_scripted(5, "-I false")
5454

5555
def test_stop_hooks_scripted_no_entry(self):
5656
"""Test that a scripted stop hook works with no specifiers"""

lldb/test/API/commands/target/stop-hooks/TestStopHooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def step_out_test(self):
5555
def after_expr_test(self):
5656
interp = self.dbg.GetCommandInterpreter()
5757
result = lldb.SBCommandReturnObject()
58-
interp.HandleCommand("target stop-hook add -o 'expr g_var++' -F false", result)
58+
interp.HandleCommand("target stop-hook add -o 'expr g_var++' -I false", result)
5959
self.assertTrue(result.Succeeded(), "Set the target stop hook")
6060

6161
(target, process, thread, first_bkpt) = lldbutil.run_to_source_breakpoint(

0 commit comments

Comments
 (0)