+2008-01-21 Ulrich Drepper <drepper@redhat.com>
+
+ * dwarf_child.c: Minor optimizations.
+ * dwarf_getattrs.c: Likewise.
+ * dwarf_getpubnames.c: Likewise.
+ * dwarf_siblingof.c: Likewise.
+ * dwarf_tag.c: Likewise.
+
2008-01-18 Ulrich Drepper <drepper@redhat.com>
* dwarf_getsrclines.c (dwarf_getsrclines): Don't require exact match
}
if (unlikely (die->abbrev == DWARF_END_ABBREV))
{
+ invalid_dwarf:
__libdw_seterrno (DWARF_E_INVALID_DWARF);
return NULL;
}
{
/* Are we still in bounds? This test needs to be refined. */
if (unlikely (attrp + 1 >= endp))
- {
- __libdw_seterrno (DWARF_E_INVALID_DWARF);
- return NULL;
- }
+ goto invalid_dwarf;
/* Get attribute name and form.
if (die->abbrev != DWARF_END_ABBREV
&& (die->abbrev == NULL || die->abbrev->has_children))
addr = __libdw_find_attr (die, INVALID, NULL, NULL);
- if (die->abbrev == (Dwarf_Abbrev *) -1l)
+ if (unlikely (die->abbrev == (Dwarf_Abbrev *) -1l))
return -1;
/* Make sure the DIE really has children. */
/* Find the abbreviation. */
die->abbrev = __libdw_findabbrev (die->cu, u128);
- if (die->abbrev == DWARF_END_ABBREV)
+ if (unlikely (die->abbrev == DWARF_END_ABBREV))
{
+ invalid_dwarf:
__libdw_seterrno (DWARF_E_INVALID_DWARF);
return -1l;
}
if (unlikely (attrp
>= ((unsigned char *) dbg->sectiondata[IDX_debug_abbrev]->d_buf
+ dbg->sectiondata[IDX_debug_abbrev]->d_size)))
- {
- __libdw_seterrno (DWARF_E_INVALID_DWARF);
- return -1;
- }
+ goto invalid_dwarf;
/* Get attribute name and form. */
Dwarf_Attribute attr;
else if (unlikely (len >= DWARF3_LENGTH_MIN_ESCAPE_CODE
&& len <= DWARF3_LENGTH_MAX_ESCAPE_CODE))
{
+ invalid_dwarf:
__libdw_seterrno (DWARF_E_INVALID_DWARF);
goto err_return;
}
/* Read the version. It better be two for now. */
uint16_t version = read_2ubyte_unaligned (dbg, readp);
- if (version != 2)
+ if (unlikely (version != 2))
{
__libdw_seterrno (DWARF_E_INVALID_VERSION);
goto err_return;
mem[cnt].cu_offset = read_8ubyte_unaligned (dbg, readp + 2);
/* Determine the size of the CU header. */
- if (dbg->sectiondata[IDX_debug_info] == NULL
- || dbg->sectiondata[IDX_debug_info]->d_buf == NULL
- || mem[cnt].cu_offset + 3 >= dbg->sectiondata[IDX_debug_info]->d_size)
- {
- __libdw_seterrno (DWARF_E_INVALID_DWARF);
- goto err_return;
- }
+ if (unlikely (dbg->sectiondata[IDX_debug_info] == NULL
+ || dbg->sectiondata[IDX_debug_info]->d_buf == NULL
+ || (mem[cnt].cu_offset + 3
+ >= dbg->sectiondata[IDX_debug_info]->d_size)))
+ goto invalid_dwarf;
+
unsigned char *infop
= ((unsigned char *) dbg->sectiondata[IDX_debug_info]->d_buf
+ mem[cnt].cu_offset);
if (dbg == NULL)
return -1l;
- if (offset < 0)
+ if (unlikely (offset < 0))
{
__libdw_seterrno (DWARF_E_INVALID_OFFSET);
return -1l;
return 0;
/* If necessary read the set information. */
- if (dbg->pubnames_nsets == 0 && get_offsets (dbg) != 0)
+ if (dbg->pubnames_nsets == 0 && unlikely (get_offsets (dbg) != 0))
return -1l;
/* Find the place where to start. */
{
Dwarf_Off offset;
sibattr.valp = addr;
- if (__libdw_formref (&sibattr, &offset) != 0)
+ if (unlikely (__libdw_formref (&sibattr, &offset) != 0))
/* Something went wrong. */
return -1;
die->abbrev = __libdw_findabbrev (die->cu, u128);
}
- if (die->abbrev == DWARF_END_ABBREV)
+ if (unlikely (die->abbrev == DWARF_END_ABBREV))
{
__libdw_seterrno (DWARF_E_INVALID_DWARF);
return DW_TAG_invalid;