]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/testsuite: Fix style.exp failures on targets without argc/argv support
authorSandra Loosemore <sandra@codesourcery.com>
Tue, 5 Sep 2023 18:48:22 +0000 (18:48 +0000)
committerSandra Loosemore <sandra@codesourcery.com>
Tue, 5 Sep 2023 18:48:22 +0000 (18:48 +0000)
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 <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
gdb/testsuite/gdb.base/style.exp

index 0370550d2512656069e4f1b83ec11a9afe96d42c..60f909e2402523b15256b0eceabc4f203693d30d 100644 (file)
@@ -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 {