mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-06 12:09:26 +08:00
f677852bbd
When I run test-case gdb.dwarf2/dw2-abs-hi-pc.exp with gcc, we have: ... (gdb) break hello^M Breakpoint 1 at 0x4004c0: file dw2-abs-hi-pc-hello.c, line 24.^M (gdb) PASS: gdb.dwarf2/dw2-abs-hi-pc.exp: break hello ... but with clang, I run into: ... (gdb) break hello^M Breakpoint 1 at 0x4004e4^M (gdb) FAIL: gdb.dwarf2/dw2-abs-hi-pc.exp: break hello ... The problem is that the CU and function both have an empty address range: ... <0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit) <108> DW_AT_name : dw2-abs-hi-pc-hello.c <123> DW_AT_low_pc : 0x4004e0 <127> DW_AT_high_pc : 0x4004e0 <1><12f>: Abbrev Number: 2 (DW_TAG_subprogram) <131> DW_AT_name : hello <13a> DW_AT_low_pc : 0x4004e0 <13e> DW_AT_high_pc : 0x4004e0 ... The address ranges are set like this in dw2-abs-hi-pc-hello-dbg.S: ... .4byte .hello_start /* DW_AT_low_pc */ .4byte .hello_end /* DW_AT_high_pc */ ... where the labels refer to dw2-abs-hi-pc-hello.c: ... extern int v; asm (".hello_start: .globl .hello_start\n"); void hello (void) { asm (".hello0: .globl .hello0\n"); v++; asm (".hello1: .globl .hello1\n"); } asm (".hello_end: .globl .hello_end\n"); ... Using asm labels in global scope is a known source of problems, as explained in the comment of proc function_range in gdb/testsuite/lib/dwarf.exp. Fix this by using function_range instead. Tested on x86_64-linux with gcc and clang-7 and clang-12.
28 lines
889 B
C
28 lines
889 B
C
/* Copyright 2014-2021 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
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/>. */
|
|
|
|
extern int v;
|
|
|
|
void
|
|
world (void)
|
|
{
|
|
asm ("world_label: .globl world_label\n");
|
|
asm (".world0: .globl .world0\n");
|
|
v++;
|
|
asm (".world1: .globl .world1\n");
|
|
}
|