https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/129301

>From a26c5596ac599f1b51cffebd658f38233899998e Mon Sep 17 00:00:00 2001
From: Jim Ingham <jing...@apple.com>
Date: Fri, 28 Feb 2025 11:45:51 -0800
Subject: [PATCH 1/2] Control the "step out through thunk" logic explicitly
 when pushing thread plans.

That allow the thread plan that is trying to step through a thunk to its target
to step out of a function it has stepped into without also stepping out past
the thunk we were trying to step through.
---
 .../lldb/Target/ThreadPlanShouldStopHere.h        |  3 ++-
 lldb/source/Target/ThreadPlanShouldStopHere.cpp   | 15 +++++++++++----
 lldb/source/Target/ThreadPlanStepInRange.cpp      |  3 ++-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h 
b/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
index 54b30291c3995..d0094c90b91a5 100644
--- a/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
+++ b/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
@@ -59,7 +59,8 @@ class ThreadPlanShouldStopHere {
     eNone = 0,
     eAvoidInlines = (1 << 0),
     eStepInAvoidNoDebug = (1 << 1),
-    eStepOutAvoidNoDebug = (1 << 2)
+    eStepOutAvoidNoDebug = (1 << 2),
+    eStepOutPastThunks = (1 << 3)
   };
 
   // Constructors and Destructors
diff --git a/lldb/source/Target/ThreadPlanShouldStopHere.cpp 
b/lldb/source/Target/ThreadPlanShouldStopHere.cpp
index fa6bc08a9914d..be6bd981c72bc 100644
--- a/lldb/source/Target/ThreadPlanShouldStopHere.cpp
+++ b/lldb/source/Target/ThreadPlanShouldStopHere.cpp
@@ -8,6 +8,7 @@
 
 #include "lldb/Target/ThreadPlanShouldStopHere.h"
 #include "lldb/Symbol/Symbol.h"
+#include "lldb/Target/Language.h"
 #include "lldb/Target/LanguageRuntime.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Thread.h"
