[gdb/testsuite] Fix gdb.base/style.exp with -m32
authorTom de Vries <tdevries@suse.de>
Thu, 14 Jan 2021 09:20:21 +0000 (10:20 +0100)
committerTom de Vries <tdevries@suse.de>
Thu, 14 Jan 2021 09:20:21 +0000 (10:20 +0100)
When running test-case gdb.base/style.exp with target board unix/-m32, we run
into (stripped styling from output, shortened file name):
...
(gdb) frame
    argv=0xffffc714) at src/gdb/testsuite/gdb.base/style.c:45
45        return some_called_function (); /* break here */
(gdb) FAIL: gdb.base/style.exp: frame when width=20
...
while with native we have instead:
...
(gdb) frame
    argv=0x7fffffffd478)
    at src/gdb/testsuite/gdb.base/style.c:45
45        return some_called_function (); /* break here */
(gdb) PASS: gdb.base/style.exp: frame when width=20
...

The problem is that due to argv having a different length for -m32, we get a
different layout, and the test-case doesn't accommodate for that.

Fix this by using a different regexp depending on the length of argv.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-01-14  Tom de Vries  <tdevries@suse.de>

PR testsuite/24590
* gdb.base/style.exp: Handle shorter argv in frame command output.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/style.exp

index cfc49db6c1a53655b0f5229de47ead4d8d1b61d2..b8c9010d28f022caf09ca02643f54866f6605fcc 100644 (file)
@@ -1,3 +1,8 @@
+2021-01-14  Tom de Vries  <tdevries@suse.de>
+
+       PR testsuite/24590
+       * gdb.base/style.exp: Handle shorter argv in frame command output.
+
 2021-01-13  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        PR gdb/26819
index cc143b432923964bca1d8d00980f2bdb754650ac..aec1d0f42ed4a9d850f80e0768117c440b1ad6a8 100644 (file)
@@ -46,6 +46,16 @@ save_vars { env(TERM) } {
     set main_line [gdb_get_line_number "break here"]
     gdb_test "list $main_line,$main_line" "return.*some_called_function.*"
 
+    gdb_test_no_output "set style enabled off"
+
+    set argv ""
+    gdb_test_multiple "frame" "frame without styling" {
+       -re -wrap "main \\(argc=.*, (argv=$hex)\\).*style\\.c:\[0-9\].*" {
+           set argv $expect_out(1,string)
+           pass $gdb_test_name
+       }
+    }
+
     gdb_test_no_output "set style enabled on"
 
     set main_expr [style main function]
@@ -60,7 +70,7 @@ save_vars { env(TERM) } {
     gdb_test_no_output "set style sources off"
     gdb_test "frame" \
        "\r\n\[^\033\]*break here.*" \
-       "frame without styling"
+       "frame without sources styling"
     gdb_test_no_output "set style sources on"
 
     gdb_test "break -q main" "file $base_file_expr.*"
@@ -71,20 +81,47 @@ save_vars { env(TERM) } {
     # wrong spot with styling.  There were different bugs at different
     # widths, so try two.
     foreach width {20 30} {
-       gdb_test_no_output "set width $width"
+       set argv_len [string length $argv]
+       if { $argv_len == 0 } {
+           continue
+       }
+
        # There was also a bug where the styling could be wrong in the
        # line listing; this is why the words from the source code are
        # spelled out in the final result line of the test.
-       gdb_test "frame" \
+       set re1_styled \
            [multi_line \
                 "#0 *$main_expr.*$arg_expr.*" \
                 ".*$arg_expr.*" \
                 ".* at .*$file_expr.*" \
-                "\[0-9\]+.*return.* break here .*"
-           ] \
-           "frame when width=$width"
+                "\[0-9\]+.*return.* break here .*"]
+       set re2_styled \
+           [multi_line \
+                "#0 *$main_expr.*$arg_expr.*" \
+                ".*$arg_expr.* at .*$file_expr.*" \
+                "\[0-9\]+.*return.* break here .*"]
+
+       # The length of the line containing argv containing:
+       # - 4 leading spaces
+       # - argv string
+       # - closing parenthesis
+       set line_len [expr 4 + $argv_len + 1]
+
+       if { $line_len > $width } {
+           # At on the next line.
+           set re_styled $re1_styled
+       } else {
+           # At on the same line as argv.
+           set re_styled $re2_styled
+       }
+
+       gdb_test_no_output "set width $width"
+       gdb_test "frame" $re_styled "frame when width=$width"
     }
 
+    # Reset width back to 0.
+    gdb_test_no_output "set width 0"
+
     if {$test_macros} {
        set macro_line [gdb_get_line_number "\#define SOME_MACRO"]
        gdb_test "info macro SOME_MACRO" \
This page took 0.037489 seconds and 4 git commands to generate.