gdb/
* dwarf2read.c (dwarf2_get_pc_bounds): Moved the `DW_AT_ranges' parsing code with its variables OBJFILE, CU_HEADER and OBFD into ... (dwarf2_ranges_read): ... a new function. (read_partial_die): Implemented the parsing of `DW_AT_ranges'. gdb/testsuite/ * gdb.dwarf2/dw2-ranges.S, gdb.dwarf2/dw2-ranges.exp: New files.
This commit is contained in:
parent
a67d13cf51
commit
4303944388
|
@ -1,3 +1,10 @@
|
|||
2007-11-25 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* dwarf2read.c (dwarf2_get_pc_bounds): Moved the `DW_AT_ranges' parsing
|
||||
code with its variables OBJFILE, CU_HEADER and OBFD into ...
|
||||
(dwarf2_ranges_read): ... a new function.
|
||||
(read_partial_die): Implemented the parsing of `DW_AT_ranges'.
|
||||
|
||||
2007-11-24 Pedro Alves <pedro_alves@portugalmail.pt>
|
||||
|
||||
* win32-nat.c (DR6_CLEAR_VALUE): New define.
|
||||
|
|
|
@ -3077,45 +3077,18 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
|
|||
local_symbols = new->locals;
|
||||
}
|
||||
|
||||
/* Get low and high pc attributes from a die. Return 1 if the attributes
|
||||
are present and valid, otherwise, return 0. Return -1 if the range is
|
||||
discontinuous, i.e. derived from DW_AT_ranges information. */
|
||||
/* Get low and high pc attributes from DW_AT_ranges attribute value OFFSET.
|
||||
Return 1 if the attributes are present and valid, otherwise, return 0. */
|
||||
|
||||
static int
|
||||
dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
|
||||
CORE_ADDR *highpc, struct dwarf2_cu *cu)
|
||||
dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
|
||||
CORE_ADDR *high_return, struct dwarf2_cu *cu)
|
||||
{
|
||||
struct objfile *objfile = cu->objfile;
|
||||
struct comp_unit_head *cu_header = &cu->header;
|
||||
struct attribute *attr;
|
||||
bfd *obfd = objfile->obfd;
|
||||
CORE_ADDR low = 0;
|
||||
CORE_ADDR high = 0;
|
||||
int ret = 0;
|
||||
|
||||
attr = dwarf2_attr (die, DW_AT_high_pc, cu);
|
||||
if (attr)
|
||||
{
|
||||
high = DW_ADDR (attr);
|
||||
attr = dwarf2_attr (die, DW_AT_low_pc, cu);
|
||||
if (attr)
|
||||
low = DW_ADDR (attr);
|
||||
else
|
||||
/* Found high w/o low attribute. */
|
||||
return 0;
|
||||
|
||||
/* Found consecutive range of addresses. */
|
||||
ret = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
attr = dwarf2_attr (die, DW_AT_ranges, cu);
|
||||
if (attr != NULL)
|
||||
{
|
||||
unsigned int addr_size = cu_header->addr_size;
|
||||
CORE_ADDR mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
|
||||
/* Value of the DW_AT_ranges attribute is the offset in the
|
||||
.debug_ranges section. */
|
||||
unsigned int offset = DW_UNSND (attr);
|
||||
/* Base address selection entry. */
|
||||
CORE_ADDR base;
|
||||
int found_base;
|
||||
|
@ -3123,6 +3096,8 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
|
|||
gdb_byte *buffer;
|
||||
CORE_ADDR marker;
|
||||
int low_set;
|
||||
CORE_ADDR low = 0;
|
||||
CORE_ADDR high = 0;
|
||||
|
||||
found_base = cu_header->base_known;
|
||||
base = cu_header->base_address;
|
||||
|
@ -3213,6 +3188,49 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
|
|||
describes an empty scope, i.e. no instructions. */
|
||||
return 0;
|
||||
|
||||
if (low_return)
|
||||
*low_return = low;
|
||||
if (high_return)
|
||||
*high_return = high;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get low and high pc attributes from a die. Return 1 if the attributes
|
||||
are present and valid, otherwise, return 0. Return -1 if the range is
|
||||
discontinuous, i.e. derived from DW_AT_ranges information. */
|
||||
static int
|
||||
dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
|
||||
CORE_ADDR *highpc, struct dwarf2_cu *cu)
|
||||
{
|
||||
struct attribute *attr;
|
||||
CORE_ADDR low = 0;
|
||||
CORE_ADDR high = 0;
|
||||
int ret = 0;
|
||||
|
||||
attr = dwarf2_attr (die, DW_AT_high_pc, cu);
|
||||
if (attr)
|
||||
{
|
||||
high = DW_ADDR (attr);
|
||||
attr = dwarf2_attr (die, DW_AT_low_pc, cu);
|
||||
if (attr)
|
||||
low = DW_ADDR (attr);
|
||||
else
|
||||
/* Found high w/o low attribute. */
|
||||
return 0;
|
||||
|
||||
/* Found consecutive range of addresses. */
|
||||
ret = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
attr = dwarf2_attr (die, DW_AT_ranges, cu);
|
||||
if (attr != NULL)
|
||||
{
|
||||
/* Value of the DW_AT_ranges attribute is the offset in the
|
||||
.debug_ranges section. */
|
||||
if (!dwarf2_ranges_read (DW_UNSND (attr), &low, &high, cu))
|
||||
return 0;
|
||||
/* Found discontinuous range of addresses. */
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
@ -5569,6 +5587,11 @@ read_partial_die (struct partial_die_info *part_die,
|
|||
has_high_pc_attr = 1;
|
||||
part_die->highpc = DW_ADDR (&attr);
|
||||
break;
|
||||
case DW_AT_ranges:
|
||||
if (dwarf2_ranges_read (DW_UNSND (&attr), &part_die->lowpc,
|
||||
&part_die->highpc, cu))
|
||||
has_low_pc_attr = has_high_pc_attr = 1;
|
||||
break;
|
||||
case DW_AT_location:
|
||||
/* Support the .debug_loc offsets */
|
||||
if (attr_form_is_block (&attr))
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2007-11-25 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.dwarf2/dw2-ranges.S, gdb.dwarf2/dw2-ranges.exp: New files.
|
||||
|
||||
2007-11-22 Maciej W. Rozycki <macro@mips.com>
|
||||
|
||||
* gdb.trace/backtrace.exp: Fix a typo.
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
Copyright 2007 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/>.
|
||||
*/
|
||||
|
||||
/* Despite the sections below will be adjacent the assembler has to produce
|
||||
DW_AT_ranges as the linker could place both sections at arbitrary locations.
|
||||
*/
|
||||
|
||||
/* Without this directive GAS will not emit DWARF2 unless we provide an
|
||||
instruction to assemble. We want to avoid any instructions to
|
||||
remain architecture independent. */
|
||||
.loc_mark_labels 1
|
||||
|
||||
.text
|
||||
|
||||
.globl main
|
||||
.func main
|
||||
main: .int 0
|
||||
.endfunc
|
||||
.size main, . - main
|
||||
|
||||
.section .text.func, "ax", @progbits
|
||||
.globl func
|
||||
.func func
|
||||
func: .int 0
|
||||
.endfunc
|
||||
.size func, . - func
|
|
@ -0,0 +1,49 @@
|
|||
# Copyright 2007 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/>.
|
||||
|
||||
# Test DW_TAG_compile_unit with no children and with neither DW_AT_low_pc nor
|
||||
# DW_AT_high_pc but with DW_AT_ranges instead.
|
||||
|
||||
# This test can only be run on targets which support DWARF-2 and use gas.
|
||||
# For now pick a sampling of likely targets.
|
||||
if {![istarget *-*-linux*]
|
||||
&& ![istarget *-*-gnu*]
|
||||
&& ![istarget *-*-elf*]
|
||||
&& ![istarget *-*-openbsd*]
|
||||
&& ![istarget arm-*-eabi*]
|
||||
&& ![istarget powerpc-*-eabi*]} {
|
||||
verbose "Skipping DW_AT_ranges test."
|
||||
return 0
|
||||
}
|
||||
|
||||
set testfile "dw2-ranges"
|
||||
set srcfile ${testfile}.S
|
||||
set binfile ${objdir}/${subdir}/${testfile}.o
|
||||
|
||||
if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object debug] != "" } {
|
||||
return -1
|
||||
}
|
||||
|
||||
gdb_exit
|
||||
gdb_start
|
||||
gdb_reinitialize_dir $srcdir/$subdir
|
||||
gdb_load ${binfile}
|
||||
|
||||
# Correct output:
|
||||
# Line 39 of "../.././gdb/testsuite/gdb.dwarf2/dw2-ranges.S" starts at address 0x4 and ends at 0x8.
|
||||
# Wrong output:
|
||||
# No line number information available for address 0x4
|
||||
|
||||
gdb_test "info line func" "Line \[0-9\]* of .* starts at address .* and ends at .*"
|
Loading…
Reference in New Issue