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 Handle DW_AT_specifi...



details:   https://anonhg.NetBSD.org/src/rev/04ebd6e59e96
branches:  trunk
changeset: 344240:04ebd6e59e96
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Mar 17 18:52:26 2016 +0000

description:
Handle DW_AT_specification better; also don't core-dump if at == NULL.
XXX: Is that right?

diffstat:

 external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c |  47 ++++++++++------
 1 files changed, 29 insertions(+), 18 deletions(-)

diffs (103 lines):

diff -r 6bceea155270 -r 04ebd6e59e96 external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c
--- a/external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c   Thu Mar 17 18:43:29 2016 +0000
+++ b/external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c   Thu Mar 17 18:52:26 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dwarf_attrval.c,v 1.4 2016/02/20 02:43:41 christos Exp $       */
+/*     $NetBSD: dwarf_attrval.c,v 1.5 2016/03/17 18:52:26 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.4 2016/02/20 02:43:41 christos Exp $");
+__RCSID("$NetBSD: dwarf_attrval.c,v 1.5 2016/03/17 18:52:26 christos Exp $");
 ELFTC_VCSID("Id: dwarf_attrval.c 3159 2015-02-15 21:43:27Z emaste ");
 
 int
@@ -141,12 +141,25 @@
        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;
+       Dwarf_Attribute at;
+
+       if ((die1 = _dwarf_die_find(die, val)) == NULL)
+               return NULL;
+
+       at = _dwarf_attr_find(die1, attr);
+       dwarf_dealloc(dbg, die1, DW_DLA_DIE);
+       return at;
+}
+
 int
 dwarf_attrval_unsigned(Dwarf_Die die, Dwarf_Half attr, Dwarf_Unsigned *valp, Dwarf_Error *err)
 {
        Dwarf_Attribute at;
-       Dwarf_Die die1;
-       Dwarf_Unsigned val;
        Dwarf_Debug dbg;
 
        dbg = die != NULL ? die->die_dbg : NULL;
@@ -163,7 +176,6 @@
                return (DW_DLV_NO_ENTRY);
        }
 
-       die1 = NULL;
        if (at == NULL &&
            (at = _dwarf_attr_find(die, DW_AT_abstract_origin)) != NULL) {
                switch (at->at_form) {
@@ -172,14 +184,7 @@
                case DW_FORM_ref4:
                case DW_FORM_ref8:
                case DW_FORM_ref_udata:
-                       val = at->u[0].u64;
-                       if ((die1 = _dwarf_die_find(die, val)) == NULL ||
-                           (at = _dwarf_attr_find(die1, attr)) == NULL) {
-                               if (die1 != NULL)
-                                       dwarf_dealloc(dbg, die1, DW_DLA_DIE);
-                               DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
-                               return (DW_DLV_NO_ENTRY);
-                       }
+                       at = dwarf_indirect_find(dbg, die, attr, at->u[0].u64);
                        break;
                default:
                        DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
@@ -187,6 +192,16 @@
                }
        }
 
+       if (at == NULL &&
+           (at = _dwarf_attr_find(die, DW_AT_specification)) != NULL) {
+           at = dwarf_indirect_find(dbg, die, attr, at->u[0].u64);
+       }
+
+       if (at == NULL)  {
+               DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
+               return (DW_DLV_NO_ENTRY);
+       }
+
        switch (at->at_form) {
        case DW_FORM_addr:
        case DW_FORM_data1:
@@ -202,14 +217,10 @@
                *valp = at->u[0].u64;
                break;
        default:
-               if (die1 != NULL)
-                       dwarf_dealloc(dbg, die1, DW_DLA_DIE);
+       out:
                DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
                return (DW_DLV_ERROR);
        }
 
-       if (die1 != NULL)
-               dwarf_dealloc(dbg, die1, DW_DLA_DIE);
-
        return (DW_DLV_OK);
 }



Home | Main Index | Thread Index | Old Index