Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/elftoolchain/dist/libdwarf Convert to full recu...



details:   https://anonhg.NetBSD.org/src/rev/4421fd2ca29f
branches:  trunk
changeset: 359450:4421fd2ca29f
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Feb 10 23:39:29 2018 +0000

description:
Convert to full recursive attr/die lookup instead of one level since gcc 6
creates indirect attributes that point to indirect attributes. The code is
smaller this way too :-)

diffstat:

 external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c |  37 ++++++----------
 1 files changed, 14 insertions(+), 23 deletions(-)

diffs (77 lines):

diff -r b71b06e5fbc5 -r 4421fd2ca29f external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c
--- a/external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c   Sat Feb 10 19:34:34 2018 +0000
+++ b/external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c   Sat Feb 10 23:39:29 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dwarf_attrval.c,v 1.8 2016/03/31 15:53:33 christos Exp $       */
+/*     $NetBSD: dwarf_attrval.c,v 1.9 2018/02/10 23:39:29 christos Exp $       */
 
 /*-
  * Copyright (c) 2007 John Birrell (jb%freebsd.org@localhost)
@@ -28,7 +28,7 @@
 
 #include "_libdwarf.h"
 
-__RCSID("$NetBSD: dwarf_attrval.c,v 1.8 2016/03/31 15:53:33 christos Exp $");
+__RCSID("$NetBSD: dwarf_attrval.c,v 1.9 2018/02/10 23:39:29 christos Exp $");
 ELFTC_VCSID("Id: dwarf_attrval.c 3159 2015-02-15 21:43:27Z emaste ");
 
 int
@@ -141,23 +141,13 @@
        return (DW_DLV_OK);
 }
 
-static Dwarf_Attribute
-dwarf_indirect_find(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Half attr,
-    Dwarf_Unsigned val)
-{
-       Dwarf_Die die1;
-
-       if ((die1 = _dwarf_die_find(die, val)) == NULL)
-               return NULL;
-
-       return _dwarf_attr_find(die1, attr);
-}
-
 int
 dwarf_attrval_unsigned(Dwarf_Die die, Dwarf_Half attr, Dwarf_Unsigned *valp, Dwarf_Error *err)
 {
        Dwarf_Attribute at;
        Dwarf_Debug dbg;
+       Dwarf_Die die1;
+       int rv;
 
        dbg = die != NULL ? die->die_dbg : NULL;
 
@@ -167,13 +157,7 @@
        }
 
        *valp = 0;
-
-       if ((at = _dwarf_attr_find(die, attr)) == NULL && attr != DW_AT_type) {
-               DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
-               return (DW_DLV_NO_ENTRY);
-       }
-
-       if (at == NULL &&
+       if ((at = _dwarf_attr_find(die, attr)) == NULL &&
            ((at = _dwarf_attr_find(die, DW_AT_specification)) != NULL ||
            (at = _dwarf_attr_find(die, DW_AT_abstract_origin)) != NULL)) {
                switch (at->at_form) {
@@ -182,8 +166,15 @@
                case DW_FORM_ref4:
                case DW_FORM_ref8:
                case DW_FORM_ref_udata:
-                       at = dwarf_indirect_find(dbg, die, attr, at->u[0].u64);
-                       break;
+                       if ((die1 = _dwarf_die_find(die, at->u[0].u64)) == NULL)
+                       {
+                               at = NULL;
+                               break;
+                       }
+                       rv = dwarf_attrval_unsigned(die1, attr, valp, err);
+                       if (die != die1)
+                               dwarf_dealloc(dbg, die1, DW_DLA_DIE);
+                       return rv;
                default:
                        DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
                        return (DW_DLV_ERROR);



Home | Main Index | Thread Index | Old Index