binutils-gdb/gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.c
Tom Tromey d30c6bef12 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.
2021-08-23 14:14:20 -06:00

43 lines
1 KiB
C

/*
Copyright 2020-2021 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
int
bar (int a)
{
asm ("bar_label: .globl bar_label");
return a + 1;
}
int
foo (int a)
{
asm ("foo_label: .globl foo_label");
return bar (a * 2) + 3;
}
int
quux (int a)
{
asm ("quux_label: .globl quux_label");
return foo (a);
}
int
main (void)
{
asm ("main_label: .globl main_label");
return quux (5) + 1;
}