https://github.com/jimingham created 
https://github.com/llvm/llvm-project/pull/139187

I suspect the test may be failing because lld doesn't behave the same way the 
native Darwin linker does.  Trying that theory here...

>From 3198c53fbf642694fde0a99a29ad779208ea8b08 Mon Sep 17 00:00:00 2001
From: Jim Ingham <jing...@apple.com>
Date: Thu, 8 May 2025 16:59:10 -0700
Subject: [PATCH 1/2] Add more logging so I can figure out why
 TestBranchIslands.py is failing but only on the bot.

---
 .../DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp    | 9 +++++++++
 lldb/test/API/macosx/branch-islands/TestBranchIslands.py | 9 ++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 578ab12268ea3..6c3040ef1a1da 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -1038,6 +1038,15 @@ DynamicLoaderDarwin::GetStepThroughTrampolinePlan(Thread 
&thread,
     static RegularExpression g_branch_island_regex(g_branch_island_pattern);
 
     bool is_branch_island = g_branch_island_regex.Execute(current_name);
+    // FIXME: this is extra logging so I can figure out why this test is 
failing
+    // on the bot but not locally with all the same tools, etc...
+    if (thread_plan_sp && is_branch_island) {
+      if (log) {
+        StreamString s;
+        thread_plan_sp->GetDescription(&s, eDescriptionLevelVerbose);
+        LLDB_LOGF(log, "Am at a branch island, but already had plan: \n\t%s", 
s.GetData());
+      }
+    }
     if (!thread_plan_sp && is_branch_island) {
       thread_plan_sp = std::make_shared<ThreadPlanStepInstruction>(
           thread,
diff --git a/lldb/test/API/macosx/branch-islands/TestBranchIslands.py 
b/lldb/test/API/macosx/branch-islands/TestBranchIslands.py
index c79840b400432..a8dd1886d5568 100644
--- a/lldb/test/API/macosx/branch-islands/TestBranchIslands.py
+++ b/lldb/test/API/macosx/branch-islands/TestBranchIslands.py
@@ -2,7 +2,7 @@
 Make sure that we can step in across an arm64 branch island
 """
 
-
+import os
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.lldbtest import *
@@ -32,6 +32,9 @@ def do_test(self):
         trace_before = lldbutil.print_stacktrace(thread, True)
         func_before = thread.frames[0].function
 
+        log_file_path = os.path.join(self.getBuildDir(), "step-log.txt")
+        self.runCmd(f"log enable -f {log_file_path} lldb step")
+        
         thread.StepInto()
         stop_frame = thread.frames[0]
         # This is failing on the bot, but I can't reproduce the failure
@@ -59,6 +62,10 @@ def do_test(self):
             print(
                 f"\nStop disassembly:\n {lldbutil.disassemble(target, 
stop_frame.function)}"
             )
+            with open(log_file_path, "r") as f:
+                data = f.read()
+                print("Step Log:")
+                print(data)
 
         self.assertIn("foo", stop_frame.name, "Stepped into foo")
         var = stop_frame.FindVariable("a_variable_in_foo")

>From 97524326b677db911969170fbeb74a40665fb3eb Mon Sep 17 00:00:00 2001
From: Jim Ingham <jing...@apple.com>
Date: Thu, 8 May 2025 17:58:18 -0700
Subject: [PATCH 2/2] Use the system linker for this test, I'm guessing lld
 isn't handling this correctly.

---
 lldb/test/API/macosx/branch-islands/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/test/API/macosx/branch-islands/Makefile 
b/lldb/test/API/macosx/branch-islands/Makefile
index 062e947f6d6ee..ff341522e15de 100644
--- a/lldb/test/API/macosx/branch-islands/Makefile
+++ b/lldb/test/API/macosx/branch-islands/Makefile
@@ -4,7 +4,7 @@ CFLAGS_EXTRAS := -std=c99
 include Makefile.rules
 
 a.out: main.o padding1.o padding2.o padding3.o padding4.o foo.o
-       ${CC} ${LDFLAGS} foo.o padding1.o padding2.o padding3.o padding4.o 
main.o -o a.out
+       ${CC} ${LDFLAGS} -fuse-ld=/usr/bin/ld foo.o padding1.o padding2.o 
padding3.o padding4.o main.o -o a.out
 
 %.o: $(SRCDIR)/%.s
        ${CC} -c $<

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to