[gcc r15-65] Fix pretty printers regexp for GDB output
Christophe Lyon
clyon@gcc.gnu.org
Tue Apr 30 08:59:28 GMT 2024
https://gcc.gnu.org/g:6d4593a178b49cab205d81cdf36f52e12eabbc6d
commit r15-65-g6d4593a178b49cab205d81cdf36f52e12eabbc6d
Author: Christophe Lyon <christophe.lyon@linaro.org>
Date: Thu Jan 25 15:43:56 2024 +0000
Fix pretty printers regexp for GDB output
GDB emits end of lines as \r\n, we currently match any >0 number of
either \n or \r, possibly leading to mismatches under racy conditions.
I noticed this while running the GCC testsuite using the equivalent of
GDB's READ1 feature [1] which helps detecting bufferization issues.
We try to match
\n$1 = empty std::tuple\r
against {^(type|\$([0-9]+)) = ([^\n\r]*)[\n\r]+} which fails because
of the leading \n (which was left in the buffer after the previous
"skipping" pattern matched the preceding \r).
This patch accepts any number of leading \n and/or \r in the "got" clause.
Also take this opportunity to quote \r and \r in the logs, to make
debugging such issues easier.
Tested on aarch64-linux-gnu.
[1] https//github.com/bminor/binutils-gdb/blob/master/gdb/testsuite/README#L269
2024-01-24 Christophe Lyon <christophe.lyon@linaro.org>
libstdc++-v3/
* testsuite/lib/gdb-test.exp (gdb-test): Fix regexp. Quote
newlines in logs.
Diff:
---
libstdc++-v3/testsuite/lib/gdb-test.exp | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/libstdc++-v3/testsuite/lib/gdb-test.exp b/libstdc++-v3/testsuite/lib/gdb-test.exp
index 31206f2fc32..2ec5596983d 100644
--- a/libstdc++-v3/testsuite/lib/gdb-test.exp
+++ b/libstdc++-v3/testsuite/lib/gdb-test.exp
@@ -194,8 +194,11 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } {
set test_counter 0
remote_expect target [timeout_value] {
- -re {^(type|\$([0-9]+)) = ([^\n\r]*)[\n\r]+} {
- send_log "got: $expect_out(buffer)"
+ -re {^[\n\r]*(type|\$([0-9]+)) = ([^\n\r]*)[\n\r]+} {
+ # Escape newlines so that we can print them.
+ set escaped [string map {"\n" "\\n"} $expect_out(buffer)]
+ set escaped2 [string map {"\r" "\\r"} $escaped]
+ send_log "got: $escaped2"
incr test_counter
set first $expect_out(3,string)
@@ -251,7 +254,10 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } {
}
-re {^[^$][^\n\r]*[\n\r]+} {
- send_log "skipping: $expect_out(buffer)"
+ # Escape newlines so that we can print them.
+ set escaped [string map {"\n" "\\n"} $expect_out(buffer)]
+ set escaped2 [string map {"\r" "\\r"} $escaped]
+ send_log "skipping: $escaped2"
exp_continue
}
More information about the Libstdc++-cvs
mailing list