From 317577025f5d749e1bbba11cd3e2b2e46cadc349 Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Tue, 5 Sep 2023 18:48:22 +0000 Subject: [PATCH] gdb/testsuite: Fix style.exp failures on targets without argc/argv support Some embedded targets don't have full support for argc/argv. argv may print as "0x0" or as an address with a symbol name following. This causes problems for the regexps in the style.exp line-wrapping tests that assume it always prints as an ordinary address in backtrace output. This patch generalizes the regexps to handle these additional forms and reworks some of the line-wrapping tests to account for the argv address string being shorter or longer than a regular address. Reviewed-By: Tom Tromey Approved-By: Tom Tromey --- gdb/testsuite/gdb.base/style.exp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index 0370550d251..60f909e2402 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -92,7 +92,7 @@ proc run_style_tests { } { set argv "" gdb_test_multiple "frame" "frame without styling" { - -re -wrap "main \\(argc=.*, (argv=$hex)\\).*style\\.c:\[0-9\].*" { + -re -wrap "main \\(argc=.*, (argv=$hex.*)\\).*style\\.c:\[0-9\].*" { set argv $expect_out(1,string) pass $gdb_test_name } @@ -105,9 +105,13 @@ proc run_style_tests { } { set file_expr "$base_file_expr:\[0-9\]+" set arg_expr [limited_style "arg." variable] + # On some embedded targets that don't fully support argc/argv, + # argv may print as "0x0" or as an address with a symbol name + # following, so use a regexp general enough to match that and + # do not make assumptions about how long the address string is. gdb_test "frame" \ [multi_line \ - "#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+$arg_expr=$hex\\)\\s+at\\s+$file_expr" \ + "#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+$arg_expr=$hex.*\\)\\s+at\\s+$file_expr" \ "\[0-9\]+\\s+.*return.* break here .*"] gdb_test "info breakpoints" "$main_expr at $file_expr.*" @@ -134,16 +138,21 @@ proc run_style_tests { } { # the line listing; this is why the words from the source # code are spelled out in the final result line of the # test. + set re0_styled \ + [multi_line \ + "#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+$arg_expr=$hex\\)" \ + "\\s+at\\s+$file_expr" \ + "\[0-9\]+\\s+.*return.* break here .*"] set re1_styled \ [multi_line \ "#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+" \ - "\\s+$arg_expr=$hex\\)" \ + "\\s+$arg_expr=$hex.*\\)" \ "\\s+at\\s+$file_expr" \ "\[0-9\]+\\s+.*return.* break here .*"] set re2_styled \ [multi_line \ "#0\\s+$main_expr\\s+\\($arg_expr=.*" \ - "\\s+$arg_expr=$hex\\)\\s+at\\s+$file_expr" \ + "\\s+$arg_expr=$hex.*\\)\\s+at\\s+$file_expr" \ "\[0-9\]+\\s+.*return.* break here .*"] # The length of the line containing argv containing: @@ -152,7 +161,11 @@ proc run_style_tests { } { # - closing parenthesis set line_len [expr 4 + $argv_len + 1] - if { $line_len > $width } { + if { $argv == "argv=0x0" && $width >= 27 } { + # Embedded target with no argv support. + # #0 main (argc=0, argv=0x0) + set re_styled $re0_styled + } elseif { $line_len > $width } { # At on the next line. set re_styled $re1_styled } else { -- 2.30.2