Skip to content

Commit bd8f106

Browse files
authored
[lldb] correct inconsistent order of messages on process launch (#73173)
Fixes [#68035](#68035), where an inconsistency in the order of "Process launched" and "Process stopped" messages occurs during `process launch`. The fix involves adjusting the message output sequence in `CommandObjectProcessLaunch::DoExecute` within `source/Commands/CommandObjectProcess.cpp`. This ensures "Process launched" consistently precedes "Process stopped" when executing commands with the '-o' flag, i.e., non-interactive mode. Upon implementing this change, two tests failed: `lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test` and `lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test`. These failures were expected as they relied on the previous, now-corrected message order. Updating these tests to align with the new message sequence is part of this PR's scope.
1 parent 18a5ca1 commit bd8f106

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lldb/source/Commands/CommandObjectProcess.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,6 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
264264
// PushProcessIOHandler().
265265
process_sp->SyncIOHandler(0, std::chrono::seconds(2));
266266

267-
llvm::StringRef data = stream.GetString();
268-
if (!data.empty())
269-
result.AppendMessage(data);
270267
// If we didn't have a local executable, then we wouldn't have had an
271268
// executable module before launch.
272269
if (!exe_module_sp)
@@ -282,6 +279,11 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
282279
exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
283280
}
284281
result.SetStatus(eReturnStatusSuccessFinishResult);
282+
// This message will refer to an event that happened after the process
283+
// launched.
284+
llvm::StringRef data = stream.GetString();
285+
if (!data.empty())
286+
result.AppendMessage(data);
285287
result.SetDidChangeProcessState(true);
286288
} else {
287289
result.AppendError(

lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
# CHECK: Breakpoint 1: no locations (pending).
1212
# CHECK: (lldb) run {{.*}}
13+
# CHECK: Process {{.*}} launched: {{.*}}
1314
# CHECK: Process {{.*}} stopped
1415
# CHECK: JIT(0x{{.*}})`jitbp() at jitbp.cpp:1:15
1516
# CHECK: -> 1 int jitbp() { return 0; }
1617
# CHECK: ^
1718
# CHECK: 2 int main() { return jitbp(); }
18-
# CHECK: Process {{.*}} launched: {{.*}}

lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
# CHECK: Breakpoint 1: no locations (pending).
1616
# CHECK: (lldb) run {{.*}}
17+
# CHECK: Process {{.*}} launched: {{.*}}
1718
# CHECK: Process {{.*}} stopped
1819
# CHECK: JIT(0x{{.*}})`jitbp() at jitbp.cpp:1:15
1920
# CHECK: -> 1 int jitbp() { return 0; }
2021
# CHECK: ^
2122
# CHECK: 2 int main() { return jitbp(); }
22-
# CHECK: Process {{.*}} launched: {{.*}}

0 commit comments

Comments
 (0)