diff options
author | Doug Evans <dje@google.com> | 2008-10-06 21:54:24 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2008-10-06 21:54:24 +0000 |
commit | 4545259105cd6f772b6d733e06f32d4e872e82c5 (patch) | |
tree | f004f0806cbf5d6ef92e793ce7bde52864ae5c13 /gdb/dwarf2read.c | |
parent | 8a498d38bec4ed8f542bf436882266fb19f3b2d9 (diff) | |
download | gdb-4545259105cd6f772b6d733e06f32d4e872e82c5.zip gdb-4545259105cd6f772b6d733e06f32d4e872e82c5.tar.gz gdb-4545259105cd6f772b6d733e06f32d4e872e82c5.tar.bz2 |
* dwarf2read.c (offset_in_cu_p): New function.
(find_partial_die,follow_die_ref): Use it.
* gdb.dwarf2/dw2-cu-size.exp: New file.
* gdb.dwarf2/dw2-cu-size.S: New file.
* gdb.dwarf2/dw2-intercu.S (.Ltype_int_in_cu2): Renamed from
.Ltype_int for clarity.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 5e4d15f..fe95cdb 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -360,7 +360,9 @@ struct dwarf2_per_cu_data { /* The start offset and length of this compilation unit. 2**30-1 bytes should suffice to store the length of any compilation unit - - if it doesn't, GDB will fall over anyway. */ + - if it doesn't, GDB will fall over anyway. + NOTE: Unlike comp_unit_head.length, this length includes + initial_length_size. */ unsigned long offset; unsigned long length : 30; @@ -1314,6 +1316,18 @@ dwarf2_build_psymtabs_easy (struct objfile *objfile, int mainline) } #endif +/* Return TRUE if OFFSET is within CU_HEADER. */ + +static inline int +offset_in_cu_p (const struct comp_unit_head *cu_header, unsigned int offset) +{ + unsigned int bottom = cu_header->offset; + unsigned int top = (cu_header->offset + + cu_header->length + + cu_header->initial_length_size); + return (offset >= bottom && offset < top); +} + /* Read in the comp unit header information from the debug_info at info_ptr. */ @@ -5990,8 +6004,7 @@ find_partial_die (unsigned long offset, struct dwarf2_cu *cu) struct dwarf2_per_cu_data *per_cu = NULL; struct partial_die_info *pd = NULL; - if (offset >= cu->header.offset - && offset < cu->header.offset + cu->header.length) + if (offset_in_cu_p (&cu->header, offset)) { pd = find_partial_die_in_comp_unit (offset, cu); if (pd != NULL) @@ -9230,12 +9243,10 @@ follow_die_ref (struct die_info *src_die, struct attribute *attr, offset = dwarf2_get_ref_die_offset (attr, cu); - if (DW_ADDR (attr) < cu->header.offset - || DW_ADDR (attr) >= cu->header.offset + cu->header.length) + if (! offset_in_cu_p (&cu->header, offset)) { struct dwarf2_per_cu_data *per_cu; - per_cu = dwarf2_find_containing_comp_unit (DW_ADDR (attr), - cu->objfile); + per_cu = dwarf2_find_containing_comp_unit (offset, cu->objfile); /* If necessary, add it to the queue and load its DIEs. */ maybe_queue_comp_unit (cu, per_cu); |