diff options
author | Josh Stone <jistone@redhat.com> | 2009-07-14 17:57:16 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2009-07-14 17:57:16 -0700 |
commit | d52761f89a1826b1cca29b1a63269eafe7197756 (patch) | |
tree | a5b5d178e1586fb1d4cdc2733089b8d6cb753be9 /dwflpp.cxx | |
parent | 9344d46f4186dbeaff984b1af6333d5c55221cd5 (diff) | |
download | systemtap-steved-d52761f89a1826b1cca29b1a63269eafe7197756.tar.gz systemtap-steved-d52761f89a1826b1cca29b1a63269eafe7197756.tar.xz systemtap-steved-d52761f89a1826b1cca29b1a63269eafe7197756.zip |
PR4166: Allow array-like indexing on pointers
* dwflpp.cxx (dwflpp::translate_components): let pointers get treated
the same as arrays, and add a final DIE dereference for array access.
* loc2c.c (c_translate_array): tolerate pointer types
* testsuite/systemtap.base/pointer_array.*: new test
Diffstat (limited to 'dwflpp.cxx')
-rw-r--r-- | dwflpp.cxx | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -1684,13 +1684,10 @@ dwflpp::translate_components(struct obstack *pool, break; case DW_TAG_pointer_type: - if (e->components[i].first == target_symbol::comp_literal_array_index) - throw semantic_error ("cannot index pointer", e->tok); - // XXX: of course, we should support this the same way C does, - // by explicit pointer arithmetic etc. PR4166. - c_translate_pointer (pool, 1, 0 /* PR9768*/, die, tail); - break; + if (e->components[i].first != target_symbol::comp_literal_array_index) + break; + /* else fall through as an array access */ case DW_TAG_array_type: if (e->components[i].first == target_symbol::comp_literal_array_index) @@ -1772,6 +1769,11 @@ dwflpp::translate_components(struct obstack *pool, if (dwarf_attr_integrate (die, DW_AT_type, attr_mem) == NULL) throw semantic_error ("cannot get type of field: " + string(dwarf_errmsg (-1)), e->tok); } + + /* For an array index, we need to dereference the final DIE */ + if (e->components.back().first == target_symbol::comp_literal_array_index) + die = dwarf_formref_die (attr_mem, die_mem); + return die; } |