@@ -83,7 +84,11 @@ bool ThreadPlanShouldStopHere::DefaultShouldStopHereCallback(
     if (Symbol *symbol = frame->GetSymbolContext(eSymbolContextSymbol).symbol) 
{
       ProcessSP process_sp(current_plan->GetThread().GetProcess());
       for (auto *runtime : process_sp->GetLanguageRuntimes()) {
-        if (runtime->IsSymbolARuntimeThunk(*symbol)) {
+        if (runtime->IsSymbolARuntimeThunk(*symbol)
+             && flags.Test(ThreadPlanShouldStopHere::eStepOutPastThunks)) {
+         LLDB_LOGF(log, "Stepping out past a language thunk %s for: %s",
+                   frame->GetFunctionName(),
+                   
Language::GetNameForLanguageType(runtime->GetLanguageType()));
           should_stop_here = false;
           break;
         }
@@ -131,9 +136,11 @@ ThreadPlanSP 
ThreadPlanShouldStopHere::DefaultStepFromHereCallback(
       // because it's marked line 0.
       bool is_thunk = false;
       for (auto *runtime : process_sp->GetLanguageRuntimes()) {
-        if (runtime->IsSymbolARuntimeThunk(*sc.symbol)) {
-          LLDB_LOGF(log, "In runtime thunk %s - stepping out.",
-                    sc.symbol->GetName().GetCString());
+        if (runtime->IsSymbolARuntimeThunk(*sc.symbol)
+             && flags.Test(ThreadPlanShouldStopHere::eStepOutPastThunks)) {
+          LLDB_LOGF(log, "Stepping out past a language thunk %s for: %s",
+                   frame->GetFunctionName(),
+                   
Language::GetNameForLanguageType(runtime->GetLanguageType()));
           is_thunk = true;
           break;
         }
diff --git a/lldb/source/Target/ThreadPlanStepInRange.cpp 
b/lldb/source/Target/ThreadPlanStepInRange.cpp
index 109d1b6b3435b..3affeae1ee388 100644
--- a/lldb/source/Target/ThreadPlanStepInRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -27,7 +27,8 @@ using namespace lldb;
 using namespace lldb_private;
 
 uint32_t ThreadPlanStepInRange::s_default_flag_values =
-    ThreadPlanShouldStopHere::eStepInAvoidNoDebug;
+    ThreadPlanShouldStopHere::eStepInAvoidNoDebug | 
+    ThreadPlanShouldStopHere::eStepOutPastThunks;
 
 // ThreadPlanStepInRange: Step through a stack range, either stepping over or
 // into based on the value of \a type.

>From 2ce4ca483a7f6a812d35b94a99425b250fe4a43a Mon Sep 17 00:00:00 2001
From: Jim Ingham <jing...@apple.com>
Date: Fri, 28 Feb 2025 13:40:05 -0800
Subject: [PATCH 2/2] clang-format

---
 .../Target/ThreadPlanShouldStopHere.cpp       | 22 ++++++++++---------
 lldb/source/Target/ThreadPlanStepInRange.cpp  |  2 +-
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/lldb/source/Target/ThreadPlanShouldStopHere.cpp 
b/lldb/source/Target/ThreadPlanShouldStopHere.cpp
index be6bd981c72bc..d2cca49987f0f 100644
--- a/lldb/source/Target/ThreadPlanShouldStopHere.cpp
+++ b/lldb/source/Target/ThreadPlanShouldStopHere.cpp
@@ -84,11 +84,12 @@ bool 
ThreadPlanShouldStopHere::DefaultShouldStopHereCallback(
     if (Symbol *symbol = frame->GetSymbolContext(eSymbolContextSymbol).symbol) 
{
       ProcessSP process_sp(current_plan->GetThread().GetProcess());
       for (auto *runtime : process_sp->GetLanguageRuntimes()) {
-        if (runtime->IsSymbolARuntimeThunk(*symbol)
-             && flags.Test(ThreadPlanShouldStopHere::eStepOutPastThunks)) {
-         LLDB_LOGF(log, "Stepping out past a language thunk %s for: %s",
-                   frame->GetFunctionName(),
-                   
Language::GetNameForLanguageType(runtime->GetLanguageType()));
+        if (runtime->IsSymbolARuntimeThunk(*symbol) &&
+            flags.Test(ThreadPlanShouldStopHere::eStepOutPastThunks)) {
+          LLDB_LOGF(
+              log, "Stepping out past a language thunk %s for: %s",
+              frame->GetFunctionName(),
+              Language::GetNameForLanguageType(runtime->GetLanguageType()));
           should_stop_here = false;
           break;
         }
@@ -136,11 +137,12 @@ ThreadPlanSP 
ThreadPlanShouldStopHere::DefaultStepFromHereCallback(
       // because it's marked line 0.
       bool is_thunk = false;
       for (auto *runtime : process_sp->GetLanguageRuntimes()) {
-        if (runtime->IsSymbolARuntimeThunk(*sc.symbol)
-             && flags.Test(ThreadPlanShouldStopHere::eStepOutPastThunks)) {
-          LLDB_LOGF(log, "Stepping out past a language thunk %s for: %s",
-                   frame->GetFunctionName(),
-                   
Language::GetNameForLanguageType(runtime->GetLanguageType()));
+        if (runtime->IsSymbolARuntimeThunk(*sc.symbol) &&
+            flags.Test(ThreadPlanShouldStopHere::eStepOutPastThunks)) {
+          LLDB_LOGF(
+              log, "Stepping out past a language thunk %s for: %s",
+              frame->GetFunctionName(),
+              Language::GetNameForLanguageType(runtime->GetLanguageType()));
           is_thunk = true;
           break;
         }
diff --git a/lldb/source/Target/ThreadPlanStepInRange.cpp 
b/lldb/source/Target/ThreadPlanStepInRange.cpp
index 3affeae1ee388..8a2417e9da326 100644
--- a/lldb/source/Target/ThreadPlanStepInRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -27,7 +27,7 @@ using namespace lldb;
 using namespace lldb_private;
 
 uint32_t ThreadPlanStepInRange::s_default_flag_values =
-    ThreadPlanShouldStopHere::eStepInAvoidNoDebug | 
+    ThreadPlanShouldStopHere::eStepInAvoidNoDebug |
     ThreadPlanShouldStopHere::eStepOutPastThunks;
 
 // ThreadPlanStepInRange: Step through a stack range, either stepping over or

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

Reply via email to