From: Roland McGrath Date: Mon, 30 Mar 2009 00:36:22 +0000 (-0700) Subject: Fix attrs that can be an expression block or a constant. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e6f99be332efe39d5a6a17a0118786d85b4d7217;p=thirdparty%2Felfutils.git Fix attrs that can be an expression block or a constant. --- diff --git a/libdw/c++/dwarf-knowledge.cc b/libdw/c++/dwarf-knowledge.cc index b7827a457..de526fe50 100644 --- a/libdw/c++/dwarf-knowledge.cc +++ b/libdw/c++/dwarf-knowledge.cc @@ -68,14 +68,15 @@ expected_value_space (int attr, int tag) case DW_AT_byte_size: case DW_AT_byte_stride: - case DW_AT_bit_offset: case DW_AT_bit_size: + case DW_AT_bit_offset: + case DW_AT_bit_stride: case DW_AT_lower_bound: case DW_AT_upper_bound: case DW_AT_count: case DW_AT_allocated: case DW_AT_associated: - return VS(reference) | VS(constant); + return VS(reference) | VS(constant) | VS(location); // XXX non-loc expr case DW_AT_stmt_list: return VS(lineptr); @@ -126,7 +127,6 @@ expected_value_space (int attr, int tag) case DW_AT_start_scope: return VS(constant); - case DW_AT_bit_stride: case DW_AT_binary_scale: case DW_AT_decimal_scale: case DW_AT_decimal_sign: diff --git a/libdw/c++/values.cc b/libdw/c++/values.cc index 63686eea3..9fd96dfaa 100644 --- a/libdw/c++/values.cc +++ b/libdw/c++/values.cc @@ -70,8 +70,9 @@ using namespace std; dwarf::value_space dwarf::attr_value::what_space () const { + unsigned int expected = expected_value_space (dwarf_whatattr (thisattr ()), + _m_tag); unsigned int possible = 0; - switch (dwarf_whatform (thisattr ())) { case DW_FORM_flag: @@ -86,6 +87,9 @@ dwarf::attr_value::what_space () const case DW_FORM_block4: /* Location expression or target constant. */ possible = VS(location) | VS(constant); + if ((expected & possible) == possible) + /* When both are expected, a block is a location expression. */ + return VS_location; break; case DW_FORM_data1: @@ -99,6 +103,9 @@ dwarf::attr_value::what_space () const | VS(source_file) | VS(source_line) | VS(source_column) | VS(location) // loclistptr | VS(lineptr) | VS(macptr) | VS(rangelistptr)); + if ((expected & possible) == (VS(constant) | VS(location))) + /* When both are expected, a constant is not a loclistptr. */ + return VS_constant; break; case DW_FORM_string: @@ -120,8 +127,6 @@ dwarf::attr_value::what_space () const throw std::runtime_error ("XXX bad form"); } - unsigned int expected = expected_value_space (dwarf_whatattr (thisattr ()), - _m_tag); if (unlikely ((expected & possible) == 0)) { if (expected == 0 && possible == (VS(unit_reference) | VS(reference))) @@ -537,5 +542,5 @@ dwarf::location_attr::to_string () const { if (is_list ()) return hex_string (_m_attr.constant (), "#"); - return "XXX"; + return "XXX-expr"; } diff --git a/tests/dwarf-print.cc b/tests/dwarf-print.cc index ece967578..8aa12ca97 100644 --- a/tests/dwarf-print.cc +++ b/tests/dwarf-print.cc @@ -71,7 +71,7 @@ print_die (const dwarf::debug_info_entry &die, if (die.has_children ()) { - if (indent >= limit) + if (limit != 0 && indent >= limit) { cout << ">...\n"; return; @@ -96,11 +96,10 @@ process_file (const char *file, unsigned int limit) cout << file << ":\n"; - if (limit > 0) - for (dwarf::compile_units::const_iterator i = dw.compile_units ().begin (); - i != dw.compile_units ().end (); - ++i) - print_die (*i, 1, limit); + for (dwarf::compile_units::const_iterator i = dw.compile_units ().begin (); + i != dw.compile_units ().end (); + ++i) + print_die (*i, 1, limit); } int @@ -117,7 +116,7 @@ main (int argc, char *argv[]) cout << hex << setiosflags (ios::showbase); - unsigned int depth = 1; + unsigned int depth = 0; if (argc > 1 && sscanf (argv[1], "--depth=%u", &depth) == 1) { --argc;