[gdb/testsuite] Fix psymtab expansion postponement in c-linkage-name.exp
authorTom de Vries <tdevries@suse.de>
Fri, 28 Feb 2020 15:05:50 +0000 (16:05 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 28 Feb 2020 15:05:50 +0000 (16:05 +0100)
commit13c3a74afb50b240dbacfd60f91414eae50279ad
tree42b055cde08cdfffa1edffae4d9a08b662edbee1
parent85d2d5bbee1c21c2e3e929cc68fe06d762b3073b
[gdb/testsuite] Fix psymtab expansion postponement in c-linkage-name.exp

The test-case gdb.base/c-linkage-name.exp starts with the following test:
...
gdb_test "print symada__cS" \
         " = {a = 100829103}" \
         "print symada__cS before partial symtab expansion"
...

However, printing the state of the partial symtabs using maint info psymtabs
shows that in fact the symtab has already been expanded:
...
  { psymtab c-linkage-name.c ((struct partial_symtab *) 0x1e27b40)^M
    readin yes^M
...

This is due to set_initial_language, which looks up the main symbol, which
expands the psymtab containing main.

Fix this by moving all but main into a separate source file c-linkage-name-2.c.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-02-28  Tom de Vries  <tdevries@suse.de>

* gdb.base/c-linkage-name.c (main): Call do_something_other_cu.
(struct wrapper, do_something, mundane/symada__cS): Move ...
* gdb.base/c-linkage-name-2.c: ... here.  New source file.
* gdb.base/c-linkage-name.exp: Add verification of psymtab expansion.
Update "print symada__cS before partial symtab expansion" regexp.
Update breakpoint location.  Flush symbol cache after expansion.
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/c-linkage-name-2.c [new file with mode: 0644]
gdb/testsuite/gdb.base/c-linkage-name.c
gdb/testsuite/gdb.base/c-linkage-name.exp