[Lldb-commits] [lldb] bd8f106 - [lldb] correct inconsistent order of messages on process launch (#73173)

via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 24 07:48:21 PST 2023


Author: José Lira Junior
Date: 2023-11-24T15:48:16Z
New Revision: bd8f1068cad06b0f0342ac7ef351bf01c2e27322

URL: https://github.com/llvm/llvm-project/commit/bd8f1068cad06b0f0342ac7ef351bf01c2e27322
DIFF: https://github.com/llvm/llvm-project/commit/bd8f1068cad06b0f0342ac7ef351bf01c2e27322.diff

LOG: [lldb] correct inconsistent order of messages on process launch (#73173)

Fixes [#68035](https://github.com/llvm/llvm-project/issues/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.

Added: 
    

Modified: 
    lldb/source/Commands/CommandObjectProcess.cpp
    lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test
    lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test

Removed: 
    


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index c7ce1b1258c196c..e42d637535eba47 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -264,9 +264,6 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
         // PushProcessIOHandler().
         process_sp->SyncIOHandler(0, std::chrono::seconds(2));
 
-        llvm::StringRef data = stream.GetString();
-        if (!data.empty())
-          result.AppendMessage(data);
         // If we didn't have a local executable, then we wouldn't have had an
         // executable module before launch.
         if (!exe_module_sp)
@@ -282,6 +279,11 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
               exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
         }
         result.SetStatus(eReturnStatusSuccessFinishResult);
+        // This message will refer to an event that happened after the process
+        // launched.
+        llvm::StringRef data = stream.GetString();
+        if (!data.empty())
+          result.AppendMessage(data);
         result.SetDidChangeProcessState(true);
       } else {
         result.AppendError(

diff  --git a/lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test b/lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test
index bbb4830a416b5e5..52c86fa5530bf75 100644
--- a/lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test
+++ b/lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test
@@ -10,9 +10,9 @@
 
 # CHECK: Breakpoint 1: no locations (pending).
 # CHECK: (lldb) run {{.*}}
+# CHECK: Process {{.*}} launched: {{.*}}
 # CHECK: Process {{.*}} stopped
 # CHECK: JIT(0x{{.*}})`jitbp() at jitbp.cpp:1:15
 # CHECK: -> 1    int jitbp() { return 0; }
 # CHECK:                       ^
 # CHECK:    2    int main() { return jitbp(); }
-# CHECK: Process {{.*}} launched: {{.*}}

diff  --git a/lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test b/lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test
index 8c289e2870ae6dd..b34a5673936f550 100644
--- a/lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test
+++ b/lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test
@@ -14,9 +14,9 @@
 
 # CHECK: Breakpoint 1: no locations (pending).
 # CHECK: (lldb) run {{.*}}
+# CHECK: Process {{.*}} launched: {{.*}}
 # CHECK: Process {{.*}} stopped
 # CHECK: JIT(0x{{.*}})`jitbp() at jitbp.cpp:1:15
 # CHECK: -> 1    int jitbp() { return 0; }
 # CHECK:                       ^
 # CHECK:    2    int main() { return jitbp(); }
-# CHECK: Process {{.*}} launched: {{.*}}


        


More information about the lldb-commits mailing list