diff options
author | Tom Tromey <tromey@adacore.com> | 2021-06-04 13:51:23 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2021-06-04 13:51:23 -0600 |
commit | 386de171cbffa86e804057030f3d64a404279f43 (patch) | |
tree | fb9c127f3c004533fa43110baa467b7405e323ce /gdb/gdbtypes.h | |
parent | 4351271e9c98553900f6ae3cbcaaa75198909daa (diff) | |
download | fsf-binutils-gdb-386de171cbffa86e804057030f3d64a404279f43.zip fsf-binutils-gdb-386de171cbffa86e804057030f3d64a404279f43.tar.gz fsf-binutils-gdb-386de171cbffa86e804057030f3d64a404279f43.tar.bz2 |
Add PROP_VARIABLE_NAME
With -fgnat-encodings=minimal, an internal version (these patches will
be upstreamed in the near future) of the Ada compiler can emit DWARF
for an array where the bound comes from a variable, like:
<1><12a7>: Abbrev Number: 7 (DW_TAG_array_type)
<12a8> DW_AT_name : (indirect string, offset: 0x1ae9): pck__my_array
[...]
<2><12b4>: Abbrev Number: 8 (DW_TAG_subrange_type)
<12b5> DW_AT_type : <0x1294>
<12b9> DW_AT_upper_bound : <0x1277>
With the upper bound DIE being:
<1><1277>: Abbrev Number: 2 (DW_TAG_variable)
<1278> DW_AT_name : (indirect string, offset: 0x1a4d): pck__my_length___U
<127c> DW_AT_type : <0x128f>
<1280> DW_AT_external : 1
<1280> DW_AT_artificial : 1
<1280> DW_AT_declaration : 1
Note that the variable is just a declaration -- in this situation, the
variable comes from another compilation unit, and must be found when
trying to compute the array bound.
This patch adds a new PROP_VARIABLE_NAME kind, to enable this search.
This same scenario can occur with DW_OP_GNU_variable_value, so this
patch adds support for that as well.
gdb/ChangeLog
2021-06-04 Tom Tromey <tromey@adacore.com>
* dwarf2/read.h (dwarf2_fetch_die_type_sect_off): Add 'var_name'
parameter.
* dwarf2/loc.c (dwarf2_evaluate_property) <case
PROP_VARIABLE_NAME>: New case.
(compute_var_value): New function.
(sect_variable_value): Use compute_var_value.
* dwarf2/read.c (attr_to_dynamic_prop): Handle DW_TAG_variable.
(var_decl_name): New function.
(dwarf2_fetch_die_type_sect_off): Add 'var_name' parameter.
* gdbtypes.h (enum dynamic_prop_kind) <PROP_VARIABLE_NAME>: New
constant.
(union dynamic_prop_data) <variable_name>: New member.
(struct dynamic_prop) <variable_name, set_variable_name>: New
methods.
gdb/testsuite/ChangeLog
2021-06-04 Tom Tromey <tromey@adacore.com>
* gdb.ada/array_of_symbolic_length.exp: New file.
* gdb.ada/array_of_symbolic_length/foo.adb: New file.
* gdb.ada/array_of_symbolic_length/gl.adb: New file.
* gdb.ada/array_of_symbolic_length/gl.ads: New file.
* gdb.ada/array_of_symbolic_length/pck.adb: New file.
* gdb.ada/array_of_symbolic_length/pck.ads: New file.
Diffstat (limited to 'gdb/gdbtypes.h')
-rw-r--r-- | gdb/gdbtypes.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index bb4d26e..0cc00e7 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -388,6 +388,7 @@ enum dynamic_prop_kind PROP_LOCLIST, /* Location list. */ PROP_VARIANT_PARTS, /* Variant parts. */ PROP_TYPE, /* Type. */ + PROP_VARIABLE_NAME, /* Variable name. */ }; union dynamic_prop_data @@ -414,6 +415,11 @@ union dynamic_prop_data rewrite the property's kind and set this field. */ struct type *original_type; + + /* Name of a variable to look up; the variable holds the value of + this property. */ + + const char *variable_name; }; /* * Used to store a dynamic property. */ @@ -496,6 +502,22 @@ struct dynamic_prop m_data.original_type = original_type; } + /* Return the name of the variable that holds this property's value. + Only valid for PROP_VARIABLE_NAME. */ + const char *variable_name () const + { + gdb_assert (m_kind == PROP_VARIABLE_NAME); + return m_data.variable_name; + } + + /* Set the name of the variable that holds this property's value, + and set this property to be of kind PROP_VARIABLE_NAME. */ + void set_variable_name (const char *name) + { + m_kind = PROP_VARIABLE_NAME; + m_data.variable_name = name; + } + /* Determine which field of the union dynamic_prop.data is used. */ enum dynamic_prop_kind m_kind; |