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

José Lira Junior via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 23 08:03:16 PST 2023


https://github.com/junior-jl updated https://github.com/llvm/llvm-project/pull/73173

>From e451fe7a466f90557c301f0775d65caaa8955a8c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= <josejunior at 10xengineers.ai>
Date: Wed, 22 Nov 2023 18:26:14 -0300
Subject: [PATCH 1/2] [lldb] correct inconsistent order of messages on process
 launch

---
 lldb/source/Commands/CommandObjectProcess.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index c7ce1b1258c196c..f601316a6f673ec 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -265,8 +265,6 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
         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 +280,8 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
               exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
         }
         result.SetStatus(eReturnStatusSuccessFinishResult);
+        if (!data.empty())
+          result.AppendMessage(data);
         result.SetDidChangeProcessState(true);
       } else {
         result.AppendError(

>From 42c29e9f2526d2cce34122eab9ffe11b6befc60b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20L=2E=20Junior?= <josejunior at 10xengineers.ai>
Date: Thu, 23 Nov 2023 13:00:45 -0300
Subject: [PATCH 2/2] fixup! [lldb] correct inconsistent order of messages on
 process launch

---
 lldb/source/Commands/CommandObjectProcess.cpp          | 4 +++-
 lldb/test/Shell/Breakpoint/jit-loader_jitlink_elf.test | 2 +-
 lldb/test/Shell/Breakpoint/jit-loader_rtdyld_elf.test  | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index f601316a6f673ec..e42d637535eba47 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -264,7 +264,6 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
         // PushProcessIOHandler().
         process_sp->SyncIOHandler(0, std::chrono::seconds(2));
 
-        llvm::StringRef data = stream.GetString();
         // If we didn't have a local executable, then we wouldn't have had an
         // executable module before launch.
         if (!exe_module_sp)
@@ -280,6 +279,9 @@ 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);
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