2017-12-10 22:00:49 +00:00
|
|
|
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
2017-12-04 19:24:00 +00:00
|
|
|
From: Fedora GDB patches <invalid@email.com>
|
|
|
|
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
|
Subject: gdb-vla-intel-fortran-vla-strings.patch
|
|
|
|
|
2017-12-08 04:31:26 +00:00
|
|
|
;;=push
|
|
|
|
|
2016-09-07 20:47:48 +00:00
|
|
|
git diff --stat -p gdb/master...gdb/users/bheckel/fortran-vla-strings
|
|
|
|
0ad7d8d1a3a36c6e04e3b6d37d8825f18d595723
|
|
|
|
|
|
|
|
gdb/NEWS | 2 +
|
|
|
|
gdb/c-valprint.c | 22 +++++
|
|
|
|
gdb/dwarf2read.c | 158 +++++++++++++++++++++++++-----
|
|
|
|
gdb/f-typeprint.c | 93 +++++++++---------
|
|
|
|
gdb/gdbtypes.c | 44 ++++++++-
|
|
|
|
gdb/testsuite/gdb.cp/vla-cxx.cc | 9 ++
|
|
|
|
gdb/testsuite/gdb.cp/vla-cxx.exp | 9 ++
|
|
|
|
gdb/testsuite/gdb.fortran/pointers.exp | 143 +++++++++++++++++++++++++++
|
|
|
|
gdb/testsuite/gdb.fortran/pointers.f90 | 109 +++++++++++++++++++++
|
|
|
|
gdb/testsuite/gdb.fortran/print_type.exp | 100 +++++++++++++++++++
|
|
|
|
gdb/testsuite/gdb.fortran/vla-ptype.exp | 12 +--
|
|
|
|
gdb/testsuite/gdb.fortran/vla-strings.exp | 103 +++++++++++++++++++
|
|
|
|
gdb/testsuite/gdb.fortran/vla-strings.f90 | 39 ++++++++
|
|
|
|
gdb/testsuite/gdb.fortran/vla-type.exp | 7 +-
|
|
|
|
gdb/testsuite/gdb.fortran/vla-value.exp | 12 ++-
|
|
|
|
gdb/testsuite/gdb.mi/mi-var-child-f.exp | 7 +-
|
|
|
|
gdb/testsuite/gdb.mi/mi-vla-fortran.exp | 27 ++---
|
|
|
|
gdb/typeprint.c | 19 ++++
|
|
|
|
gdb/valops.c | 16 ++-
|
|
|
|
gdb/valprint.c | 6 --
|
|
|
|
20 files changed, 827 insertions(+), 110 deletions(-)
|
|
|
|
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/NEWS b/gdb/NEWS
|
|
|
|
--- a/gdb/NEWS
|
|
|
|
+++ b/gdb/NEWS
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -985,6 +985,8 @@ SH-5/SH64 running OpenBSD SH-5/SH64 support in sh*-*-openbsd*
|
2018-01-31 22:47:02 +00:00
|
|
|
|
|
|
|
*** Changes in GDB 8.1
|
2016-09-07 20:47:48 +00:00
|
|
|
|
|
|
|
+* Fortran: Support pointers to dynamic types.
|
|
|
|
+
|
2018-01-10 19:21:10 +00:00
|
|
|
* GDB now supports dynamically creating arbitrary register groups specified
|
2018-01-31 22:47:02 +00:00
|
|
|
in XML target descriptions. This allows for finer grain grouping of
|
|
|
|
registers on systems with a large amount of registers.
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
|
|
|
|
--- a/gdb/c-valprint.c
|
|
|
|
+++ b/gdb/c-valprint.c
|
2021-02-24 21:25:14 +00:00
|
|
|
@@ -572,6 +572,28 @@ c_value_print (struct value *val, struct ui_file *stream,
|
2016-09-07 20:47:48 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* normal case */
|
2020-11-05 21:17:24 +00:00
|
|
|
+ if (type->code () == TYPE_CODE_PTR
|
2016-09-07 20:47:48 +00:00
|
|
|
+ && 1 == is_dynamic_type (type))
|
|
|
|
+ {
|
2021-02-24 21:25:14 +00:00
|
|
|
+ CORE_ADDR addr;
|
|
|
|
+ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type)))
|
|
|
|
+ addr = value_address (val);
|
|
|
|
+ else
|
|
|
|
+ addr = value_as_address (val);
|
2016-09-07 20:47:48 +00:00
|
|
|
+
|
|
|
|
+ /* We resolve the target-type only when the
|
|
|
|
+ pointer is associated. */
|
|
|
|
+ if ((addr != 0)
|
|
|
|
+ && (0 == type_not_associated (type)))
|
|
|
|
+ TYPE_TARGET_TYPE (type) =
|
|
|
|
+ resolve_dynamic_type (TYPE_TARGET_TYPE (type),
|
2020-11-05 21:17:24 +00:00
|
|
|
+ {}, addr);
|
2016-09-07 20:47:48 +00:00
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ /* Do nothing. References are already resolved from the beginning,
|
|
|
|
+ only pointers are resolved when we actual need the target. */
|
|
|
|
+ }
|
|
|
|
fprintf_filtered (stream, "(");
|
|
|
|
type_print (value_type (val), "", stream, -1);
|
|
|
|
fprintf_filtered (stream, ") ");
|
2020-11-05 21:17:24 +00:00
|
|
|
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
|
|
|
|
--- a/gdb/dwarf2/read.c
|
|
|
|
+++ b/gdb/dwarf2/read.c
|
|
|
|
@@ -1562,7 +1562,10 @@ static void read_signatured_type (signatured_type *sig_type,
|
2016-09-07 20:47:48 +00:00
|
|
|
|
|
|
|
static int attr_to_dynamic_prop (const struct attribute *attr,
|
|
|
|
struct die_info *die, struct dwarf2_cu *cu,
|
2019-08-02 23:25:51 +00:00
|
|
|
- struct dynamic_prop *prop, struct type *type);
|
|
|
|
+ struct dynamic_prop *prop,
|
|
|
|
+ struct type *default_type,
|
|
|
|
+ const gdb_byte *additional_data,
|
2016-09-07 20:47:48 +00:00
|
|
|
+ int additional_data_size);
|
|
|
|
|
|
|
|
/* memory allocation interface */
|
|
|
|
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -13631,7 +13634,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
|
2016-09-07 20:47:48 +00:00
|
|
|
newobj->static_link
|
|
|
|
= XOBNEW (&objfile->objfile_obstack, struct dynamic_prop);
|
2019-08-02 23:25:51 +00:00
|
|
|
attr_to_dynamic_prop (attr, die, cu, newobj->static_link,
|
2020-11-05 21:17:24 +00:00
|
|
|
- cu->addr_type ());
|
|
|
|
+ cu->addr_type (), NULL, 0);
|
2016-09-07 20:47:48 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 17:16:00 +00:00
|
|
|
cu->list_in_scope = cu->get_builder ()->get_local_symbols ();
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -16073,7 +16076,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct dynamic_prop prop;
|
|
|
|
- if (attr_to_dynamic_prop (attr, die, cu, &prop, cu->addr_type ()))
|
|
|
|
+ if (attr_to_dynamic_prop (attr, die, cu, &prop, cu->addr_type (), NULL, 0))
|
|
|
|
type->add_dyn_prop (DYN_PROP_BYTE_SIZE, prop);
|
|
|
|
TYPE_LENGTH (type) = 0;
|
|
|
|
}
|
|
|
|
@@ -16764,7 +16767,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
|
2018-01-10 19:21:10 +00:00
|
|
|
byte_stride_prop
|
|
|
|
= (struct dynamic_prop *) alloca (sizeof (struct dynamic_prop));
|
2019-08-02 23:25:51 +00:00
|
|
|
stride_ok = attr_to_dynamic_prop (attr, die, cu, byte_stride_prop,
|
|
|
|
- prop_type);
|
|
|
|
+ prop_type, NULL, 0);
|
2018-01-10 19:21:10 +00:00
|
|
|
if (!stride_ok)
|
|
|
|
{
|
2018-06-04 20:26:33 +00:00
|
|
|
complaint (_("unable to read array DW_AT_byte_stride "
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -17522,7 +17525,7 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
|
2016-09-07 20:47:48 +00:00
|
|
|
struct attribute *attr;
|
2020-02-04 20:06:34 +00:00
|
|
|
struct dynamic_prop prop;
|
|
|
|
bool length_is_constant = true;
|
|
|
|
- LONGEST length;
|
|
|
|
+ ULONGEST length = UINT_MAX;
|
|
|
|
|
|
|
|
/* There are a couple of places where bit sizes might be made use of
|
|
|
|
when parsing a DW_TAG_string_type, however, no producer that we know
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -17543,6 +17546,10 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
|
2020-02-04 20:06:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-07 20:47:48 +00:00
|
|
|
+ index_type = objfile_type (objfile)->builtin_int;
|
|
|
|
+ range_type = create_static_range_type (NULL, index_type, 1, length);
|
2020-02-04 20:06:34 +00:00
|
|
|
+
|
2016-09-07 20:47:48 +00:00
|
|
|
+ /* If DW_AT_string_length is defined, the length is stored in memory. */
|
|
|
|
attr = dwarf2_attr (die, DW_AT_string_length, cu);
|
2020-11-05 21:17:24 +00:00
|
|
|
if (attr != nullptr && !attr->form_is_constant ())
|
2020-02-04 20:06:34 +00:00
|
|
|
{
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -17569,13 +17576,68 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
|
2020-02-04 20:06:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert the attribute into a dynamic property. */
|
|
|
|
- if (!attr_to_dynamic_prop (attr, die, cu, &prop, prop_type))
|
|
|
|
+ if (!attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0))
|
|
|
|
length = 1;
|
|
|
|
else
|
|
|
|
length_is_constant = false;
|
|
|
|
}
|
|
|
|
else if (attr != nullptr)
|
2016-09-07 20:47:48 +00:00
|
|
|
{
|
2020-11-05 21:17:24 +00:00
|
|
|
+ if (attr->form_is_block ())
|
2016-09-07 20:47:48 +00:00
|
|
|
+ {
|
|
|
|
+ struct attribute *byte_size, *bit_size;
|
|
|
|
+ struct dynamic_prop high;
|
|
|
|
+
|
|
|
|
+ byte_size = dwarf2_attr (die, DW_AT_byte_size, cu);
|
|
|
|
+ bit_size = dwarf2_attr (die, DW_AT_bit_size, cu);
|
|
|
|
+
|
|
|
|
+ /* DW_AT_byte_size should never occur in combination with
|
|
|
|
+ DW_AT_bit_size. */
|
|
|
|
+ if (byte_size != NULL && bit_size != NULL)
|
2018-06-04 20:26:33 +00:00
|
|
|
+ complaint (_("DW_AT_byte_size AND "
|
2016-09-07 20:47:48 +00:00
|
|
|
+ "DW_AT_bit_size found together at the same time."));
|
|
|
|
+
|
|
|
|
+ /* If DW_AT_string_length AND DW_AT_byte_size exist together,
|
|
|
|
+ DW_AT_byte_size describes the number of bytes that should be read
|
|
|
|
+ from the length memory location. */
|
|
|
|
+ if (byte_size != NULL)
|
|
|
|
+ {
|
|
|
|
+ /* Build new dwarf2_locexpr_baton structure with additions to the
|
|
|
|
+ data attribute, to reflect DWARF specialities to get address
|
|
|
|
+ sizes. */
|
|
|
|
+ const gdb_byte append_ops[] =
|
|
|
|
+ {
|
|
|
|
+ /* DW_OP_deref_size: size of an address on the target machine
|
|
|
|
+ (bytes), where the size will be specified by the next
|
|
|
|
+ operand. */
|
|
|
|
+ DW_OP_deref_size,
|
|
|
|
+ /* Operand for DW_OP_deref_size. */
|
2018-09-17 22:38:14 +00:00
|
|
|
+ (gdb_byte) DW_UNSND(byte_size) };
|
2016-09-07 20:47:48 +00:00
|
|
|
+
|
2019-08-02 23:25:51 +00:00
|
|
|
+ if (!attr_to_dynamic_prop (attr, die, cu, &high, index_type,
|
|
|
|
+ append_ops, ARRAY_SIZE(append_ops)))
|
2018-06-04 20:26:33 +00:00
|
|
|
+ complaint (_("Could not parse DW_AT_byte_size"));
|
2016-09-07 20:47:48 +00:00
|
|
|
+ }
|
|
|
|
+ else if (bit_size != NULL)
|
2018-06-04 20:26:33 +00:00
|
|
|
+ complaint (_("DW_AT_string_length AND "
|
2016-09-07 20:47:48 +00:00
|
|
|
+ "DW_AT_bit_size found but not supported yet."));
|
|
|
|
+ /* If DW_AT_string_length WITHOUT DW_AT_byte_size exist, the default
|
|
|
|
+ is the address size of the target machine. */
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ const gdb_byte append_ops[] =
|
|
|
|
+ { DW_OP_deref };
|
|
|
|
+
|
2019-08-02 23:25:51 +00:00
|
|
|
+ if (!attr_to_dynamic_prop (attr, die, cu, &high, index_type,
|
|
|
|
+ append_ops, ARRAY_SIZE(append_ops)))
|
2018-06-04 20:26:33 +00:00
|
|
|
+ complaint (_("Could not parse DW_AT_string_length"));
|
2016-09-07 20:47:48 +00:00
|
|
|
+ }
|
|
|
|
+
|
2020-11-05 21:17:24 +00:00
|
|
|
+ range_type->bounds ()->high = high;
|
2016-09-07 20:47:48 +00:00
|
|
|
+ }
|
|
|
|
+ else
|
2020-11-05 21:17:24 +00:00
|
|
|
+ range_type->bounds ()->high.set_const_val (DW_UNSND(attr));
|
2020-02-04 20:06:34 +00:00
|
|
|
+
|
|
|
|
/* This DW_AT_string_length just contains the length with no
|
|
|
|
indirection. There's no need to create a dynamic property in this
|
|
|
|
case. Pass 0 for the default value as we know it will not be
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -17589,6 +17651,14 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
|
2016-09-07 20:47:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
+ /* Check for the DW_AT_byte_size attribute, which represents the length
|
|
|
|
+ in this case. */
|
2020-02-04 20:06:34 +00:00
|
|
|
+ attr = dwarf2_attr (die, DW_AT_byte_size, cu);
|
|
|
|
+ if (attr)
|
2020-11-05 21:17:24 +00:00
|
|
|
+ range_type->bounds ()->high.set_const_val (DW_UNSND(attr));
|
2020-02-04 20:06:34 +00:00
|
|
|
+ else
|
2020-11-05 21:17:24 +00:00
|
|
|
+ range_type->bounds ()->high.set_const_val (1);
|
2020-02-04 20:06:34 +00:00
|
|
|
+
|
|
|
|
/* Use 1 as a fallback length if we have nothing else. */
|
|
|
|
length = 1;
|
2016-09-07 20:47:48 +00:00
|
|
|
}
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -17603,6 +17673,7 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
|
|
|
|
low_bound.set_const_val (1);
|
2020-02-04 20:06:34 +00:00
|
|
|
range_type = create_range_type (NULL, index_type, &low_bound, &prop, 0);
|
|
|
|
}
|
|
|
|
+
|
2016-09-07 20:47:48 +00:00
|
|
|
char_type = language_string_char_type (cu->language_defn, gdbarch);
|
|
|
|
type = create_string_type (NULL, char_type, range_type);
|
|
|
|
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -18078,7 +18149,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
|
2016-09-07 20:47:48 +00:00
|
|
|
static int
|
|
|
|
attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
|
2019-08-02 23:25:51 +00:00
|
|
|
struct dwarf2_cu *cu, struct dynamic_prop *prop,
|
|
|
|
- struct type *default_type)
|
|
|
|
+ struct type *default_type,
|
2016-09-07 20:47:48 +00:00
|
|
|
+ const gdb_byte *additional_data, int additional_data_size)
|
|
|
|
{
|
|
|
|
struct dwarf2_property_baton *baton;
|
2020-11-05 21:17:24 +00:00
|
|
|
dwarf2_per_objfile *per_objfile = cu->per_objfile;
|
|
|
|
@@ -18108,6 +18180,26 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
|
2020-02-04 20:06:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-11-05 21:17:24 +00:00
|
|
|
|
2016-09-07 20:47:48 +00:00
|
|
|
+ if (additional_data != NULL && additional_data_size > 0)
|
|
|
|
+ {
|
|
|
|
+ gdb_byte *data;
|
|
|
|
+
|
|
|
|
+ data = (gdb_byte *) obstack_alloc(
|
2020-11-05 21:17:24 +00:00
|
|
|
+ &cu->per_objfile->objfile->objfile_obstack,
|
2016-09-07 20:47:48 +00:00
|
|
|
+ DW_BLOCK (attr)->size + additional_data_size);
|
|
|
|
+ memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
|
|
|
|
+ memcpy (data + DW_BLOCK (attr)->size, additional_data,
|
|
|
|
+ additional_data_size);
|
|
|
|
+
|
|
|
|
+ baton->locexpr.data = data;
|
|
|
|
+ baton->locexpr.size = DW_BLOCK (attr)->size + additional_data_size;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ baton->locexpr.data = DW_BLOCK (attr)->data;
|
|
|
|
+ baton->locexpr.size = DW_BLOCK (attr)->size;
|
|
|
|
+ }
|
|
|
|
+
|
2020-11-05 21:17:24 +00:00
|
|
|
prop->set_locexpr (baton);
|
|
|
|
gdb_assert (prop->baton () != NULL);
|
2016-09-07 20:47:48 +00:00
|
|
|
}
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -18142,11 +18234,31 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
|
2019-08-02 23:25:51 +00:00
|
|
|
baton->property_type = die_type (target_die, target_cu);
|
2016-09-07 20:47:48 +00:00
|
|
|
baton->locexpr.per_cu = cu->per_cu;
|
2020-11-05 21:17:24 +00:00
|
|
|
baton->locexpr.per_objfile = per_objfile;
|
2016-09-07 20:47:48 +00:00
|
|
|
- baton->locexpr.size = DW_BLOCK (target_attr)->size;
|
|
|
|
- baton->locexpr.data = DW_BLOCK (target_attr)->data;
|
2019-08-02 23:25:51 +00:00
|
|
|
baton->locexpr.is_reference = true;
|
2016-09-07 20:47:48 +00:00
|
|
|
+
|
|
|
|
+ if (additional_data != NULL && additional_data_size > 0)
|
|
|
|
+ {
|
|
|
|
+ gdb_byte *data;
|
|
|
|
+
|
2020-11-05 21:17:24 +00:00
|
|
|
+ data = (gdb_byte *) obstack_alloc (&cu->per_objfile->objfile->objfile_obstack,
|
2016-09-07 20:47:48 +00:00
|
|
|
+ DW_BLOCK (target_attr)->size + additional_data_size);
|
|
|
|
+ memcpy (data, DW_BLOCK (target_attr)->data,
|
|
|
|
+ DW_BLOCK (target_attr)->size);
|
|
|
|
+ memcpy (data + DW_BLOCK (target_attr)->size,
|
|
|
|
+ additional_data, additional_data_size);
|
|
|
|
+
|
|
|
|
+ baton->locexpr.data = data;
|
|
|
|
+ baton->locexpr.size = (DW_BLOCK (target_attr)->size
|
|
|
|
+ + additional_data_size);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ baton->locexpr.data = DW_BLOCK (target_attr)->data;
|
|
|
|
+ baton->locexpr.size = DW_BLOCK (target_attr)->size;
|
|
|
|
+ }
|
|
|
|
+
|
2020-11-05 21:17:24 +00:00
|
|
|
prop->set_locexpr (baton);
|
|
|
|
- gdb_assert (prop->baton () != NULL);
|
|
|
|
+ gdb_assert (prop->baton() != NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
@@ -18308,8 +18420,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
|
2020-02-04 20:06:34 +00:00
|
|
|
}
|
2016-09-07 20:47:48 +00:00
|
|
|
|
|
|
|
attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
|
2020-02-04 20:06:34 +00:00
|
|
|
- if (attr != nullptr)
|
2019-08-02 23:25:51 +00:00
|
|
|
- attr_to_dynamic_prop (attr, die, cu, &low, base_type);
|
2020-02-04 20:06:34 +00:00
|
|
|
+ if (attr)
|
2019-08-02 23:25:51 +00:00
|
|
|
+ attr_to_dynamic_prop (attr, die, cu, &low, base_type, NULL, 0);
|
2016-09-07 20:47:48 +00:00
|
|
|
else if (!low_default_is_valid)
|
2018-06-04 20:26:33 +00:00
|
|
|
complaint (_("Missing DW_AT_lower_bound "
|
2018-05-31 18:47:56 +00:00
|
|
|
"- DIE at %s [in module %s]"),
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -18318,10 +18430,10 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
|
2016-09-07 20:47:48 +00:00
|
|
|
|
2018-09-17 22:38:14 +00:00
|
|
|
struct attribute *attr_ub, *attr_count;
|
|
|
|
attr = attr_ub = dwarf2_attr (die, DW_AT_upper_bound, cu);
|
2019-08-02 23:25:51 +00:00
|
|
|
- if (!attr_to_dynamic_prop (attr, die, cu, &high, base_type))
|
|
|
|
+ if (!attr_to_dynamic_prop (attr, die, cu, &high, base_type, NULL, 0))
|
2016-09-07 20:47:48 +00:00
|
|
|
{
|
2018-09-17 22:38:14 +00:00
|
|
|
attr = attr_count = dwarf2_attr (die, DW_AT_count, cu);
|
2019-08-02 23:25:51 +00:00
|
|
|
- if (attr_to_dynamic_prop (attr, die, cu, &high, base_type))
|
|
|
|
+ if (attr_to_dynamic_prop (attr, die, cu, &high, base_type, NULL, 0))
|
2016-09-07 20:47:48 +00:00
|
|
|
{
|
|
|
|
/* If bounds are constant do the final calculation here. */
|
2020-11-05 21:17:24 +00:00
|
|
|
if (low.kind () == PROP_CONST && high.kind () == PROP_CONST)
|
|
|
|
@@ -18372,7 +18484,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
|
|
|
|
{
|
|
|
|
struct type *prop_type = cu->addr_sized_int_type (false);
|
2020-02-04 20:06:34 +00:00
|
|
|
attr_to_dynamic_prop (attr_byte_stride, die, cu, &byte_stride_prop,
|
|
|
|
- prop_type);
|
|
|
|
+ prop_type, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct dynamic_prop bit_stride_prop;
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -18392,7 +18504,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
|
|
|
|
{
|
|
|
|
struct type *prop_type = cu->addr_sized_int_type (false);
|
2020-02-04 20:06:34 +00:00
|
|
|
attr_to_dynamic_prop (attr_bit_stride, die, cu, &bit_stride_prop,
|
|
|
|
- prop_type);
|
|
|
|
+ prop_type, NULL, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -24424,7 +24536,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
|
|
|
|
if (attr != NULL)
|
2016-09-07 20:47:48 +00:00
|
|
|
{
|
2020-11-05 21:17:24 +00:00
|
|
|
struct type *prop_type = cu->addr_sized_int_type (false);
|
2019-08-02 23:25:51 +00:00
|
|
|
- if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type))
|
|
|
|
+ if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0))
|
2020-11-05 21:17:24 +00:00
|
|
|
type->add_dyn_prop (DYN_PROP_ALLOCATED, prop);
|
2016-09-07 20:47:48 +00:00
|
|
|
}
|
2020-11-05 21:17:24 +00:00
|
|
|
|
|
|
|
@@ -24433,13 +24545,13 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
|
|
|
|
if (attr != NULL)
|
2016-09-07 20:47:48 +00:00
|
|
|
{
|
2020-11-05 21:17:24 +00:00
|
|
|
struct type *prop_type = cu->addr_sized_int_type (false);
|
2019-08-02 23:25:51 +00:00
|
|
|
- if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type))
|
|
|
|
+ if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0))
|
2020-11-05 21:17:24 +00:00
|
|
|
type->add_dyn_prop (DYN_PROP_ASSOCIATED, prop);
|
2016-09-07 20:47:48 +00:00
|
|
|
}
|
2020-11-05 21:17:24 +00:00
|
|
|
|
2016-09-07 20:47:48 +00:00
|
|
|
/* Read DW_AT_data_location and set in type. */
|
|
|
|
attr = dwarf2_attr (die, DW_AT_data_location, cu);
|
2020-11-05 21:17:24 +00:00
|
|
|
- if (attr_to_dynamic_prop (attr, die, cu, &prop, cu->addr_type ()))
|
|
|
|
+ if (attr_to_dynamic_prop (attr, die, cu, &prop, cu->addr_type (), NULL, 0))
|
|
|
|
type->add_dyn_prop (DYN_PROP_DATA_LOCATION, prop);
|
2016-09-07 20:47:48 +00:00
|
|
|
|
2020-11-05 21:17:24 +00:00
|
|
|
if (per_objfile->die_type_hash == NULL)
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
|
|
|
|
--- a/gdb/f-typeprint.c
|
|
|
|
+++ b/gdb/f-typeprint.c
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -217,8 +217,9 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
|
2019-06-25 19:49:31 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
LONGEST lower_bound = f77_get_lowerbound (type);
|
|
|
|
+
|
|
|
|
if (lower_bound != 1) /* Not the default. */
|
2019-04-12 20:35:20 +00:00
|
|
|
- fprintf_filtered (stream, "%s:", plongest (lower_bound));
|
2019-06-25 19:49:31 +00:00
|
|
|
+ fprintf_filtered (stream, "%s:", plongest (lower_bound));
|
2019-04-12 20:35:20 +00:00
|
|
|
|
2019-06-25 19:49:31 +00:00
|
|
|
/* Make sure that, if we have an assumed size array, we
|
|
|
|
print out a warning and print the upperbound as '*'. */
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -229,7 +230,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
|
2019-06-25 19:49:31 +00:00
|
|
|
{
|
|
|
|
LONGEST upper_bound = f77_get_upperbound (type);
|
2019-04-12 20:35:20 +00:00
|
|
|
|
|
|
|
- fputs_filtered (plongest (upper_bound), stream);
|
2019-06-25 19:49:31 +00:00
|
|
|
+ fprintf_filtered (stream, "%s", plongest (upper_bound));
|
|
|
|
}
|
|
|
|
}
|
2019-04-12 20:35:20 +00:00
|
|
|
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -249,7 +250,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
|
2016-09-07 20:47:48 +00:00
|
|
|
case TYPE_CODE_REF:
|
|
|
|
f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0,
|
2019-06-25 19:49:31 +00:00
|
|
|
arrayprint_recurse_level, false);
|
2019-05-02 03:08:41 +00:00
|
|
|
- fprintf_filtered (stream, " )");
|
|
|
|
+ fprintf_filtered (stream, ")");
|
2016-09-07 20:47:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPE_CODE_FUNC:
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
|
|
|
|
--- a/gdb/gdbtypes.c
|
|
|
|
+++ b/gdb/gdbtypes.c
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -1977,7 +1977,8 @@ is_dynamic_type_internal (struct type *type, int top_level)
|
2016-09-07 20:47:48 +00:00
|
|
|
type = check_typedef (type);
|
|
|
|
|
|
|
|
/* We only want to recognize references at the outermost level. */
|
2020-11-05 21:17:24 +00:00
|
|
|
- if (top_level && type->code () == TYPE_CODE_REF)
|
2016-09-07 20:47:48 +00:00
|
|
|
+ if (top_level &&
|
2020-11-05 21:17:24 +00:00
|
|
|
+ (type->code () == TYPE_CODE_REF || type-> code() == TYPE_CODE_PTR))
|
2016-09-07 20:47:48 +00:00
|
|
|
type = check_typedef (TYPE_TARGET_TYPE (type));
|
|
|
|
|
|
|
|
/* Types that have a dynamic TYPE_DATA_LOCATION are considered
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -2017,10 +2018,10 @@ is_dynamic_type_internal (struct type *type, int top_level)
|
2020-02-04 20:06:34 +00:00
|
|
|
|| is_dynamic_type_internal (TYPE_TARGET_TYPE (type), 0));
|
2016-09-07 20:47:48 +00:00
|
|
|
}
|
|
|
|
|
2020-02-04 20:06:34 +00:00
|
|
|
- case TYPE_CODE_STRING:
|
|
|
|
/* Strings are very much like an array of characters, and can be
|
|
|
|
treated as one here. */
|
2016-09-07 20:47:48 +00:00
|
|
|
case TYPE_CODE_ARRAY:
|
|
|
|
+ case TYPE_CODE_STRING:
|
|
|
|
{
|
2020-11-05 21:17:24 +00:00
|
|
|
gdb_assert (type->num_fields () == 1);
|
2016-09-07 20:47:48 +00:00
|
|
|
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -2183,11 +2184,15 @@ resolve_dynamic_array_or_string (struct type *type,
|
2016-09-07 20:47:48 +00:00
|
|
|
|
|
|
|
ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
|
|
|
|
|
2020-11-05 21:17:24 +00:00
|
|
|
- if (ary_dim != NULL && ary_dim->code () == TYPE_CODE_ARRAY)
|
|
|
|
+ if (ary_dim != NULL && (ary_dim->code () == TYPE_CODE_ARRAY
|
|
|
|
+ || ary_dim->code () == TYPE_CODE_STRING))
|
2020-02-04 20:06:34 +00:00
|
|
|
elt_type = resolve_dynamic_array_or_string (ary_dim, addr_stack);
|
2016-09-07 20:47:48 +00:00
|
|
|
else
|
|
|
|
elt_type = TYPE_TARGET_TYPE (type);
|
|
|
|
|
2020-11-05 21:17:24 +00:00
|
|
|
+ if (type->code () == TYPE_CODE_STRING)
|
2016-09-07 20:47:48 +00:00
|
|
|
+ return create_string_type (type, elt_type, range_type);
|
2018-01-10 19:21:10 +00:00
|
|
|
+
|
2020-11-05 21:17:24 +00:00
|
|
|
prop = type->dyn_prop (DYN_PROP_BYTE_STRIDE);
|
2018-01-10 19:21:10 +00:00
|
|
|
if (prop != NULL)
|
|
|
|
{
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -2533,6 +2538,25 @@ resolve_dynamic_struct (struct type *type,
|
2016-09-07 20:47:48 +00:00
|
|
|
return resolved_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
+/* Worker for pointer types. */
|
|
|
|
+
|
|
|
|
+static struct type *
|
|
|
|
+resolve_dynamic_pointer (struct type *type,
|
|
|
|
+ struct property_addr_info *addr_stack)
|
|
|
|
+{
|
|
|
|
+ struct dynamic_prop *prop;
|
|
|
|
+ CORE_ADDR value;
|
|
|
|
+
|
|
|
|
+ type = copy_type (type);
|
|
|
|
+
|
|
|
|
+ /* Resolve associated property. */
|
|
|
|
+ prop = TYPE_ASSOCIATED_PROP (type);
|
|
|
|
+ if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
|
2020-11-05 21:17:24 +00:00
|
|
|
+ prop->set_const_val (value);
|
2016-09-07 20:47:48 +00:00
|
|
|
+
|
|
|
|
+ return type;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/* Worker for resolved_dynamic_type. */
|
|
|
|
|
|
|
|
static struct type *
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -2594,6 +2618,9 @@ resolve_dynamic_type_internal (struct type *type,
|
2020-02-04 20:06:34 +00:00
|
|
|
case TYPE_CODE_ARRAY:
|
|
|
|
resolved_type = resolve_dynamic_array_or_string (type, addr_stack);
|
|
|
|
break;
|
2016-09-07 20:47:48 +00:00
|
|
|
+ case TYPE_CODE_PTR:
|
|
|
|
+ resolved_type = resolve_dynamic_pointer (type, addr_stack);
|
|
|
|
+ break;
|
|
|
|
|
2020-02-04 20:06:34 +00:00
|
|
|
case TYPE_CODE_RANGE:
|
|
|
|
resolved_type = resolve_dynamic_range (type, addr_stack);
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/testsuite/gdb.cp/vla-cxx.cc b/gdb/testsuite/gdb.cp/vla-cxx.cc
|
|
|
|
--- a/gdb/testsuite/gdb.cp/vla-cxx.cc
|
|
|
|
+++ b/gdb/testsuite/gdb.cp/vla-cxx.cc
|
2016-09-07 20:47:48 +00:00
|
|
|
@@ -15,6 +15,10 @@
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
+extern "C" {
|
|
|
|
+#include <stddef.h>
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
struct container;
|
|
|
|
|
|
|
|
struct element
|
2017-12-08 04:31:26 +00:00
|
|
|
@@ -40,11 +44,16 @@ int main(int argc, char **argv)
|
2016-09-07 20:47:48 +00:00
|
|
|
typedef typeof (vla) &vlareftypedef;
|
|
|
|
vlareftypedef vlaref2 (vla);
|
|
|
|
container c;
|
|
|
|
+ typeof (vla) *ptr = NULL;
|
|
|
|
+
|
|
|
|
+ // Before pointer assignment
|
|
|
|
+ ptr = &vla;
|
|
|
|
|
|
|
|
for (int i = 0; i < z; ++i)
|
|
|
|
vla[i] = 5 + 2 * i;
|
|
|
|
|
|
|
|
// vlas_filled
|
|
|
|
vla[0] = 2 * vla[0];
|
|
|
|
+
|
|
|
|
return vla[2];
|
|
|
|
}
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/testsuite/gdb.cp/vla-cxx.exp b/gdb/testsuite/gdb.cp/vla-cxx.exp
|
|
|
|
--- a/gdb/testsuite/gdb.cp/vla-cxx.exp
|
|
|
|
+++ b/gdb/testsuite/gdb.cp/vla-cxx.exp
|
|
|
|
@@ -23,6 +23,12 @@ if ![runto_main] {
|
2016-09-07 20:47:48 +00:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
|
|
|
|
+gdb_continue_to_breakpoint "Before pointer assignment"
|
|
|
|
+gdb_test "ptype ptr" "int \\(\\*\\)\\\[variable length\\\]" "ptype ptr, Before pointer assignment"
|
|
|
|
+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[variable length\\\]\\) 0x0" "print ptr, Before pointer assignment"
|
|
|
|
+gdb_test "print *ptr" "Cannot access memory at address 0x0" "print *ptr, Before pointer assignment"
|
|
|
|
+
|
|
|
|
gdb_breakpoint [gdb_get_line_number "vlas_filled"]
|
|
|
|
gdb_continue_to_breakpoint "vlas_filled"
|
|
|
|
|
2017-12-08 04:31:26 +00:00
|
|
|
@@ -33,3 +39,6 @@ gdb_test "print vlaref" " = \\(int \\(&\\)\\\[3\\\]\\) @$hex: \\{5, 7, 9\\}"
|
2016-09-07 20:47:48 +00:00
|
|
|
# bug being tested, it's better not to depend on the exact spelling.
|
|
|
|
gdb_test "print vlaref2" " = \\(.*\\) @$hex: \\{5, 7, 9\\}"
|
|
|
|
gdb_test "print c" " = \\{e = \\{c = @$hex\\}\\}"
|
|
|
|
+gdb_test "ptype ptr" "int \\(\\*\\)\\\[3\\\]"
|
|
|
|
+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[3\\\]\\) $hex"
|
|
|
|
+gdb_test "print *ptr" " = \\{5, 7, 9\\}"
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/testsuite/gdb.fortran/pointers.exp b/gdb/testsuite/gdb.fortran/pointers.exp
|
|
|
|
new file mode 100644
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/gdb/testsuite/gdb.fortran/pointers.exp
|
2016-09-07 20:47:48 +00:00
|
|
|
@@ -0,0 +1,143 @@
|
|
|
|
+# Copyright 2016 Free Software Foundation, Inc.
|
|
|
|
+
|
|
|
|
+# This program is free software; you can redistribute it and/or modify
|
|
|
|
+# it under the terms of the GNU General Public License as published by
|
|
|
|
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
+# (at your option) any later version.
|
|
|
|
+#
|
|
|
|
+# This program is distributed in the hope that it will be useful,
|
|
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+# GNU General Public License for more details.
|
|
|
|
+#
|
|
|
|
+# You should have received a copy of the GNU General Public License
|
|
|
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
+
|
|
|
|
+standard_testfile "pointers.f90"
|
|
|
|
+load_lib fortran.exp
|
|
|
|
+
|
|
|
|
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
|
|
|
|
+ {debug f90 quiet}] } {
|
|
|
|
+ return -1
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+if ![runto_main] {
|
|
|
|
+ untested "could not run to main"
|
|
|
|
+ return -1
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+# Depending on the compiler being used, the type names can be printed differently.
|
|
|
|
+set logical [fortran_logical4]
|
|
|
|
+set real [fortran_real4]
|
|
|
|
+set int [fortran_int4]
|
|
|
|
+set complex [fortran_complex4]
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
|
|
|
|
+gdb_continue_to_breakpoint "Before pointer assignment"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print logp" "= \\(PTR TO -> \\( $logical\\)\\) 0x0" "print logp, not associated"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *logp" "Cannot access memory at address 0x0" "print *logp, not associated"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print comp" "= \\(PTR TO -> \\( $complex\\)\\) 0x0" "print comp, not associated"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *comp" "Cannot access memory at address 0x0" "print *comp, not associated"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1\\)\\) 0x0" "print charp, not associated"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *charp" "Cannot access memory at address 0x0" "print *charp, not associated"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3\\)\\) 0x0" "print charap, not associated"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *charap" "Cannot access memory at address 0x0" "print *charap, not associated"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print intp" "= \\(PTR TO -> \\( $int\\)\\) 0x0" "print intp, not associated"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *intp" "Cannot access memory at address 0x0" "print *intp, not associated"
|
|
|
|
+set test "print intap, not associated"
|
|
|
|
+gdb_test_multiple "print intap" $test {
|
|
|
|
+ -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not associated>\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+ -re " = <not associated>\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+}
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print realp" "= \\(PTR TO -> \\( $real\\)\\) 0x0" "print realp, not associated"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int\\)\\) 0x0"
|
2016-09-07 20:47:48 +00:00
|
|
|
+set test "print cyclicp1, not associated"
|
|
|
|
+gdb_test_multiple "print cyclicp1" $test {
|
|
|
|
+ -re "= \\( i = -?\\d+, p = 0x0 \\)\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+ -re "= \\( i = -?\\d+, p = <not associated> \\)\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+set test "print cyclicp1%p, not associated"
|
|
|
|
+gdb_test_multiple "print cyclicp1%p" $test {
|
2019-05-03 00:08:08 +00:00
|
|
|
+ -re "= \\(PTR TO -> \\( Type typewithpointer\\)\\) 0x0\r\n$gdb_prompt $" {
|
2016-09-07 20:47:48 +00:00
|
|
|
+ pass $test
|
|
|
|
+ }
|
2019-05-03 00:08:08 +00:00
|
|
|
+ -re "= \\(PTR TO -> \\( Type typewithpointer\\)\\) <not associated>\r\n$gdb_prompt $" {
|
2016-09-07 20:47:48 +00:00
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+gdb_breakpoint [gdb_get_line_number "Before value assignment"]
|
|
|
|
+gdb_continue_to_breakpoint "Before value assignment"
|
|
|
|
+gdb_test "print *(twop)%ivla2" "= <not allocated>"
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+gdb_breakpoint [gdb_get_line_number "After value assignment"]
|
|
|
|
+gdb_continue_to_breakpoint "After value assignment"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print logp" "= \\(PTR TO -> \\( $logical\\)\\) $hex\( <.*>\)?"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *logp" "= \\.TRUE\\."
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print comp" "= \\(PTR TO -> \\( $complex\\)\\) $hex\( <.*>\)?"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *comp" "= \\(1,2\\)"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1\\)\\) $hex\( <.*>\)?"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *charp" "= 'a'"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3\\)\\) $hex\( <.*>\)?"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *charap" "= 'abc'"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print intp" "= \\(PTR TO -> \\( $int\\)\\) $hex\( <.*>\)?"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *intp" "= 10"
|
|
|
|
+set test_name "print intap, associated"
|
|
|
|
+gdb_test_multiple "print intap" $test_name {
|
|
|
|
+ -re "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test_name
|
|
|
|
+ }
|
|
|
|
+ -re "= \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
|
|
|
|
+ gdb_test "print *intap" "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)"
|
|
|
|
+ pass $test_name
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+set test_name "print intvlap, associated"
|
|
|
|
+gdb_test_multiple "print intvlap" $test_name {
|
|
|
|
+ -re "= \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test_name
|
|
|
|
+ }
|
|
|
|
+ -re "= \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
|
|
|
|
+ gdb_test "print *intvlap" "= \\(2, 2, 2, 4(, 2){6}\\)"
|
|
|
|
+ pass $test_name
|
|
|
|
+ }
|
|
|
|
+}
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print realp" "= \\(PTR TO -> \\( $real\\)\\) $hex\( <.*>\)?"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *realp" "= 3\\.14000\\d+"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print arrayOfPtr(2)%p" "= \\(PTR TO -> \\( Type two\\)\\) $hex\( <.*>\)?"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *(arrayOfPtr(2)%p)" "= \\( ivla1 = \\(11, 12, 13\\), ivla2 = \\(\\( 211, 221\\) \\( 212, 222\\) \\) \\)"
|
|
|
|
+set test_name "print arrayOfPtr(3)%p"
|
|
|
|
+gdb_test_multiple $test_name $test_name {
|
2019-05-03 00:08:08 +00:00
|
|
|
+ -re "= \\(PTR TO -> \\( Type two\\)\\) <not associated>\r\n$gdb_prompt $" {
|
2016-09-07 20:47:48 +00:00
|
|
|
+ pass $test_name
|
|
|
|
+ }
|
2019-05-03 00:08:08 +00:00
|
|
|
+ -re "= \\(PTR TO -> \\( Type two\\)\\) 0x0\r\n$gdb_prompt $" {
|
2016-09-07 20:47:48 +00:00
|
|
|
+ pass $test_name
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+set test_name "print *(arrayOfPtr(3)%p), associated"
|
|
|
|
+gdb_test_multiple "print *(arrayOfPtr(3)%p)" $test_name {
|
|
|
|
+ -re "Cannot access memory at address 0x0\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test_name
|
|
|
|
+ }
|
|
|
|
+ -re "Attempt to take contents of a not associated pointer.\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test_name
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+gdb_test "print cyclicp1" "= \\( i = 1, p = $hex\( <.*>\)? \\)"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print cyclicp1%p" "= \\(PTR TO -> \\( Type typewithpointer\\)\\) $hex\( <.*>\)?"
|
2016-09-07 20:47:48 +00:00
|
|
|
+gdb_test "print *((integer*) &inta + 2)" "= 3" "print temporary pointer, array"
|
|
|
|
+gdb_test "print *((integer*) &intvla + 3)" "= 4" "print temporary pointer, allocated vla"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "print \$pc" "= \\(PTR TO -> \\( void \\(\\) \\(\\)\\)\\) $hex <pointers\\+\\d+>" "Print program counter"
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/testsuite/gdb.fortran/pointers.f90 b/gdb/testsuite/gdb.fortran/pointers.f90
|
2019-06-25 19:49:31 +00:00
|
|
|
--- a/gdb/testsuite/gdb.fortran/pointers.f90
|
2017-12-08 04:31:26 +00:00
|
|
|
+++ b/gdb/testsuite/gdb.fortran/pointers.f90
|
2019-06-25 19:49:31 +00:00
|
|
|
@@ -20,21 +20,34 @@ program pointers
|
|
|
|
integer, allocatable :: ivla2 (:, :)
|
|
|
|
end type two
|
|
|
|
|
2016-09-07 20:47:48 +00:00
|
|
|
+ type :: typeWithPointer
|
|
|
|
+ integer i
|
|
|
|
+ type(typeWithPointer), pointer:: p
|
|
|
|
+ end type typeWithPointer
|
|
|
|
+
|
|
|
|
+ type :: twoPtr
|
|
|
|
+ type (two), pointer :: p
|
|
|
|
+ end type twoPtr
|
|
|
|
+
|
2019-06-25 19:49:31 +00:00
|
|
|
logical, target :: logv
|
|
|
|
complex, target :: comv
|
|
|
|
character, target :: charv
|
|
|
|
character (len=3), target :: chara
|
|
|
|
integer, target :: intv
|
|
|
|
integer, target, dimension (10,2) :: inta
|
|
|
|
- real, target :: realv
|
|
|
|
- type(two), target :: twov
|
2016-09-07 20:47:48 +00:00
|
|
|
+ integer, target, allocatable, dimension (:) :: intvla
|
|
|
|
+ real, target :: realv
|
|
|
|
+ type(two), target :: twov
|
|
|
|
+ type(twoPtr) :: arrayOfPtr (3)
|
|
|
|
+ type(typeWithPointer), target:: cyclicp1,cyclicp2
|
2019-06-25 19:49:31 +00:00
|
|
|
|
|
|
|
logical, pointer :: logp
|
|
|
|
complex, pointer :: comp
|
|
|
|
- character, pointer :: charp
|
|
|
|
- character (len=3), pointer :: charap
|
2016-09-07 20:47:48 +00:00
|
|
|
+ character, pointer:: charp
|
|
|
|
+ character (len=3), pointer:: charap
|
2019-06-25 19:49:31 +00:00
|
|
|
integer, pointer :: intp
|
|
|
|
integer, pointer, dimension (:,:) :: intap
|
2016-09-07 20:47:48 +00:00
|
|
|
+ integer, pointer, dimension (:) :: intvlap
|
2019-06-25 19:49:31 +00:00
|
|
|
real, pointer :: realp
|
|
|
|
type(two), pointer :: twop
|
|
|
|
|
|
|
|
@@ -44,8 +57,14 @@ program pointers
|
|
|
|
nullify (charap)
|
|
|
|
nullify (intp)
|
|
|
|
nullify (intap)
|
2016-09-07 20:47:48 +00:00
|
|
|
+ nullify (intvlap)
|
2019-06-25 19:49:31 +00:00
|
|
|
nullify (realp)
|
|
|
|
nullify (twop)
|
2016-09-07 20:47:48 +00:00
|
|
|
+ nullify (arrayOfPtr(1)%p)
|
|
|
|
+ nullify (arrayOfPtr(2)%p)
|
|
|
|
+ nullify (arrayOfPtr(3)%p)
|
|
|
|
+ nullify (cyclicp1%p)
|
|
|
|
+ nullify (cyclicp2%p)
|
2019-06-25 19:49:31 +00:00
|
|
|
|
|
|
|
logp => logv ! Before pointer assignment
|
|
|
|
comp => comv
|
|
|
|
@@ -53,8 +72,14 @@ program pointers
|
|
|
|
charap => chara
|
|
|
|
intp => intv
|
|
|
|
intap => inta
|
2016-09-07 20:47:48 +00:00
|
|
|
+ intvlap => intvla
|
2019-06-25 19:49:31 +00:00
|
|
|
realp => realv
|
|
|
|
twop => twov
|
2016-09-07 20:47:48 +00:00
|
|
|
+ arrayOfPtr(2)%p => twov
|
|
|
|
+ cyclicp1%i = 1
|
|
|
|
+ cyclicp1%p => cyclicp2
|
|
|
|
+ cyclicp2%i = 2
|
|
|
|
+ cyclicp2%p => cyclicp1
|
2019-06-25 19:49:31 +00:00
|
|
|
|
|
|
|
logv = associated(logp) ! Before value assignment
|
|
|
|
comv = cmplx(1,2)
|
|
|
|
@@ -63,6 +88,10 @@ program pointers
|
|
|
|
intv = 10
|
|
|
|
inta(:,:) = 1
|
|
|
|
inta(3,1) = 3
|
2016-09-07 20:47:48 +00:00
|
|
|
+ allocate (intvla(10))
|
|
|
|
+ intvla(:) = 2
|
|
|
|
+ intvla(4) = 4
|
|
|
|
+ intvlap => intvla
|
2019-06-25 19:49:31 +00:00
|
|
|
realv = 3.14
|
|
|
|
|
|
|
|
allocate (twov%ivla1(3))
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
|
2019-06-25 19:49:31 +00:00
|
|
|
--- a/gdb/testsuite/gdb.fortran/print_type.exp
|
2017-12-08 04:31:26 +00:00
|
|
|
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
|
2019-06-25 19:49:31 +00:00
|
|
|
@@ -1,5 +1,6 @@
|
2020-02-04 20:06:34 +00:00
|
|
|
# Copyright 2019-2020 Free Software Foundation, Inc.
|
2019-06-25 19:49:31 +00:00
|
|
|
#
|
|
|
|
+
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -42,7 +43,7 @@ set complex [fortran_complex4]
|
2019-06-25 19:49:31 +00:00
|
|
|
# matches the string TYPE.
|
|
|
|
proc check_pointer_type { var_name type } {
|
|
|
|
gdb_test "ptype ${var_name}" \
|
|
|
|
- "type = PTR TO -> \\( ${type} \\)"
|
|
|
|
+ "type = PTR TO -> \\( ${type}\\)"
|
|
|
|
}
|
|
|
|
|
|
|
|
gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -87,7 +88,8 @@ gdb_test "ptype twop" \
|
2019-06-25 19:49:31 +00:00
|
|
|
[multi_line "type = PTR TO -> \\( Type two" \
|
|
|
|
" $int, allocatable :: ivla1\\(:\\)" \
|
|
|
|
" $int, allocatable :: ivla2\\(:,:\\)" \
|
|
|
|
- "End Type two \\)"]
|
2019-05-03 00:08:08 +00:00
|
|
|
+ "End Type two\\)"]
|
2016-09-07 20:47:48 +00:00
|
|
|
+
|
2019-06-25 19:49:31 +00:00
|
|
|
|
|
|
|
gdb_breakpoint [gdb_get_line_number "After value assignment"]
|
|
|
|
gdb_continue_to_breakpoint "After value assignment"
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -99,11 +101,11 @@ gdb_test "ptype intv" "type = $int"
|
2019-06-25 19:49:31 +00:00
|
|
|
gdb_test "ptype inta" "type = $int \\(10,2\\)"
|
|
|
|
gdb_test "ptype realv" "type = $real"
|
|
|
|
|
|
|
|
-gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)"
|
|
|
|
-gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)"
|
|
|
|
-gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)"
|
|
|
|
-gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)"
|
|
|
|
-gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "ptype logp" "type = PTR TO -> \\( $logical\\)"
|
|
|
|
+gdb_test "ptype comp" "type = PTR TO -> \\( $complex\\)"
|
|
|
|
+gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1\\)"
|
|
|
|
+gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3\\)"
|
|
|
|
+gdb_test "ptype intp" "type = PTR TO -> \\( $int\\)"
|
2019-06-25 19:49:31 +00:00
|
|
|
set test "ptype intap"
|
|
|
|
gdb_test_multiple $test $test {
|
|
|
|
-re "type = $int \\(10,2\\)\r\n$gdb_prompt $" {
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -113,4 +115,4 @@ gdb_test_multiple $test $test {
|
2019-06-25 19:49:31 +00:00
|
|
|
pass $test
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)"
|
2019-05-03 00:08:08 +00:00
|
|
|
+gdb_test "ptype realp" "type = PTR TO -> \\( $real\\)"
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/testsuite/gdb.fortran/vla-strings.exp b/gdb/testsuite/gdb.fortran/vla-strings.exp
|
|
|
|
new file mode 100644
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/gdb/testsuite/gdb.fortran/vla-strings.exp
|
2016-09-07 20:47:48 +00:00
|
|
|
@@ -0,0 +1,103 @@
|
|
|
|
+# Copyright 2016 Free Software Foundation, Inc.
|
|
|
|
+
|
|
|
|
+# This program is free software; you can redistribute it and/or modify
|
|
|
|
+# it under the terms of the GNU General Public License as published by
|
|
|
|
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
+# (at your option) any later version.
|
|
|
|
+#
|
|
|
|
+# This program is distributed in the hope that it will be useful,
|
|
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+# GNU General Public License for more details.
|
|
|
|
+#
|
|
|
|
+# You should have received a copy of the GNU General Public License
|
|
|
|
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
+
|
|
|
|
+standard_testfile ".f90"
|
|
|
|
+
|
|
|
|
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
|
|
|
|
+ {debug f90 quiet}] } {
|
|
|
|
+ return -1
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+# check that all fortran standard datatypes will be
|
|
|
|
+# handled correctly when using as VLA's
|
|
|
|
+
|
|
|
|
+if ![runto_main] {
|
|
|
|
+ untested "could not run to main"
|
|
|
|
+ return -1
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"]
|
|
|
|
+gdb_continue_to_breakpoint "var_char-allocated-1"
|
|
|
|
+set test "whatis var_char first time"
|
|
|
|
+gdb_test_multiple "whatis var_char" $test {
|
2019-05-03 00:08:08 +00:00
|
|
|
+ -re "type = PTR TO -> \\( character\\*10\\)\r\n$gdb_prompt $" {
|
2016-09-07 20:47:48 +00:00
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+ -re "type = character\\*10\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+set test "ptype var_char first time"
|
|
|
|
+gdb_test_multiple "ptype var_char" $test {
|
2019-05-03 00:08:08 +00:00
|
|
|
+ -re "type = PTR TO -> \\( character\\*10\\)\r\n$gdb_prompt $" {
|
2016-09-07 20:47:48 +00:00
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+ -re "type = character\\*10\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+gdb_test "next" "\\d+.*var_char = 'foo'.*" \
|
|
|
|
+ "next to allocation status of var_char"
|
|
|
|
+gdb_test "print l" " = \\.TRUE\\." "print allocation status first time"
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+gdb_breakpoint [gdb_get_line_number "var_char-filled-1"]
|
|
|
|
+gdb_continue_to_breakpoint "var_char-filled-1"
|
|
|
|
+set test "print var_char, var_char-filled-1"
|
|
|
|
+gdb_test_multiple "print var_char" $test {
|
2019-05-03 00:08:08 +00:00
|
|
|
+ -re "= \\(PTR TO -> \\( character\\*3\\)\\) $hex\r\n$gdb_prompt $" {
|
2016-09-07 20:47:48 +00:00
|
|
|
+ gdb_test "print *var_char" "= 'foo'" "print *var_char, var_char-filled-1"
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+ -re "= 'foo'\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+set test "ptype var_char, var_char-filled-1"
|
|
|
|
+gdb_test_multiple "ptype var_char" $test {
|
2019-05-03 00:08:08 +00:00
|
|
|
+ -re "type = PTR TO -> \\( character\\*3\\)\r\n$gdb_prompt $" {
|
2016-09-07 20:47:48 +00:00
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+ -re "type = character\\*3\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)"
|
|
|
|
+gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)"
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+gdb_breakpoint [gdb_get_line_number "var_char-filled-2"]
|
|
|
|
+gdb_continue_to_breakpoint "var_char-filled-2"
|
|
|
|
+set test "print var_char, var_char-filled-2"
|
|
|
|
+gdb_test_multiple "print var_char" $test {
|
2019-05-03 00:08:08 +00:00
|
|
|
+ -re "= \\(PTR TO -> \\( character\\*6\\)\\) $hex\r\n$gdb_prompt $" {
|
2016-09-07 20:47:48 +00:00
|
|
|
+ gdb_test "print *var_char" "= 'foobar'" "print *var_char, var_char-filled-2"
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+ -re "= 'foobar'\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+set test "ptype var_char, var_char-filled-2"
|
|
|
|
+gdb_test_multiple "ptype var_char" $test {
|
2019-05-03 00:08:08 +00:00
|
|
|
+ -re "type = PTR TO -> \\( character\\*6\\)\r\n$gdb_prompt $" {
|
2016-09-07 20:47:48 +00:00
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+ -re "type = character\\*6\r\n$gdb_prompt $" {
|
|
|
|
+ pass $test
|
|
|
|
+ }
|
|
|
|
+}
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/testsuite/gdb.fortran/vla-strings.f90 b/gdb/testsuite/gdb.fortran/vla-strings.f90
|
|
|
|
new file mode 100644
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/gdb/testsuite/gdb.fortran/vla-strings.f90
|
2016-09-07 20:47:48 +00:00
|
|
|
@@ -0,0 +1,39 @@
|
|
|
|
+! Copyright 2016 Free Software Foundation, Inc.
|
|
|
|
+!
|
|
|
|
+! This program is free software; you can redistribute it and/or modify
|
|
|
|
+! it under the terms of the GNU General Public License as published by
|
|
|
|
+! the Free Software Foundation; either version 3 of the License, or
|
|
|
|
+! (at your option) any later version.
|
|
|
|
+!
|
|
|
|
+! This program is distributed in the hope that it will be useful,
|
|
|
|
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+! GNU General Public License for more details.
|
|
|
|
+!
|
|
|
|
+! You should have received a copy of the GNU General Public License
|
|
|
|
+! along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
+
|
|
|
|
+program vla_strings
|
|
|
|
+ character(len=:), target, allocatable :: var_char
|
|
|
|
+ character(len=:), pointer :: var_char_p
|
|
|
|
+ logical :: l
|
|
|
|
+
|
|
|
|
+ allocate(character(len=10) :: var_char)
|
|
|
|
+ l = allocated(var_char) ! var_char-allocated-1
|
|
|
|
+ var_char = 'foo'
|
|
|
|
+ deallocate(var_char) ! var_char-filled-1
|
|
|
|
+ l = allocated(var_char) ! var_char-deallocated
|
|
|
|
+ allocate(character(len=42) :: var_char)
|
|
|
|
+ l = allocated(var_char)
|
|
|
|
+ var_char = 'foobar'
|
|
|
|
+ var_char = '' ! var_char-filled-2
|
|
|
|
+ var_char = 'bar' ! var_char-empty
|
|
|
|
+ deallocate(var_char)
|
|
|
|
+ allocate(character(len=21) :: var_char)
|
|
|
|
+ l = allocated(var_char) ! var_char-allocated-3
|
|
|
|
+ var_char = 'johndoe'
|
|
|
|
+ var_char_p => var_char
|
|
|
|
+ l = associated(var_char_p) ! var_char_p-associated
|
|
|
|
+ var_char_p => null()
|
|
|
|
+ l = associated(var_char_p) ! var_char_p-not-associated
|
|
|
|
+end program vla_strings
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
|
|
|
|
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
|
|
|
|
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -37,7 +37,7 @@ gdb_breakpoint [gdb_get_line_number "vla1-init"]
|
2016-09-07 20:47:48 +00:00
|
|
|
gdb_continue_to_breakpoint "vla1-init"
|
|
|
|
gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
|
|
|
|
gdb_test "print &vla1" \
|
2019-06-25 19:49:31 +00:00
|
|
|
- " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\) \\\)\\\) $hex" \
|
2019-05-02 03:08:41 +00:00
|
|
|
+ " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\)\\\)\\\) $hex" \
|
2016-09-07 20:47:48 +00:00
|
|
|
"print non-allocated &vla1"
|
|
|
|
gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \
|
|
|
|
"print member in non-allocated vla1 (1)"
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -58,7 +58,7 @@ with_timeout_factor 15 {
|
2019-05-02 03:08:41 +00:00
|
|
|
"step over value assignment of vla1"
|
|
|
|
}
|
|
|
|
gdb_test "print &vla1" \
|
|
|
|
- " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\) \\\)\\\) $hex" \
|
|
|
|
+ " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\)\\\)\\\) $hex" \
|
|
|
|
"print allocated &vla1"
|
|
|
|
gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)"
|
|
|
|
gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)"
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -78,7 +78,7 @@ gdb_test "print vla1(9, 9, 9)" " = 999" \
|
2016-09-07 20:47:48 +00:00
|
|
|
# Try to access values in undefined pointer to VLA (dangling)
|
|
|
|
gdb_test "print pvla" " = <not associated>" "print undefined pvla"
|
|
|
|
gdb_test "print &pvla" \
|
2019-06-25 19:49:31 +00:00
|
|
|
- " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\) \\\)\\\) $hex" \
|
2016-09-07 20:47:48 +00:00
|
|
|
+ " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\)\\\)\\\) $hex" \
|
|
|
|
"print non-associated &pvla"
|
|
|
|
gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \
|
|
|
|
"print undefined pvla(1,3,8)"
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -87,7 +87,7 @@ gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated
|
2019-05-02 03:08:41 +00:00
|
|
|
gdb_breakpoint [gdb_get_line_number "pvla-associated"]
|
|
|
|
gdb_continue_to_breakpoint "pvla-associated"
|
|
|
|
gdb_test "print &pvla" \
|
|
|
|
- " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\) \\\)\\\) $hex" \
|
|
|
|
+ " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \
|
|
|
|
"print associated &pvla"
|
|
|
|
gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)"
|
|
|
|
gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)"
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
|
|
|
|
--- a/gdb/typeprint.c
|
|
|
|
+++ b/gdb/typeprint.c
|
2021-02-24 21:25:14 +00:00
|
|
|
@@ -565,6 +565,25 @@ whatis_exp (const char *exp, int show)
|
2016-09-07 20:47:48 +00:00
|
|
|
printf_filtered (" */\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
+ /* Resolve any dynamic target type, as we might print
|
|
|
|
+ additional information about the target.
|
|
|
|
+ For example, in Fortran and C we are printing the dimension of the
|
|
|
|
+ dynamic array the pointer is pointing to. */
|
2020-11-05 21:17:24 +00:00
|
|
|
+ if (type->code () == TYPE_CODE_PTR
|
2016-09-07 20:47:48 +00:00
|
|
|
+ && is_dynamic_type (type) == 1)
|
|
|
|
+ {
|
2021-02-24 21:25:14 +00:00
|
|
|
+ CORE_ADDR addr;
|
|
|
|
+ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE(type)))
|
|
|
|
+ addr = value_address (val);
|
|
|
|
+ else
|
|
|
|
+ addr = value_as_address (val);
|
2016-09-07 20:47:48 +00:00
|
|
|
+
|
|
|
|
+ if (addr != 0
|
|
|
|
+ && type_not_associated (type) == 0)
|
|
|
|
+ TYPE_TARGET_TYPE (type) = resolve_dynamic_type (TYPE_TARGET_TYPE (type),
|
2020-11-05 21:17:24 +00:00
|
|
|
+ {}, addr);
|
2016-09-07 20:47:48 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
LA_PRINT_TYPE (type, "", gdb_stdout, show, 0, &flags);
|
|
|
|
printf_filtered ("\n");
|
2018-05-31 18:47:56 +00:00
|
|
|
}
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/valops.c b/gdb/valops.c
|
|
|
|
--- a/gdb/valops.c
|
|
|
|
+++ b/gdb/valops.c
|
2021-02-24 21:25:14 +00:00
|
|
|
@@ -1553,6 +1553,19 @@ value_ind (struct value *arg1)
|
2020-11-05 21:17:24 +00:00
|
|
|
if (base_type->code () == TYPE_CODE_PTR)
|
2016-09-07 20:47:48 +00:00
|
|
|
{
|
|
|
|
struct type *enc_type;
|
2021-02-24 21:25:14 +00:00
|
|
|
+ CORE_ADDR addr;
|
2016-09-07 20:47:48 +00:00
|
|
|
+
|
|
|
|
+ if (type_not_associated (base_type))
|
|
|
|
+ error (_("Attempt to take contents of a not associated pointer."));
|
|
|
|
+
|
2021-02-24 21:25:14 +00:00
|
|
|
+ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (base_type)))
|
|
|
|
+ addr = value_address (arg1);
|
|
|
|
+ else
|
|
|
|
+ addr = value_as_address (arg1);
|
2016-09-07 20:47:48 +00:00
|
|
|
+
|
|
|
|
+ if (addr != 0)
|
|
|
|
+ TYPE_TARGET_TYPE (base_type) =
|
2020-11-05 21:17:24 +00:00
|
|
|
+ resolve_dynamic_type (TYPE_TARGET_TYPE (base_type), {}, addr);
|
2016-09-07 20:47:48 +00:00
|
|
|
|
|
|
|
/* We may be pointing to something embedded in a larger object.
|
|
|
|
Get the real type of the enclosing object. */
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -1570,8 +1583,7 @@ value_ind (struct value *arg1)
|
2016-09-07 20:47:48 +00:00
|
|
|
else
|
2020-11-05 21:17:24 +00:00
|
|
|
{
|
|
|
|
/* Retrieve the enclosing object pointed to. */
|
|
|
|
- base_addr = (value_as_address (arg1)
|
|
|
|
- - value_pointed_to_offset (arg1));
|
|
|
|
+ base_addr = (addr - value_pointed_to_offset (arg1));
|
|
|
|
}
|
|
|
|
arg2 = value_at_lazy (enc_type, base_addr);
|
2016-09-07 20:47:48 +00:00
|
|
|
enc_type = value_type (arg2);
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/valprint.c b/gdb/valprint.c
|
|
|
|
--- a/gdb/valprint.c
|
|
|
|
+++ b/gdb/valprint.c
|
2020-11-05 21:17:24 +00:00
|
|
|
@@ -1046,12 +1046,6 @@ value_check_printable (struct value *val, struct ui_file *stream,
|
2016-09-07 20:47:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (type_not_associated (value_type (val)))
|
|
|
|
- {
|
|
|
|
- val_print_not_associated (stream);
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if (type_not_allocated (value_type (val)))
|
|
|
|
{
|
|
|
|
val_print_not_allocated (stream);
|