Files
binutils-gdb/gdb/testsuite/gdb.dwarf2/dw2-noloc.c
Guinevere Larsen b9bdebba83 gdb/testsuite: modernize gdb.dwarf2/dw2-noloc.exp
The test gdb.dwarf2/dw2-noloc.exp predates the dwarf assembler, and uses
some unreliable assumptions about where global labels get put.
Specifically, when using clang to compile the test, both labels it uses
to gauge the adresses of the main function get reshuffled to be side-by-side,
and the debug information ends up making it look like main's high pc is equal
to low pc, meaning we never enter the main function's scope, and that leads to
22 failures because the "main_*" variables are technically never in scope.

This patch modernizes the aforementioned test to use the dwarf
assembler, which removes all failures when using clang.  It also renames
the .c file to be more inline with current standard.

Approved-By: Tom Tromey <tom@tromey.com>
2024-01-22 11:30:07 +01:00

45 lines
1.8 KiB
C

/* This testcase is part of GDB, the GNU debugger.
Copyright 2009-2023 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/>. */
/* This is the value that all variables should have, here for convenience. */
#define VALUE 1234567890
/* These variables are here so that gcc adds them to the .symtab section
on its own, instead of needing the DWARF assembler. */
int file_locno_resolvable = VALUE;
int file_locempty_resolvable = VALUE;
int file_locaddr_resolvable = VALUE;
int main_local_locno_resolvable = VALUE;
int main_local_locempty_resolvable = VALUE;
int main_local_locaddr_resolvable = VALUE;
/* Despite these variables being marked as external in the debuginfo, if
we do have them as external, the compiler won't add them to the .symtab
section. */
/* extern */ int file_extern_locno_resolvable = VALUE;
/* extern */ int file_extern_locempty_resolvable = VALUE;
/* extern */ int file_extern_locaddr_resolvable = VALUE;
/* extern */ int main_extern_locno_resolvable = VALUE;
/* extern */ int main_extern_locempty_resolvable = VALUE;
/* extern */ int main_extern_locaddr_resolvable = VALUE;
int
main (void)
{
asm ("main_label: .global main_label");
return 0; /* main start */
}