Skip to content

Commit 1608fe8

Browse files
authored
[lldb][Breakpoint] Allow whitespace in breakpoint address expression (#126053)
Setting a breakpoint on `<symbol> + <offset>` used to work until `2c76e88e9eb284d17cf409851fb01f1d583bb22a`, where this regex was reworked. Now we only accept `<symbol>+ <offset>` or `<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
1 parent 4bf97aa commit 1608fe8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lldb/source/Interpreter/OptionArgParser.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,10 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s,
262262
// 3: The symbol/reg name if there is an offset
263263
// 4: +/-
264264
// 5: The offset value.
265+
// clang-format off
265266
static RegularExpression g_symbol_plus_offset_regex(
266-
"^(\\$[^ +-]+)|(([^ +-]+)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*)$");
267+
"^(\\$[^ +-]+)|(([^ +-]+)[[:space:]]*([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*)$");
268+
// clang-format on
267269

268270
llvm::SmallVector<llvm::StringRef, 4> matches;
269271
if (g_symbol_plus_offset_regex.Execute(sref, &matches)) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# RUN: %clang_host -g -O0 %S/Inputs/main.c -o %t.out
2+
# RUN: %lldb %t.out -b -s %s | FileCheck %s
3+
4+
breakpoint set -a "main+26"
5+
breakpoint set -a "main+ 26"
6+
breakpoint set -a "main +26"
7+
breakpoint set -a "main + 26"
8+
breakpoint set -a "main + 26"
9+
10+
# CHECK: Breakpoint 1: address =
11+
# CHECK: Breakpoint 2: address =
12+
# CHECK: Breakpoint 3: address =
13+
# CHECK: Breakpoint 4: address =
14+
# CHECK: Breakpoint 5: address =

0 commit comments

Comments
 (0)