[gdb/testsuite] Use function_range in gdb.dwarf2/dw2-abs-hi-pc.exp
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.
This commit is contained in:
parent
720f6ee095
commit
f677852bbd
5 changed files with 41 additions and 18 deletions
|
@ -24,8 +24,8 @@
|
|||
.byte 0x1 /* DW_AT_language */
|
||||
.ascii "dw2-abs-hi-pc-hello.c\0" /* DW_AT_name */
|
||||
.ascii "/tmp\0" /* DW_AT_comp_dir */
|
||||
.4byte .hello_start /* DW_AT_low_pc */
|
||||
.4byte .hello_end /* DW_AT_high_pc */
|
||||
.4byte HELLO_START /* DW_AT_low_pc */
|
||||
.4byte HELLO_END /* DW_AT_high_pc */
|
||||
.4byte .Ldebug_line0 /* DW_AT_stmt_list */
|
||||
.uleb128 0x2 /* (DIE (0x2d) DW_TAG_subprogram) */
|
||||
.byte 0x1 /* DW_AT_external */
|
||||
|
@ -33,8 +33,8 @@
|
|||
.byte 0x1 /* DW_AT_decl_file (hello.c) */
|
||||
.byte 0x13 /* DW_AT_decl_line */
|
||||
.byte 0x1 /* DW_AT_prototyped */
|
||||
.4byte .hello_start /* DW_AT_low_pc */
|
||||
.4byte .hello_end /* DW_AT_high_pc */
|
||||
.4byte HELLO_START /* DW_AT_low_pc */
|
||||
.4byte HELLO_END /* DW_AT_high_pc */
|
||||
.byte 0 /* end of children of DIE 0xb */
|
||||
.Ledebug_info0:
|
||||
|
||||
|
@ -114,7 +114,7 @@ LELTP:
|
|||
.byte 0 /* set address to .hello_start */
|
||||
.uleb128 0x5
|
||||
.byte 0x2
|
||||
.4byte .hello_start
|
||||
.4byte HELLO_START
|
||||
.byte 0x3 /* DW_LNS_advance_line */
|
||||
.sleb128 22 /* ... to 23 */
|
||||
.byte 0x5 /* column 0 */
|
||||
|
@ -144,7 +144,7 @@ LELTP:
|
|||
.byte 0 /* set address to .hello_end */
|
||||
.uleb128 0x5
|
||||
.byte 0x2
|
||||
.4byte .hello_end
|
||||
.4byte HELLO_END
|
||||
.byte 0 /* end sequence */
|
||||
.uleb128 0x1
|
||||
.byte 0x1
|
||||
|
|
|
@ -17,12 +17,11 @@
|
|||
|
||||
extern int v;
|
||||
|
||||
asm (".hello_start: .globl .hello_start\n");
|
||||
void
|
||||
hello (void)
|
||||
{
|
||||
asm ("hello_label: .globl hello_label\n");
|
||||
asm (".hello0: .globl .hello0\n");
|
||||
v++;
|
||||
asm (".hello1: .globl .hello1\n");
|
||||
}
|
||||
asm (".hello_end: .globl .hello_end\n");
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
.byte 0x1 /* DW_AT_language */
|
||||
.ascii "dw2-abs-hi-pc-world.c\0" /* DW_AT_name */
|
||||
.ascii "/tmp\0" /* DW_AT_comp_dir */
|
||||
.4byte .world_start /* DW_AT_low_pc */
|
||||
.4byte .world_end /* DW_AT_high_pc */
|
||||
.4byte WORLD_START /* DW_AT_low_pc */
|
||||
.4byte WORLD_END /* DW_AT_high_pc */
|
||||
.4byte .Ldebug_line0 /* DW_AT_stmt_list */
|
||||
.uleb128 0x2 /* (DIE (0x2d) DW_TAG_subprogram) */
|
||||
.byte 0x1 /* DW_AT_external */
|
||||
|
@ -33,8 +33,8 @@
|
|||
.byte 0x1 /* DW_AT_decl_file (world.c) */
|
||||
.byte 0x13 /* DW_AT_decl_line */
|
||||
.byte 0x1 /* DW_AT_prototyped */
|
||||
.4byte .world_start /* DW_AT_low_pc */
|
||||
.4byte .world_end /* DW_AT_high_pc */
|
||||
.4byte WORLD_START /* DW_AT_low_pc */
|
||||
.4byte WORLD_END /* DW_AT_high_pc */
|
||||
.byte 0 /* end of children of DIE 0xb */
|
||||
.Ledebug_info0:
|
||||
|
||||
|
@ -114,7 +114,7 @@ LELTP:
|
|||
.byte 0 /* set address to .world_start */
|
||||
.uleb128 0x5
|
||||
.byte 0x2
|
||||
.4byte .world_start
|
||||
.4byte WORLD_START
|
||||
.byte 0x3 /* DW_LNS_advance_line */
|
||||
.sleb128 22 /* ... to 23 */
|
||||
.byte 0x5 /* column 0 */
|
||||
|
@ -144,7 +144,7 @@ LELTP:
|
|||
.byte 0 /* set address to .world_end */
|
||||
.uleb128 0x5
|
||||
.byte 0x2
|
||||
.4byte .world_end
|
||||
.4byte WORLD_END
|
||||
.byte 0 /* end sequence */
|
||||
.uleb128 0x1
|
||||
.byte 0x1
|
||||
|
|
|
@ -17,12 +17,11 @@
|
|||
|
||||
extern int v;
|
||||
|
||||
asm (".world_start: .globl .world_start\n");
|
||||
void
|
||||
world (void)
|
||||
{
|
||||
asm ("world_label: .globl world_label\n");
|
||||
asm (".world0: .globl .world0\n");
|
||||
v++;
|
||||
asm (".world1: .globl .world1\n");
|
||||
}
|
||||
asm (".world_end: .globl .world_end\n");
|
||||
|
|
|
@ -20,9 +20,34 @@ if {![dwarf2_support]} {
|
|||
}
|
||||
|
||||
standard_testfile
|
||||
set executable ${testfile}
|
||||
|
||||
if {[build_executable ${testfile}.exp ${executable} "${testfile}.c ${testfile}-hello-dbg.S ${testfile}-hello.c ${testfile}-world-dbg.S ${testfile}-world.c" "nodebug"] == -1} {
|
||||
set sources \
|
||||
[list \
|
||||
${testfile}.c \
|
||||
${testfile}-hello.c \
|
||||
${testfile}-world.c]
|
||||
set sources [lmap i $sources { string cat "${srcdir}/${subdir}/" $i }]
|
||||
lassign [function_range hello $sources] \
|
||||
hello_start hello_len
|
||||
lassign [function_range world $sources] \
|
||||
world_start world_len
|
||||
|
||||
set sources \
|
||||
[list \
|
||||
${testfile}.c \
|
||||
${testfile}-hello-dbg.S \
|
||||
${testfile}-hello.c \
|
||||
${testfile}-world-dbg.S \
|
||||
${testfile}-world.c]
|
||||
set flags \
|
||||
[list \
|
||||
"nodebug" \
|
||||
"additional_flags=\"-DHELLO_START=$hello_start\"" \
|
||||
"additional_flags=\"-DHELLO_END=$hello_start + $hello_len\"" \
|
||||
"additional_flags=\"-DWORLD_START=$world_start\"" \
|
||||
"additional_flags=\"-DWORLD_END=$world_start + $world_len\""]
|
||||
set executable ${testfile}
|
||||
if {[build_executable ${testfile}.exp ${executable} $sources $flags] == -1} {
|
||||
return -1
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue