Skip to content

[lldb] Support any flag to _regexp-bt #116260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kastiglione
Copy link
Contributor

@kastiglione kastiglione commented Nov 14, 2024

In particular, this allows bt -u.

Note that this passthrough behavior has precedent in _regexp-break, where b (-.*) is expanded to breakpoint set %1.

In particular, this allows `bt -u`.
@llvmbot
Copy link
Member

llvmbot commented Nov 14, 2024

@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)

Changes

In particular, this allows bt -u.


Full diff: https://github.com/llvm/llvm-project/pull/116260.diff

2 Files Affected:

  • (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+1-2)
  • (modified) lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py (+5)
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index f2712af0a08a73..2cdf5e6da6fd13 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -851,8 +851,7 @@ void CommandInterpreter::LoadCommandDictionary() {
     // now "bt 3" is the preferred form, in line with gdb.
     if (bt_regex_cmd_up->AddRegexCommand("^([[:digit:]]+)[[:space:]]*$",
                                          "thread backtrace -c %1") &&
-        bt_regex_cmd_up->AddRegexCommand("^-c ([[:digit:]]+)[[:space:]]*$",
-                                         "thread backtrace -c %1") &&
+        bt_regex_cmd_up->AddRegexCommand("^(-.*)$", "thread backtrace %1") &&
         bt_regex_cmd_up->AddRegexCommand("^all[[:space:]]*$", "thread backtrace all") &&
         bt_regex_cmd_up->AddRegexCommand("^[[:space:]]*$", "thread backtrace")) {
       CommandObjectSP command_sp(bt_regex_cmd_up.release());
diff --git a/lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py b/lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
index d1cb8214d658ff..978bf2066e43b0 100644
--- a/lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
+++ b/lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
@@ -46,6 +46,11 @@ def test_backtrace(self):
             "thread backtrace", matching=False, patterns=["frame.*std::__.*::__function"]
         )
         # Unfiltered.
+        self.expect(
+            "bt -u",
+            ordered=True,
+            patterns=["frame.*foo", "frame.*std::__[^:]*::__function", "frame.*main"],
+        )
         self.expect(
             "thread backtrace -u",
             ordered=True,

Copy link

github-actions bot commented Nov 14, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff c9719ad5cd7e0fa65b52333f28aa62c05052d989 b83d07056ecaf53a34c3da81ff3472d2c84cc09a --extensions cpp -- lldb/source/Interpreter/CommandInterpreter.cpp
View the diff from clang-format here.
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 764dcfd190..0eb928e1db 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -851,9 +851,12 @@ void CommandInterpreter::LoadCommandDictionary() {
     // now "bt 3" is the preferred form, in line with gdb.
     if (bt_regex_cmd_up->AddRegexCommand("^([[:digit:]]+)[[:space:]]*$",
                                          "thread backtrace -c %1") &&
-        bt_regex_cmd_up->AddRegexCommand("^(-[^[:space:]].*)$", "thread backtrace %1") &&
-        bt_regex_cmd_up->AddRegexCommand("^all[[:space:]]*$", "thread backtrace all") &&
-        bt_regex_cmd_up->AddRegexCommand("^[[:space:]]*$", "thread backtrace")) {
+        bt_regex_cmd_up->AddRegexCommand("^(-[^[:space:]].*)$",
+                                         "thread backtrace %1") &&
+        bt_regex_cmd_up->AddRegexCommand("^all[[:space:]]*$",
+                                         "thread backtrace all") &&
+        bt_regex_cmd_up->AddRegexCommand("^[[:space:]]*$",
+                                         "thread backtrace")) {
       CommandObjectSP command_sp(bt_regex_cmd_up.release());
       m_command_dict[std::string(command_sp->GetCommandName())] = command_sp;
     }

Copy link
Collaborator

@jimingham jimingham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kastiglione kastiglione merged commit 5d16fbc into llvm:main Nov 14, 2024
6 of 7 checks passed
@kastiglione kastiglione deleted the lldb-Support-any-flag-to-_regexp-bt branch November 14, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants