Skip to contentSkip to conversation

tests: ptrace-sync: relax breakpoint pattern matching

PATCH In review Yuan Wang 2 participants 3 messages Mar 2 – Mar 3

lore
Share & tools
lore

Yuan Wang

author
#0 lore raw

PATCH 1/1 tests: ptrace-sync: relax breakpoint pattern matching

In some OS distributions, the gdb output of the break instruction doesn't contain the function name where the breakpoint is set. This is observed on Ubuntu 22.04.5. with GNU gdb
(Ubuntu 12.1-0ubuntu1~22.04.2) 12.1., causing pattern matching failures and subsequent test failures.

Remove the ": bp\." suffix requirement to make the pattern more robust across different gdb versions and configurations.

The original failed log (run with -v) -

"
-> {{ "b bp" }}
EXPECT {{ ^Breakpoint 1 at .*: bp\.}}
<- {{ "Breakpoint 1 at 0x28b9: file ../tests/ptrace-sync.c, line 59." }} <- {{ "(gdb)" }}

<timeout waiting for gdb>
"

---
 tests/ptrace-sync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/ptrace-sync.c +1 -1
index 4c56e73..556c7a6 100644
@@ -147,7 +147,7 @@ static struct dialog {
 	{ "^Reading symbols from .*", "set prompt (gdb)\\n" },
 	{ ".*(gdb).*", "set env __EVL_DEBUGGEE__=1" },
 	{ "(gdb)", "b bp" },
-	{ "^Breakpoint 1 at .*: bp\\.", "r" },
+	{ "^Breakpoint 1 at .*", "r" },
 	{ "^Thread 1 .* hit Breakpoint 1.*, bp ().*", "c" },
 	{ "^Thread 3 .* hit Breakpoint 1.*, bp ().*", "c" },
 	{ "^Thread 2 .* hit Breakpoint 1.*, bp ().*", "c" },
Signature · 1 line
2.34.1
#1 lore raw
Quoted 9 lines · Yuan Wang

In some OS distributions, the gdb output of the break instruction doesn't contain the function name where the breakpoint is set. This is observed on Ubuntu 22.04.5. with GNU gdb
(Ubuntu 12.1-0ubuntu1~22.04.2) 12.1., causing pattern matching failures and subsequent test failures.

Remove the ": bp\." suffix requirement to make the pattern more robust across different gdb versions and configurations.

Quoted 6 lines

The original failed log (run with -v) -

"
-> {{ "b bp" }}
EXPECT {{ ^Breakpoint 1 at .*: bp\.}}
<- {{ "Breakpoint 1 at 0x28b9: file ../tests/ptrace-sync.c, line 59." }}

I guess the difference comes from this toolchain compiling bp into a single function, rather than 3 inline spots like gcc-4 of Debian is generating.

Quoted 16 lines

<- {{ "(gdb)" }}

<timeout waiting for gdb>
"

---
 tests/ptrace-sync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/ptrace-sync.c +0 -0
index 4c56e73..556c7a6 100644

tests/ptrace-sync.c static struct dialog { · line 153

Quoted 8 lines
tests/ptrace-sync.c +1 -1
@@ -147,7 +147,7 @@ static struct dialog {
 	{ "^Reading symbols from .*", "set prompt (gdb)\\n" },
 	{ ".*(gdb).*", "set env __EVL_DEBUGGEE__=1" },
 	{ "(gdb)", "b bp" },
-	{ "^Breakpoint 1 at .*: bp\\.", "r" },
+	{ "^Breakpoint 1 at .*", "r" },
 	{ "^Thread 1 .* hit Breakpoint 1.*, bp ().*", "c" },
 	{ "^Thread 3 .* hit Breakpoint 1.*, bp ().*", "c" },
 	{ "^Thread 2 .* hit Breakpoint 1.*, bp ().*", "c" },

Maybe you could tag the target repo in future submissions, e.g. like this:

[PATCH libevl] ...

Thanks,
Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center
#2 lore raw
Quoted 12 lines · Jan Kiszka
Quoted 11 lines · Yuan Wang

In some OS distributions, the gdb output of the break instruction doesn't contain the function name where the breakpoint is set. This is observed on Ubuntu 22.04.5. with GNU gdb
(Ubuntu 12.1-0ubuntu1~22.04.2) 12.1., causing pattern matching failures and subsequent test failures.

Remove the ": bp\." suffix requirement to make the pattern more robust across different gdb versions and configurations.

The original failed log (run with -v) -

Quoted 9 lines
Quoted 4 lines

"
-> {{ "b bp" }}
EXPECT {{ ^Breakpoint 1 at .*: bp\.}}
<- {{ "Breakpoint 1 at 0x28b9: file ../tests/ptrace-sync.c, line 59." }}

I guess the difference comes from this toolchain compiling bp into a single function, rather than 3 inline spots like gcc-4 of Debian is generating.

I'm not sure when gdb can return function names for breakpoints. I tried 'b main', it returns output in the form of file + line number.

(gdb) b main
Breakpoint 1 at 0x3a2b: file ../tests/ptrace-sync.c, line 277.

I also tried modifying the bp function to inline, but it still returns output in the form of file + line number.

code [

 57│ static inline void bp(void)
 58│ {
 59│         __Texpr_assert(!evl_is_inband());
 60│ }

]

(gdb) b bp
Breakpoint 2 at 0x28b5: file ../tests/ptrace-sync.c, line 59.

And below it my compile steps for libevl -

$meson setup .. -Dbuildtype=debug -Duapi=<path-to-linux-evl> $meson compile

Quoted 27 lines
Quoted 16 lines

<- {{ "(gdb)" }}

<timeout waiting for gdb>
"

---
 tests/ptrace-sync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/ptrace-sync.c +0 -0
index 4c56e73..556c7a6 100644

tests/ptrace-sync.c static struct dialog { · line 153

Quoted 8 lines
tests/ptrace-sync.c +1 -1
@@ -147,7 +147,7 @@ static struct dialog {
 	{ "^Reading symbols from .*", "set prompt (gdb)\\n" },
 	{ ".*(gdb).*", "set env __EVL_DEBUGGEE__=1" },
 	{ "(gdb)", "b bp" },
-	{ "^Breakpoint 1 at .*: bp\\.", "r" },
+	{ "^Breakpoint 1 at .*", "r" },
 	{ "^Thread 1 .* hit Breakpoint 1.*, bp ().*", "c" },
 	{ "^Thread 3 .* hit Breakpoint 1.*, bp ().*", "c" },
 	{ "^Thread 2 .* hit Breakpoint 1.*, bp ().*", "c" },

Maybe you could tag the target repo in future submissions, e.g. like this:

Quoted 2 lines

[PATCH libevl] ...

Sure, will add the target tag in the future.

Thanks
Yuan