Make the maint.exp:'maint print objfiles' test less fragile.
authorPedro Alves <palves@redhat.com>
Wed, 20 Nov 2013 17:12:37 +0000 (17:12 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 20 Nov 2013 17:12:37 +0000 (17:12 +0000)
I was "lucky" enough that an unrelated patch changed how many symtabs
GDB expands in a plain run to main, and that triggered a latent issue
in this test:

  PASS: gdb.base/maint.exp: maint print objfiles: header
  PASS: gdb.base/maint.exp: maint print objfiles: psymtabs
  FAIL: gdb.base/maint.exp: maint print objfiles: symtabs

The problem is in my case, expect is managing to alway put in the
buffer chunks like this:

  Psymtabs:
  ../../../src/gdb/testsuite/gdb.base/break1.c at 0x1ed2280, ../../../src/gdb/testsuite/gdb.base/break.c at 0x1ed21d0,

  Symtabs:
  ../../../src/gdb/testsuite/gdb.base/break.c at 0x1f044f0, /usr/include/stdio.h at 0x1ed25a0, /usr/include/libio.h at 0x1ed2510, /usr/include/bits/types.h at 0x1ed2480, /usr/lib/gcc/x86_64-redhat-linux/4.7.2/include/stddef.h at 0x1ed23f0,

  Object file /usr/lib/debug/lib64/ld-2.15.so.debug:  Objfile at 0x1f4bff0, bfd at 0x1f2d940, 0 minsyms

  Psymtabs:
  bsearch.c at 0x1f65340, ../sysdeps/x86_64/multiarch/init-arch.c at
  0x1f65290, ...

Note: Psymtabs:/Symtabs:/Psymtabs:.

So, the loop matches the first Psymtabs in the buffer.  Then we're
left with

  ../../../src/gdb/testsuite/gdb.base/break1.c at 0x1ed2280, ../../../src/gdb/testsuite/gdb.base/break.c at 0x1ed21d0,

  Symtabs:
  ../../../src/gdb/testsuite/gdb.base/break.c at 0x1f044f0, /usr/include/stdio.h at 0x1ed25a0, /usr/include/libio.h at 0x1ed2510, /usr/include/bits/types.h at 0x1ed2480, /usr/lib/gcc/x86_64-redhat-linux/4.7.2/include/stddef.h at 0x1ed23f0,

  Object file /usr/lib/debug/lib64/ld-2.15.so.debug:  Objfile at 0x1f4bff0, bfd at 0x1f2d940, 0 minsyms

  Psymtabs:
  bsearch.c at 0x1f65340, ../sysdeps/x86_64/multiarch/init-arch.c at
  0x1f65290, ...

In the next iteration, because the psymtabs regex comes first, we
match with the Psymtabs: line, then of course, end up with just

  bsearch.c at 0x1f65340, ../sysdeps/x86_64/multiarch/init-arch.c at
  0x1f65290, ...

in the buffer.  The "Symtabs:" line is lost.  expect then reads more
gdb output, and manages to again retrieve the same pattern.  Rinse,
repeat, and the test never matches any "Symtab:" line.

We don't know the order the matches lines will appear, so the fix is
to consume one line at a time, and run it through all three milestone
regexes.

gdb/testsuite/
2013-11-20  Pedro Alves  <palves@redhat.com>

* gdb.base/maint.exp (maint print objfiles): Consume one line at a
time, and run it through all three milestone regexes.

gdb/testsuite/gdb.base/maint.exp

index 9425f2b386b1ba2f4ffc2e167f5c6e3ceefb857c..d3409b65dfead64845292151d99f3c0cdea08360 100644 (file)
@@ -181,9 +181,18 @@ set keep_looking 1
 while {$keep_looking} {
     gdb_expect  {
 
-       -re ".*Object file.*maint($EXEEXT)?:  Objfile at $hex, bfd at $hex, \[0-9\]* minsyms\[\r\t \]+\n" { set header 1 }
-       -re ".*Psymtabs:\[\r\t \]+\n" { set psymtabs 1 }
-       -re ".*Symtabs:\[\r\t \]+\n" { set symtabs 1 }
+       -re "\r\n" {
+           set output $expect_out(buffer)
+           if {[regexp ".*Object file.*maint($EXEEXT)?:  Objfile at ${hex}" $output]} {
+               set header 1
+           }
+           if {[regexp ".*Psymtabs:\[\r\t \]+\n" $output]} {
+               set psymtabs 1
+           }
+           if {[regexp ".*Symtabs:\[\r\t \]+\n" $output]} {
+               set symtabs 1
+           }
+       }
 
        -re ".*$gdb_prompt $" { 
            set keep_looking 0
This page took 0.038798 seconds and 4 git commands to generate.