]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
2007-08-07 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Tue, 7 Aug 2007 19:51:01 +0000 (19:51 +0000)
committerRoland McGrath <roland@redhat.com>
Tue, 7 Aug 2007 19:51:01 +0000 (19:51 +0000)
* dwarf_getscopes.c (pc_match): Swallow dwarf_haspc error return when
error code is DWARF_E_NOERROR (0).

libdw/ChangeLog
libdw/dwarf_getscopes.c

index 78b10528c5b437253b6fcbb3a1fdd51d86154682..b6919a524f71d88908c859901918a9b02fcd739e 100644 (file)
@@ -1,3 +1,14 @@
+2007-08-07  Roland McGrath  <roland@redhat.com>
+
+       * 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  <roland@redhat.com>
 
        * libdw.h (__extern_inline): New macro.
index f9fa5132a983b7fac2fcce194251cc85c972a3c3..73431ba7ffd6390de076763917aa407b7105f7c5 100644 (file)
@@ -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);
 }