[Lldb-commits] [lldb] [lldb][Breakpoint] Allow whitespace in breakpoint address expression (PR #126053)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Thu Feb 6 07:15:00 PST 2025
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/126053
>From 659a383f00011ecbf88163d15719eff9661742a7 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Thu, 6 Feb 2025 11:44:50 +0000
Subject: [PATCH 1/4] [lldb][Breakpoint] Allow whitespace in breakpoint address
expression
Setting a breakpoint on `<symbol> + <offset>` used to work until
`2c76e88e9eb284d17cf409851fb01f1d583bb22a`, where this regex was
reworked. Now we only accept `<symbol>+ <offset>`.
This patch fixes the regression by adding yet another `[[:space:]]*`
component to the regex.
One could probably simplify the regex (or even replace the regex by just
calling the relevent `consumeXXX` APIs on `llvm::StringRef`). Though I
left that for the future.
rdar://130780342
---
lldb/source/Interpreter/OptionArgParser.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Interpreter/OptionArgParser.cpp b/lldb/source/Interpreter/OptionArgParser.cpp
index 800f22b6169dc62..2d393a57452ee56 100644
--- a/lldb/source/Interpreter/OptionArgParser.cpp
+++ b/lldb/source/Interpreter/OptionArgParser.cpp
@@ -262,8 +262,10 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s,
// 3: The symbol/reg name if there is an offset
// 4: +/-
// 5: The offset value.
+ // clang-format off
static RegularExpression g_symbol_plus_offset_regex(
- "^(\\$[^ +-]+)|(([^ +-]+)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*)$");
+ "^(\\$[^ +-]+)|(([^ +-]+)[[:space:]]*([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*)$");
+ // clang-format on
llvm::SmallVector<llvm::StringRef, 4> matches;
if (g_symbol_plus_offset_regex.Execute(sref, &matches)) {
>From 32ad53a1c6a04a1f7c8edf328b325385364615ee Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Thu, 6 Feb 2025 14:10:06 +0000
Subject: [PATCH 2/4] fixup! add test
---
lldb/test/Shell/Commands/command-breakpoint-by-addr.test | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 lldb/test/Shell/Commands/command-breakpoint-by-addr.test
diff --git a/lldb/test/Shell/Commands/command-breakpoint-by-addr.test b/lldb/test/Shell/Commands/command-breakpoint-by-addr.test
new file mode 100644
index 000000000000000..ff17ae6cb1a3db3
--- /dev/null
+++ b/lldb/test/Shell/Commands/command-breakpoint-by-addr.test
@@ -0,0 +1,3 @@
+# RUN: %clang_host -g -O0 %S/Inputs/main.c -o %t.out
+# RUN: %lldb -b -o 'breakpoint set -a "main + 26"' %t.out | FileCheck %s --check-prefix CHECK
+# CHECK: Breakpoint 1: address =
>From b70126a667d6189d2b779fdd7b960d8c81fe8327 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Thu, 6 Feb 2025 15:10:49 +0000
Subject: [PATCH 3/4] fixup! add more test cases
---
lldb/test/Shell/Commands/command-breakpoint-by-addr.test | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/lldb/test/Shell/Commands/command-breakpoint-by-addr.test b/lldb/test/Shell/Commands/command-breakpoint-by-addr.test
index ff17ae6cb1a3db3..14bc7ebecc845e6 100644
--- a/lldb/test/Shell/Commands/command-breakpoint-by-addr.test
+++ b/lldb/test/Shell/Commands/command-breakpoint-by-addr.test
@@ -1,3 +1,12 @@
# RUN: %clang_host -g -O0 %S/Inputs/main.c -o %t.out
+# RUN: %lldb -b -o 'breakpoint set -a "main+26"' %t.out | FileCheck %s --check-prefix CHECK
+# RUN: %lldb -b -o 'breakpoint set -a "main+ 26"' %t.out | FileCheck %s --check-prefix CHECK
+# RUN: %lldb -b -o 'breakpoint set -a "main +26"' %t.out | FileCheck %s --check-prefix CHECK
+# RUN: %lldb -b -o 'breakpoint set -a "main + 26"' %t.out | FileCheck %s --check-prefix CHECK
# RUN: %lldb -b -o 'breakpoint set -a "main + 26"' %t.out | FileCheck %s --check-prefix CHECK
+
# CHECK: Breakpoint 1: address =
+# CHECK: Breakpoint 2: address =
+# CHECK: Breakpoint 3: address =
+# CHECK: Breakpoint 4: address =
+# CHECK: Breakpoint 5: address =
>From 63fae751f91156aca9a1541f2a68edf9d0425222 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Thu, 6 Feb 2025 15:14:32 +0000
Subject: [PATCH 4/4] fixup! use single lldb invocation in test
---
.../Shell/Commands/command-breakpoint-by-addr.test | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lldb/test/Shell/Commands/command-breakpoint-by-addr.test b/lldb/test/Shell/Commands/command-breakpoint-by-addr.test
index 14bc7ebecc845e6..43fc49c2e410d1e 100644
--- a/lldb/test/Shell/Commands/command-breakpoint-by-addr.test
+++ b/lldb/test/Shell/Commands/command-breakpoint-by-addr.test
@@ -1,9 +1,9 @@
# RUN: %clang_host -g -O0 %S/Inputs/main.c -o %t.out
-# RUN: %lldb -b -o 'breakpoint set -a "main+26"' %t.out | FileCheck %s --check-prefix CHECK
-# RUN: %lldb -b -o 'breakpoint set -a "main+ 26"' %t.out | FileCheck %s --check-prefix CHECK
-# RUN: %lldb -b -o 'breakpoint set -a "main +26"' %t.out | FileCheck %s --check-prefix CHECK
-# RUN: %lldb -b -o 'breakpoint set -a "main + 26"' %t.out | FileCheck %s --check-prefix CHECK
-# RUN: %lldb -b -o 'breakpoint set -a "main + 26"' %t.out | FileCheck %s --check-prefix CHECK
+# RUN: %lldb -b -o 'breakpoint set -a "main+26"' \
+# RUN: -o 'breakpoint set -a "main+ 26"' \
+# RUN: -o 'breakpoint set -a "main +26"' \
+# RUN: -o 'breakpoint set -a "main + 26"' \
+# RUN: -o 'breakpoint set -a "main + 26"' %t.out | FileCheck %s
# CHECK: Breakpoint 1: address =
# CHECK: Breakpoint 2: address =
More information about the lldb-commits
mailing list