diff options
author | Jason King <jason.brian.king@gmail.com> | 2012-06-28 19:37:15 +0100 |
---|---|---|
committer | Jason King <jason.brian.king@gmail.com> | 2012-06-28 19:37:15 +0100 |
commit | 09d1f8075d1105a2e9528cd0bb5f60462378ee7e (patch) | |
tree | bc4cc671f1c3fe886ecf9cc5adeda6e66110df8d /usr/src/tools/ctf/cvt/dwarf.c | |
parent | 4445fffbbb1ea25fd0e9ea68b9380dd7a6709025 (diff) | |
download | illumos-joyent-09d1f8075d1105a2e9528cd0bb5f60462378ee7e.tar.gz |
1973 ctfconvert VLA support is broken (again) for DWARF objects
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Gordon Ross <gwr@nexenta.com>
Diffstat (limited to 'usr/src/tools/ctf/cvt/dwarf.c')
-rw-r--r-- | usr/src/tools/ctf/cvt/dwarf.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/usr/src/tools/ctf/cvt/dwarf.c b/usr/src/tools/ctf/cvt/dwarf.c index ce8f6f9601..29848d6678 100644 --- a/usr/src/tools/ctf/cvt/dwarf.c +++ b/usr/src/tools/ctf/cvt/dwarf.c @@ -22,6 +22,10 @@ * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright 2012 Jason King. All rights reserved. + * Use is subject to license terms. + */ /* * DWARF to tdata conversion @@ -360,6 +364,37 @@ die_attr_form(dwarf_t *dw, Dwarf_Attribute attr) return (0); } +/* + * the following functions lookup the value of an attribute in a DIE: + * + * die_signed + * die_unsigned + * die_bool + * die_string + * + * They all take the same parameters (with the exception of valp which is + * a pointer to the type of the attribute we are looking up): + * + * dw - the dwarf object to look in + * die - the DIE we're interested in + * name - the name of the attribute to lookup + * valp - pointer to where the value of the attribute is placed + * req - if the value is required (0 / non-zero) + * + * If the attribute is not found, one of the following happens: + * - program terminates (req is non-zero) + * - function returns 0 + * + * If the value is found, and in a form (class) we can handle, the function + * returns 1. + * + * Currently, we can only handle attribute values that are stored as + * constants (immediate value). If an attribute has a form we cannot + * handle (for example VLAs may store the dimensions of the array + * as a DWARF expression that can compute it at runtime by reading + * values off the stack or other locations in memory), it is treated + * the same as if the attribute does not exist. + */ static int die_signed(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Signed *valp, int req) @@ -371,6 +406,9 @@ die_signed(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Signed *valp, return (0); /* die_attr will terminate for us if necessary */ if (dwarf_formsdata(attr, &val, &dw->dw_err) != DW_DLV_OK) { + if (req == 0) + return (0); + terminate("die %llu: failed to get signed (form 0x%x)\n", die_off(dw, die), die_attr_form(dw, attr)); } @@ -392,6 +430,9 @@ die_unsigned(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Unsigned *valp, return (0); /* die_attr will terminate for us if necessary */ if (dwarf_formudata(attr, &val, &dw->dw_err) != DW_DLV_OK) { + if (req == 0) + return (0); + terminate("die %llu: failed to get unsigned (form 0x%x)\n", die_off(dw, die), die_attr_form(dw, attr)); } @@ -412,6 +453,9 @@ die_bool(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Bool *valp, int req) return (0); /* die_attr will terminate for us if necessary */ if (dwarf_formflag(attr, &val, &dw->dw_err) != DW_DLV_OK) { + if (req == 0) + return (0); + terminate("die %llu: failed to get bool (form 0x%x)\n", die_off(dw, die), die_attr_form(dw, attr)); } @@ -432,6 +476,9 @@ die_string(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, char **strp, int req) return (0); /* die_attr will terminate for us if necessary */ if (dwarf_formstring(attr, &str, &dw->dw_err) != DW_DLV_OK) { + if (req == 0) + return (0); + terminate("die %llu: failed to get string (form 0x%x)\n", die_off(dw, die), die_attr_form(dw, attr)); } |