PERFORCE change 134520 for review
John Birrell
jb at FreeBSD.org
Wed Jan 30 19:54:56 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=134520
Change 134520 by jb at jb_freebsd1 on 2008/01/31 03:54:13
When looking for a DW_AT_type and one doesn't exist in the specified
DIE, there is probably a DW_AT_abstract_origin which will give us
what we were looking for.
Affected files ...
.. //depot/projects/dtrace7/src/lib/libdwarf/dwarf_attrval.c#3 edit
.. //depot/projects/dtrace7/src/lib/libdwarf/dwarf_die.c#3 edit
.. //depot/projects/dtrace7/src/lib/libdwarf/libdwarf.h#2 edit
Differences ...
==== //depot/projects/dtrace7/src/lib/libdwarf/dwarf_attrval.c#3 (text+ko) ====
@@ -209,10 +209,42 @@
*valp = 0;
- if ((av = dwarf_attrval_find(die, attr)) == NULL) {
+ if ((av = dwarf_attrval_find(die, attr)) == NULL && attr != DW_AT_type) {
DWARF_SET_ERROR(err, DWARF_E_NO_ENTRY);
ret = DWARF_E_NO_ENTRY;
- } else {
+ } else if (av == NULL && (av = dwarf_attrval_find(die,
+ DW_AT_abstract_origin)) != NULL) {
+ Dwarf_Die die1;
+ Dwarf_Unsigned val;
+
+ switch (av->av_form) {
+ case DW_FORM_data1:
+ case DW_FORM_data2:
+ case DW_FORM_data4:
+ case DW_FORM_data8:
+ case DW_FORM_ref1:
+ case DW_FORM_ref2:
+ case DW_FORM_ref4:
+ case DW_FORM_ref8:
+ case DW_FORM_ref_udata:
+ val = av->u[0].u64;
+
+ if ((die1 = dwarf_die_find(die, val)) == NULL ||
+ (av = dwarf_attrval_find(die1, attr)) == NULL) {
+ DWARF_SET_ERROR(err, DWARF_E_NO_ENTRY);
+ ret = DWARF_E_NO_ENTRY;
+ }
+ break;
+ default:
+ printf("%s(%d): av->av_form '%s' (0x%lx) not handled\n",
+ __func__,__LINE__,get_form_desc(av->av_form),
+ (u_long) av->av_form);
+ DWARF_SET_ERROR(err, DWARF_E_BAD_FORM);
+ ret = DWARF_E_BAD_FORM;
+ }
+ }
+
+ if (ret == DWARF_E_NONE) {
switch (av->av_form) {
case DW_FORM_data1:
case DW_FORM_data2:
==== //depot/projects/dtrace7/src/lib/libdwarf/dwarf_die.c#3 (text+ko) ====
@@ -175,3 +175,17 @@
return ret;
}
+
+Dwarf_Die
+dwarf_die_find(Dwarf_Die die, Dwarf_Unsigned off)
+{
+ Dwarf_CU cu = die->die_cu;
+ Dwarf_Die die1;
+
+ STAILQ_FOREACH(die1, &cu->cu_die, die_next) {
+ if ((off_t) die1->die_offset == off)
+ return (die1);
+ }
+
+ return (NULL);
+}
==== //depot/projects/dtrace7/src/lib/libdwarf/libdwarf.h#2 (text+ko) ====
@@ -114,6 +114,7 @@
__BEGIN_DECLS
Dwarf_Abbrev dwarf_abbrev_find(Dwarf_CU, uint64_t);
Dwarf_AttrValue dwarf_attrval_find(Dwarf_Die, Dwarf_Half);
+Dwarf_Die dwarf_die_find(Dwarf_Die, Dwarf_Unsigned);
const char *dwarf_errmsg(Dwarf_Error *);
const char *get_sht_desc(uint32_t);
const char *get_attr_desc(uint32_t);
More information about the p4-projects
mailing list