[gdb/testsuite] Fix gdb.tui/tui-layout-asm.exp with -m32
authorTom de Vries <tdevries@suse.de>
Sat, 6 Feb 2021 22:22:03 +0000 (23:22 +0100)
committerTom de Vries <tdevries@suse.de>
Sat, 6 Feb 2021 22:22:03 +0000 (23:22 +0100)
When running test-case gdb.tui/tui-layout-asm.exp with target board
unix/-m32, we run into:
...
FAIL: gdb.tui/tui-layout-asm.exp: scroll to end of assembler (scroll failed)
...

Comparing screen dumps (edited a bit to fit column width) before:
...
 0 +--------------------------------------------------------------------+
 1 | 0x8049194 <__libc_csu_init+68>  call   *-0x104(%ebp,%esi,4)        |
 2 | 0x804919b <__libc_csu_init+75>  add    $0x1,%esi                   |
 3 | 0x804919e <__libc_csu_init+78>  add    $0x10,%esp                  |
 4 | 0x80491a1 <__libc_csu_init+81>  cmp    %esi,%ebx                   |
 5 | 0x80491a3 <__libc_csu_init+83>  jne    0x8049188 <__...>           |
 6 | 0x80491a5 <__libc_csu_init+85>  add    $0xc,%esp                   |
 7 | 0x80491a8 <__libc_csu_init+88>  pop    %ebx                        |
 8 | 0x80491a9 <__libc_csu_init+89>  pop    %esi                        |
 9 | 0x80491aa <__libc_csu_init+90>  pop    %edi                        |
10 | 0x80491ab <__libc_csu_init+91>  pop    %ebp                        |
11 | 0x80491ac <__libc_csu_init+92>  ret                                |
12 | 0x80491ad                           lea    0x0(%esi),%esi          |
13 | 0x80491b0 <__libc_csu_fini>     ret                                |
14 +--------------------------------------------------------------------+
...
and after:
...
 0 +--------------------------------------------------------------------+
 1 | 0x804919b <__libc_csu_init+75>          add    $0x1,%esi           |
 2 | 0x804919e <__libc_csu_init+78>          add    $0x10,%esp          |
 3 | 0x80491a1 <__libc_csu_init+81>          cmp    %esi,%ebx           |
 4 | 0x80491a3 <__libc_csu_init+83>          jne    0x8049188 <__...>   |
 5 | 0x80491a5 <__libc_csu_init+85>          add    $0xc,%esp           |
 6 | 0x80491a8 <__libc_csu_init+88>          pop    %ebx                |
 7 | 0x80491a9 <__libc_csu_init+89>          pop    %esi                |
 8 | 0x80491aa <__libc_csu_init+90>          pop    %edi                |
 9 | 0x80491ab <__libc_csu_init+91>          pop    %ebp                |
10 | 0x80491ac <__libc_csu_init+92>          ret                        |
11 | 0x80491ad                                   lea    0x0(%esi),%esi  |
12 | 0x80491b0 <__libc_csu_fini>             ret                        |
13 | 0x80491b1 <__x86.get_pc_thunk.bp>       mov    (%esp),%ebp         |
14 +--------------------------------------------------------------------+
...
it seems the mismatch comes from the extra indentation forced by the longer
<__x86.get_pc_thunk.bp> that was scrolled in.

Fix this by ignoring whitespace when comparing scrolled lines.

Tested on x86_64-linux, using -m64 and -m32.

gdb/testsuite/ChangeLog:

2021-02-06  Tom de Vries  <tdevries@suse.de>

PR testsuite/26922
* gdb.tui/tui-layout-asm.exp: Ignore whitespace mismatches when
scrolling.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.tui/tui-layout-asm.exp

index 5875843472c3fc98d2257fc0c767a22e2fa79e58..222e8198fd0c992b3af658ef8dfad40b54a93f70 100644 (file)
@@ -1,3 +1,9 @@
+2021-02-06  Tom de Vries  <tdevries@suse.de>
+
+       PR testsuite/26922
+       * gdb.tui/tui-layout-asm.exp: Ignore whitespace mismatches when
+       scrolling.
+
 2021-02-05  Tom de Vries  <tdevries@suse.de>
 
        PR breakpoints/27313
index 347064aacc6e64c1ae15febecb191ba5a3e4dd9e..19ce333ca9eb1908ea1e01cf377d2cf4d11e14b3 100644 (file)
@@ -58,8 +58,11 @@ while (1) {
     # Send the down key to GDB.
     send_gdb "\033\[B"
     incr down_count
-    if {[Term::wait_for [string_to_regexp $line]] \
-           && [Term::get_line 1] == $line} {
+    set re_line [string_to_regexp $line]
+    # Ignore whitespace mismatches.
+    regsub -all {\s+} $re_line {\s+} re_line
+    if {[Term::wait_for $re_line] \
+           && [regexp $re_line [Term::get_line 1]]} {
        # We scrolled successfully.
     } else {
        fail "$testname (scroll failed)"