diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-11-29 00:14:35 +0000 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2019-12-01 22:31:32 +0000 |
commit | 216a7e6b9e5d2b279276f3bd8c11145a7d9b59ac (patch) | |
tree | 9138bacbc1bf655ff3d28324a4831f89ab505acc /gdb/testsuite | |
parent | 11a8b1641e310f3d47173125b62ee2e2147e74f3 (diff) | |
download | gdb-216a7e6b9e5d2b279276f3bd8c11145a7d9b59ac.zip gdb-216a7e6b9e5d2b279276f3bd8c11145a7d9b59ac.tar.gz gdb-216a7e6b9e5d2b279276f3bd8c11145a7d9b59ac.tar.bz2 |
gdb: Dynamic string length support
Add support for strings with dynamic length using the DWARF attribute
DW_AT_string_length.
Currently gFortran generates DWARF for some strings that make use of
DW_AT_string_length like this:
<1><2cc>: Abbrev Number: 20 (DW_TAG_string_type)
<2cd> DW_AT_string_length: 5 byte block: 99 bd 1 0 0 (DW_OP_call4: <0x1bd>)
<2d3> DW_AT_byte_size : 4
<2d4> DW_AT_sibling : <0x2e2>
In this type entry the DW_AT_string_length attribute references a
second DW_TAG_formal_parameter that contains the string length. The
DW_AT_byte_size indicates that the length is a 4-byte value.
This commit extends GDB's DWARF parsing for strings so that we can
create dynamic types as well as static types, based on the attribute
the DWARF contains.
I then extend the dynamic type resolution code in gdbtypes.c to add
support for resolving dynamic strings.
gdb/ChangeLog:
* dwarf2read.c (read_tag_string_type): Read the fields required to
make a dynamic string, and possibly create a dynamic range for the
string.
(attr_to_dynamic_prop): Setup is_reference based on the type of
attribute being processed.
* gdbtypes.c (is_dynamic_type_internal): Handle TYPE_CODE_STRING.
(resolve_dynamic_array): Rename to...
(resolve_dynamic_array_or_string): ...this, update header comment,
and accept TYPE_CODE_STRING.
(resolve_dynamic_type_internal): Handle TYPE_CODE_STRING.
gdb/testsuite/ChangeLog:
* gdb.fortran/array-slices.exp: Add test for dynamic strings.
Change-Id: I03f2d181b26156f48f27a03c8a59f9bd4d71ac17
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.fortran/array-slices.exp | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f3bffa5..a4d2556 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-12-01 Andrew Burgess <andrew.burgess@embecosm.com> + + * gdb.fortran/array-slices.exp: Add test for dynamic strings. + 2019-12-01 Richard Bunt <richard.bunt@arm.com> Andrew Burgess <andrew.burgess@embecosm.com> diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp index db07ace..7a7baf7 100644 --- a/gdb/testsuite/gdb.fortran/array-slices.exp +++ b/gdb/testsuite/gdb.fortran/array-slices.exp @@ -46,12 +46,21 @@ set array_contents \ " = \\(\\( -26, -25, -24, -23, -22, -21\\) \\( -19, -18, -17, -16, -15, -14\\) \\( -12, -11, -10, -9, -8, -7\\) \\)" \ " = \\(\\( -26, -24, -22, -20, -18\\) \\( -5, -3, -1, 1, 3\\) \\( 16, 18, 20, 22, 24\\) \\( 37, 39, 41, 43, 45\\) \\)" ] +set message_strings \ + [list \ + " = 'array'" \ + " = 'array \\(1:5,1:5\\)'" \ + " = 'array \\(1:10:2,1:10:2\\)'" \ + " = 'array \\(1:10:3,1:10:2\\)'" \ + " = 'array \\(1:10:5,1:10:3\\)'" ] + set i 0 -foreach result $array_contents { +foreach result $array_contents msg $message_strings { incr i with_test_prefix "test $i" { gdb_continue_to_breakpoint "show" gdb_test "p array" $result + gdb_test "p message" "$msg" } } |