Module Name:    src
Committed By:   christos
Date:           Sat Feb 10 23:39:29 UTC 2018

Modified Files:
        src/external/bsd/elftoolchain/dist/libdwarf: dwarf_attrval.c

Log Message:
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 :-)


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 \
    src/external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c
diff -u src/external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c:1.8 src/external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c:1.9
--- src/external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c:1.8	Thu Mar 31 11:53:33 2016
+++ src/external/bsd/elftoolchain/dist/libdwarf/dwarf_attrval.c	Sat Feb 10 18:39:29 2018
@@ -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 (j...@freebsd.org)
@@ -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 @@ dwarf_attrval_signed(Dwarf_Die die, Dwar
 	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 @@ dwarf_attrval_unsigned(Dwarf_Die die, Dw
 	}
 
 	*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 @@ dwarf_attrval_unsigned(Dwarf_Die die, Dw
 		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);

Reply via email to