From: Roland McGrath Date: Tue, 7 Aug 2007 19:51:01 +0000 (+0000) Subject: 2007-08-07 Roland McGrath X-Git-Tag: elfutils-0.129~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1a4817e7d913efbaa7d4f4462949ed7b53618b3;p=thirdparty%2Felfutils.git 2007-08-07 Roland McGrath * dwarf_getscopes.c (pc_match): Swallow dwarf_haspc error return when error code is DWARF_E_NOERROR (0). --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 78b10528c..b6919a524 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,14 @@ +2007-08-07 Roland McGrath + + * dwarf_getscopes.c (pc_match): Swallow dwarf_haspc error return when + error code is DWARF_E_NOERROR (0). + + * dwarf_getscopes.c (pc_record): Always bail early if DIE->prune. + Fix typo in __libdw_visit_scopes argument. + + * dwarf_getscopes.c (pc_match): Check dwarf_haspc error return, + swallow DWARF_E_NO_DEBUG_RANGES but not other errors. + 2007-07-03 Roland McGrath * libdw.h (__extern_inline): New macro. diff --git a/libdw/dwarf_getscopes.c b/libdw/dwarf_getscopes.c index f9fa5132a..73431ba7f 100644 --- a/libdw/dwarf_getscopes.c +++ b/libdw/dwarf_getscopes.c @@ -1,5 +1,5 @@ /* Return scope DIEs containing PC address. - Copyright (C) 2005 Red Hat, Inc. + Copyright (C) 2005, 2007 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -71,10 +71,32 @@ pc_match (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) { struct args *a = arg; - if (a->scopes != NULL || INTUSE(dwarf_haspc) (&die->die, a->pc) <= 0) + if (a->scopes != NULL) die->prune = true; - else if (INTUSE (dwarf_tag) (&die->die) == DW_TAG_inlined_subroutine) - a->inlined = depth; + else + { + /* dwarf_haspc returns an error if there are no appropriate attributes. + But we use it indiscriminantly instead of presuming which tags can + have PC attributes. So when it fails for that reason, treat it just + as a nonmatching return. */ + int result = INTUSE(dwarf_haspc) (&die->die, a->pc); + if (result < 0) + { + int error = INTUSE(dwarf_errno) (); + if (error != DWARF_E_NOERROR && error != DWARF_E_NO_DEBUG_RANGES) + { + __libdw_seterrno (error); + return -1; + } + result = 0; + } + if (result == 0) + die->prune = true; + + if (!die->prune + && INTUSE (dwarf_tag) (&die->die) == DW_TAG_inlined_subroutine) + a->inlined = depth; + } return 0; } @@ -119,11 +141,11 @@ pc_record (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) { struct args *a = arg; + if (die->prune) + return 0; + if (a->scopes == NULL) { - if (die->prune) - return 0; - /* We have hit the innermost DIE that contains the target PC. */ a->nscopes = depth + 1 - a->inlined; @@ -175,7 +197,7 @@ pc_record (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) If we don't find it, return to search the containing scope. If we do find it, the nonzero return value will bail us out of the postorder traversal. */ - return __libdw_visit_scopes (depth, die, &origin_match, NULL, &a); + return __libdw_visit_scopes (depth, die, &origin_match, NULL, a); }