Fix a latent bug in dw2-ranges-overlap.exp
authorTom Tromey <tom@tromey.com>
Fri, 6 Aug 2021 22:07:27 +0000 (16:07 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 23 Aug 2021 20:14:20 +0000 (14:14 -0600)
commitd30c6bef12b2021211054f8a1672bc675a5cecb5
treeeff39c72319ad8b3314998bc25a42a00d2f77945
parenta9680e0e54cfd8a12ddb1a583b4acb96dc2bbdbd
Fix a latent bug in dw2-ranges-overlap.exp

dw2-ranges-overlap.exp creates a program where a psymtab has two
address ranges, and a function without debug info whose address is
between these two ranges.  Then it sets a breakpoint on this function
and runs to it, expecting that the language should remain "auto; c"
when stopped.

However, this test case also has a "main" function described (briefly)
in the DWARF, and this function is given language C++.  Also, a
breakpoint stop sets the current language to the language that was
used when setting the breakpoint.

My new DWARF scanner decides that this "main" is the main program and
sets the current language to C++ at startup, causing this test to
fail.

This patch fixes the test in a simple way, by introducing a new
function that takes the place of "main" in the DWARF.  I think this
still exercises the original problem, but also avoids problems with my
branch.

It seemed safe to me to submit this separately.
gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.c
gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.exp