* [PATCH 1/4] [gdb/testsuite] Use strict regexp in gdb.python/py-rbreak.exp
2026-09-16 9:52 [PATCH 0/4] [gdb/testsuite] Fixes in gdb.python/py-rbreak.exp Tom de Vries
@ 2026-09-16 9:52 ` Tom de Vries
2026-09-16 9:52 ` [PATCH 2/4] [gdb/testsuite] Make gdb.python/py-rbreak.exp more readable Tom de Vries
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-09-16 9:52 UTC (permalink / raw)
To: gdb-patches
With a 16.3 based package and test-case gdb.python/py-rbreak.exp I ran into:
...
(gdb) py sl = gdb.rbreak("func.*",minsyms=False,throttle=10)
Breakpoint 17 at 0x4011ad: file py-rbreak-func2.c, line 21.
Breakpoint 18 at 0x4011b8: file py-rbreak-func2.c, line 27.
Breakpoint 19 at 0x4011c3: file py-rbreak-func2.c, line 33.
Breakpoint 20 at 0x40113a: file py-rbreak.c, line 21.
Breakpoint 21 at 0x401145: file py-rbreak.c, line 27.
Breakpoint 22 at 0x401150: file py-rbreak.c, line 33.
Breakpoint 23 at 0x40115b: file py-rbreak.c, line 39.
Breakpoint 24 at 0x401166: file py-rbreak.c, line 45.
Breakpoint 25 at 0x401171: file py-rbreak.c, line 51.
Breakpoint 26 at 0x40107e: file static-reloc.c, line 29.
(gdb) py print(len(sl))
10
(gdb) FAIL: $exp: check number of returned breakpoints is 9
...
The extra match is for _dl_relocate_static_pie_ifunc, which has a debug info
entry with address:
...
<1><295>: Abbrev Number: 2 (DW_TAG_subprogram)
<296> DW_AT_external : 1
<296> DW_AT_name : _dl_relocate_static_pie_ifunc
<29a> DW_AT_decl_file : 1
<29a> DW_AT_decl_line : 28
<29b> DW_AT_decl_column : 1
<29b> DW_AT_prototyped : 1
<29b> DW_AT_low_pc : 0x40107e
<2a3> DW_AT_high_pc : 0x7
<2ab> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<2ad> DW_AT_call_all_calls: 1
...
Previously, that was just a declaration:
...
<1><295>: Abbrev Number: 4 (DW_TAG_subprogram)
<296> DW_AT_external : 1
<296> DW_AT_name : _dl_relocate_static_pie_ifunc
<29a> DW_AT_decl_file : 1
<29b> DW_AT_decl_line : 28
<29c> DW_AT_decl_column : 1
<29d> DW_AT_prototyped : 1
...
I'm not sure what the exact cause for this difference is, but it breaks the
test-case.
Fix this by using a regexp that only matches the 9 functions defined in the
sources: func[1-6] and efunc[1-3].
I didn't consider it a good idea to update the test names using "func.*",
because the intention stays the same, and changing it would unnecessarily
disturb test summary comparisons.
Tested on x86-64-linux.
---
gdb/testsuite/gdb.python/py-rbreak.exp | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/gdb/testsuite/gdb.python/py-rbreak.exp b/gdb/testsuite/gdb.python/py-rbreak.exp
index ba02758ae79..731ac7bbdb3 100644
--- a/gdb/testsuite/gdb.python/py-rbreak.exp
+++ b/gdb/testsuite/gdb.python/py-rbreak.exp
@@ -45,11 +45,15 @@ gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"main\.\*\",minsyms=False)" \
"get main function breakpoint" 0
gdb_test "py print(len(sl))" "1" \
"check number of returned breakpoints is 1"
-gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"func\.\*\",minsyms=False,throttle=10)" \
+
+# BRE matching func[1-6] and efunc[1-3].
+set re_func_efunc {r"^\(func[1-6]\|efunc[1-3]\)$"}
+
+gdb_py_test_silent_cmd "py sl = gdb.rbreak($re_func_efunc,minsyms=False,throttle=10)" \
"get functions matching func.*" 0
gdb_test "py print(len(sl))" "9" \
"check number of returned breakpoints is 9"
-gdb_test "py gdb.rbreak(\"func\.\*\",minsyms=False,throttle=5)" \
+gdb_test "py gdb.rbreak($re_func_efunc,minsyms=False,throttle=5)" \
"Number of breakpoints exceeds throttled maximum.*" \
"check throttle errors on too many breakpoints"
gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"func1\",minsyms=True)" \
@@ -60,7 +64,7 @@ gdb_py_test_silent_cmd "python sym = gdb.lookup_symbol(\"efunc1\")" \
"find a symbol in objfile" 1
gdb_py_test_silent_cmd "python symtab = sym\[0\].symtab" \
"get backing symbol table" 1
-gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"func\.\*\",minsyms=False,throttle=10,symtabs=\[symtab\])" \
+gdb_py_test_silent_cmd "py sl = gdb.rbreak($re_func_efunc,minsyms=False,throttle=10,symtabs=\[symtab\])" \
"get functions matching func.* in one symtab only" 0
gdb_test "py print(len(sl))" "3" \
"check number of returned breakpoints is 3"
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 2/4] [gdb/testsuite] Make gdb.python/py-rbreak.exp more readable
2026-09-16 9:52 [PATCH 0/4] [gdb/testsuite] Fixes in gdb.python/py-rbreak.exp Tom de Vries
2026-09-16 9:52 ` [PATCH 1/4] [gdb/testsuite] Use strict regexp " Tom de Vries
@ 2026-09-16 9:52 ` Tom de Vries
2026-09-16 9:52 ` [PATCH 3/4] [gdb/testsuite] Fix test name in gdb.python/py-rbreak.exp Tom de Vries
2026-09-16 9:52 ` [PATCH 4/4] [gdb/testsuite] Speed up gdb.python/py-rbreak.exp Tom de Vries
3 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-09-16 9:52 UTC (permalink / raw)
To: gdb-patches
Make gdb.python/py-rbreak.exp more readable by:
- adding empty lines between groups of tests, and
- reducing escaping using {} and subst_vars.
---
gdb/testsuite/gdb.python/py-rbreak.exp | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/gdb.python/py-rbreak.exp b/gdb/testsuite/gdb.python/py-rbreak.exp
index 731ac7bbdb3..2d5fb33f666 100644
--- a/gdb/testsuite/gdb.python/py-rbreak.exp
+++ b/gdb/testsuite/gdb.python/py-rbreak.exp
@@ -31,7 +31,8 @@ if {![runto_main]} {
}
gdb_test_no_output "nosharedlibrary"
-gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"\",minsyms=False)" \
+
+gdb_py_test_silent_cmd {py sl = gdb.rbreak("",minsyms=False)} \
"get all function breakpoints" 0
set min_breakpoints 11
gdb_test_multiple "py print(len(sl))" \
@@ -41,7 +42,8 @@ gdb_test_multiple "py print(len(sl))" \
gdb_assert { $n >= $min_breakpoints } $gdb_test_name
}
}
-gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"main\.\*\",minsyms=False)" \
+
+gdb_py_test_silent_cmd {py sl = gdb.rbreak("main.*",minsyms=False)} \
"get main function breakpoint" 0
gdb_test "py print(len(sl))" "1" \
"check number of returned breakpoints is 1"
@@ -53,18 +55,23 @@ gdb_py_test_silent_cmd "py sl = gdb.rbreak($re_func_efunc,minsyms=False,throttle
"get functions matching func.*" 0
gdb_test "py print(len(sl))" "9" \
"check number of returned breakpoints is 9"
+
gdb_test "py gdb.rbreak($re_func_efunc,minsyms=False,throttle=5)" \
"Number of breakpoints exceeds throttled maximum.*" \
"check throttle errors on too many breakpoints"
-gdb_py_test_silent_cmd "py sl = gdb.rbreak(\"func1\",minsyms=True)" \
+
+gdb_py_test_silent_cmd {py sl = gdb.rbreak("func1",minsyms=True)} \
"including minimal symbols, get functions matching func.*" 0
gdb_test "py print(len(sl))" "2" \
"check number of returned breakpoints is 2"
-gdb_py_test_silent_cmd "python sym = gdb.lookup_symbol(\"efunc1\")" \
+
+gdb_py_test_silent_cmd {python sym = gdb.lookup_symbol("efunc1")} \
"find a symbol in objfile" 1
-gdb_py_test_silent_cmd "python symtab = sym\[0\].symtab" \
+gdb_py_test_silent_cmd {python symtab = sym[0].symtab} \
"get backing symbol table" 1
-gdb_py_test_silent_cmd "py sl = gdb.rbreak($re_func_efunc,minsyms=False,throttle=10,symtabs=\[symtab\])" \
+gdb_py_test_silent_cmd \
+ [subst_vars \
+ {py sl = gdb.rbreak($re_func_efunc,minsyms=False,throttle=10,symtabs=[symtab])}] \
"get functions matching func.* in one symtab only" 0
gdb_test "py print(len(sl))" "3" \
"check number of returned breakpoints is 3"
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 3/4] [gdb/testsuite] Fix test name in gdb.python/py-rbreak.exp
2026-09-16 9:52 [PATCH 0/4] [gdb/testsuite] Fixes in gdb.python/py-rbreak.exp Tom de Vries
2026-09-16 9:52 ` [PATCH 1/4] [gdb/testsuite] Use strict regexp " Tom de Vries
2026-09-16 9:52 ` [PATCH 2/4] [gdb/testsuite] Make gdb.python/py-rbreak.exp more readable Tom de Vries
@ 2026-09-16 9:52 ` Tom de Vries
2026-09-16 9:52 ` [PATCH 4/4] [gdb/testsuite] Speed up gdb.python/py-rbreak.exp Tom de Vries
3 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-09-16 9:52 UTC (permalink / raw)
To: gdb-patches
I noticed here:
...
gdb_py_test_silent_cmd {py sl = gdb.rbreak("func1",minsyms=True)} \
"including minimal symbols, get functions matching func.*" 0
...
that the test name doesn't match the used regexp.
Fix this by using "matching func1.*".
---
gdb/testsuite/gdb.python/py-rbreak.exp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.python/py-rbreak.exp b/gdb/testsuite/gdb.python/py-rbreak.exp
index 2d5fb33f666..395a603ef4e 100644
--- a/gdb/testsuite/gdb.python/py-rbreak.exp
+++ b/gdb/testsuite/gdb.python/py-rbreak.exp
@@ -61,7 +61,7 @@ gdb_test "py gdb.rbreak($re_func_efunc,minsyms=False,throttle=5)" \
"check throttle errors on too many breakpoints"
gdb_py_test_silent_cmd {py sl = gdb.rbreak("func1",minsyms=True)} \
- "including minimal symbols, get functions matching func.*" 0
+ "including minimal symbols, get functions matching func1.*" 0
gdb_test "py print(len(sl))" "2" \
"check number of returned breakpoints is 2"
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 4/4] [gdb/testsuite] Speed up gdb.python/py-rbreak.exp
2026-09-16 9:52 [PATCH 0/4] [gdb/testsuite] Fixes in gdb.python/py-rbreak.exp Tom de Vries
` (2 preceding siblings ...)
2026-09-16 9:52 ` [PATCH 3/4] [gdb/testsuite] Fix test name in gdb.python/py-rbreak.exp Tom de Vries
@ 2026-09-16 9:52 ` Tom de Vries
3 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2026-09-16 9:52 UTC (permalink / raw)
To: gdb-patches
I noticed that gdb.python/py-rbreak.exp does:
...
if {![runto_main]} {
return
}
gdb_test_no_output "nosharedlibrary"
...
Speed up the test-case by not running to main.
This breaks the gdb.lookup_symbol("efunc1") call, which requires a current
frame, so use lookup_global_symbol instead.
Also remove the nosharedlibrary command. No longer running to main means we
no longer load symbols for shared libraries, so the nosharedlibrary that drops
those symbols is no longer required.
---
gdb/testsuite/gdb.python/py-rbreak.exp | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/gdb/testsuite/gdb.python/py-rbreak.exp b/gdb/testsuite/gdb.python/py-rbreak.exp
index 395a603ef4e..a1ca7d4283d 100644
--- a/gdb/testsuite/gdb.python/py-rbreak.exp
+++ b/gdb/testsuite/gdb.python/py-rbreak.exp
@@ -26,12 +26,6 @@ if {[prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $srcfile
return 1
}
-if {![runto_main]} {
- return
-}
-
-gdb_test_no_output "nosharedlibrary"
-
gdb_py_test_silent_cmd {py sl = gdb.rbreak("",minsyms=False)} \
"get all function breakpoints" 0
set min_breakpoints 11
@@ -65,9 +59,9 @@ gdb_py_test_silent_cmd {py sl = gdb.rbreak("func1",minsyms=True)} \
gdb_test "py print(len(sl))" "2" \
"check number of returned breakpoints is 2"
-gdb_py_test_silent_cmd {python sym = gdb.lookup_symbol("efunc1")} \
+gdb_py_test_silent_cmd {python sym = gdb.lookup_global_symbol("efunc1")} \
"find a symbol in objfile" 1
-gdb_py_test_silent_cmd {python symtab = sym[0].symtab} \
+gdb_py_test_silent_cmd {python symtab = sym.symtab} \
"get backing symbol table" 1
gdb_py_test_silent_cmd \
[subst_vars \
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread