https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/153984

>From 07a8f9b07c67b6a84a922180aaeb5808c84c7fdc Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee....@gmail.com>
Date: Sat, 16 Aug 2025 15:37:35 -0700
Subject: [PATCH 1/3] [lldb] Make step/s alias for new _regexp-step

Introduces `_regexp-step`, a regex command which allows for stepping into a 
target
function. This change updates `step` and `s` to be aliases for `_regexp-step`.

The existing `sif` command ("Step Into Function") is not well known amongst 
users. This
change makes `step` and `s` work like `sif`, taking an optional function name.

This is implemented to not break uses of `step` or `s` with a flag, for example 
running
`step -r func_to_avoid` works as expected.
---
 .../source/Interpreter/CommandInterpreter.cpp | 22 ++++++++++++++++-
 .../API/lang/c/step-target/TestStepTarget.py  | 24 +++++++++++--------
 2 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index a0080cfff57c1..b1fd3e7984aa4 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -335,7 +335,7 @@ void CommandInterpreter::Initialize() {
     AddAlias("ni", cmd_obj_sp);
   }
 
-  cmd_obj_sp = GetCommandSPExact("thread step-in");
+  cmd_obj_sp = GetCommandSPExact("_regexp-step");
   if (cmd_obj_sp) {
     AddAlias("s", cmd_obj_sp);
     AddAlias("step", cmd_obj_sp);
@@ -946,6 +946,26 @@ void CommandInterpreter::LoadCommandDictionary() {
           jump_regex_cmd_sp;
     }
   }
+
+  std::shared_ptr<CommandObjectRegexCommand> step_regex_cmd_sp(
+      new CommandObjectRegexCommand(
+          *this, "_regexp-step",
+          "Single step, optionally to a specific function.",
+          "\n"
+          "_regexp-step                 // Single step\n"
+          "_regexp-step <function-name> // Step into the named function\n",
+          0, false));
+  if (step_regex_cmd_sp) {
+    if (step_regex_cmd_sp->AddRegexCommand("^$", "thread step-in") &&
+        step_regex_cmd_sp->AddRegexCommand("^[[:space:]]*(-.*)$",
+                                           "thread step-in %1") &&
+        step_regex_cmd_sp->AddRegexCommand(
+            "^[[:space:]]*(.+)[[:space:]]*$",
+            "thread step-in --end-linenumber block --step-in-target %1")) {
+      m_command_dict[std::string(step_regex_cmd_sp->GetCommandName())] =
+          step_regex_cmd_sp;
+    }
+  }
 }
 
 int CommandInterpreter::GetCommandNamesMatchingPartialString(
diff --git a/lldb/test/API/lang/c/step-target/TestStepTarget.py 
b/lldb/test/API/lang/c/step-target/TestStepTarget.py
index 2da0a7894655d..e5bd64d8927af 100644
--- a/lldb/test/API/lang/c/step-target/TestStepTarget.py
+++ b/lldb/test/API/lang/c/step-target/TestStepTarget.py
@@ -83,14 +83,16 @@ def test_with_end_line_deeper(self):
     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
     def test_with_command_and_block(self):
         """Test stepping over vrs. hitting breakpoints & subsequent stepping 
in various forms."""
+        self.do_command_and_block()
+        self.do_command_and_block(True)
 
+    def do_command_and_block(self, use_regexp_step=False):
         thread = self.get_to_start()
 
-        result = lldb.SBCommandReturnObject()
-        self.dbg.GetCommandInterpreter().HandleCommand(
-            'thread step-in -t "lotsOfArgs" -e block', result
-        )
-        self.assertTrue(result.Succeeded(), "thread step-in command 
succeeded.")
+        if use_regexp_step:
+            self.expect("s lotsOfArgs")
+        else:
+            self.expect('thread step-in -t "lotsOfArgs" -e block')
 
         frame = thread.frames[0]
         self.assertEqual(frame.name, "lotsOfArgs", "Stepped to lotsOfArgs.")
@@ -98,14 +100,16 @@ def test_with_command_and_block(self):
     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
     def test_with_command_and_block_and_bad_name(self):
         """Test stepping over vrs. hitting breakpoints & subsequent stepping 
in various forms."""
+        self.do_with_command_and_block_and_bad_name()
+        self.do_with_command_and_block_and_bad_name(True)
 
+    def do_with_command_and_block_and_bad_name(self, use_regexp_step=False):
         thread = self.get_to_start()
 
-        result = lldb.SBCommandReturnObject()
-        self.dbg.GetCommandInterpreter().HandleCommand(
-            'thread step-in -t "lotsOfArgsssss" -e block', result
-        )
-        self.assertTrue(result.Succeeded(), "thread step-in command 
succeeded.")
+        if use_regexp_step:
+            self.expect("s lotsOfArgsssss")
+        else:
+            self.expect('thread step-in -t "lotsOfArgsssss" -e block')
 
         frame = thread.frames[0]
 

>From 4c641666648a728b01690ce8c5ddfd96a2199cfe Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee....@gmail.com>
Date: Sat, 16 Aug 2025 15:49:04 -0700
Subject: [PATCH 2/3] handle invocation with trailing space

---
 lldb/source/Interpreter/CommandInterpreter.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index b1fd3e7984aa4..993edd12ce692 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -956,7 +956,8 @@ void CommandInterpreter::LoadCommandDictionary() {
           "_regexp-step <function-name> // Step into the named function\n",
           0, false));
   if (step_regex_cmd_sp) {
-    if (step_regex_cmd_sp->AddRegexCommand("^$", "thread step-in") &&
+    if (step_regex_cmd_sp->AddRegexCommand("^[[:space:]]*$",
+                                           "thread step-in") &&
         step_regex_cmd_sp->AddRegexCommand("^[[:space:]]*(-.*)$",
                                            "thread step-in %1") &&
         step_regex_cmd_sp->AddRegexCommand(

>From e426c45984849d9df7c05b1c42c546d31936c871 Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee....@gmail.com>
Date: Sat, 16 Aug 2025 15:57:51 -0700
Subject: [PATCH 3/3] fine tune regex command

---
 lldb/source/Interpreter/CommandInterpreter.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index 993edd12ce692..650b754fd8ace 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -958,7 +958,7 @@ void CommandInterpreter::LoadCommandDictionary() {
   if (step_regex_cmd_sp) {
     if (step_regex_cmd_sp->AddRegexCommand("^[[:space:]]*$",
                                            "thread step-in") &&
-        step_regex_cmd_sp->AddRegexCommand("^[[:space:]]*(-.*)$",
+        step_regex_cmd_sp->AddRegexCommand("^[[:space:]]*(-.+)$",
                                            "thread step-in %1") &&
         step_regex_cmd_sp->AddRegexCommand(
             "^[[:space:]]*(.+)[[:space:]]*$",

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

Reply via email to