* [V2 09/23] vla: changed string length semantic.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
@ 2014-07-11 9:21 ` Keven Boell
2014-07-18 15:38 ` Jan Kratochvil
2014-07-11 9:21 ` [V2 21/23] test: basic MI test for the dynamic array support Keven Boell
` (23 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:21 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
This patch changes the semantic of the Dwarf string length
attribute to reflect the standard. This serves as pre-work
to get variable strings in Fortran to work.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
* dwarf2read.c (read_tag_string_type): changed
semantic of DW_AT_string_length to be able to
handle Dwarf blocks as well. Support for
DW_AT_byte_length added to get correct length
if specified in combination with
DW_AT_string_length.
(attr_to_dynamic_prop): added
functionality to add Dwarf operators to baton
data attribute. Added post values to baton
as required by the string evaluation case.
(read_subrange_type): Adapt caller.
(set_die_type): Adapt caller.
(add_post_values_to_baton): New function.
* dwarf2loc.c (dwarf2_evaluate_property): Evaluate
post processing dwarf.
* dwarf2loc.h (struct dwarf2_property_baton): Add
post dwarf values attribute.
Change-Id: I6edfa005f416cddc8e364d34891b9abf6b44f757
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/dwarf2read.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 126 insertions(+), 18 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index f612cd8..9b755b2 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1847,6 +1847,12 @@ static void free_dwo_file_cleanup (void *);
static void process_cu_includes (void);
static void check_producer (struct dwarf2_cu *cu);
+
+static int
+attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
+ struct dwarf2_cu *cu, struct dynamic_prop *prop,
+ const gdb_byte *additional_data, int additional_data_size);
+
\f
/* Various complaints about symbol reading that don't abort the process. */
@@ -14201,29 +14207,94 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct type *type, *range_type, *index_type, *char_type;
struct attribute *attr;
- unsigned int length;
+ unsigned int length = UINT_MAX;
+ index_type = objfile_type (objfile)->builtin_int;
+ range_type = create_static_range_type (NULL, index_type, 1, length);
+
+ /* If DW_AT_string_length is defined, the length is stored at some location
+ * in memory. */
attr = dwarf2_attr (die, DW_AT_string_length, cu);
if (attr)
{
- length = DW_UNSND (attr);
+ if (attr_form_is_block (attr))
+ {
+ 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 together in combination with
+ DW_AT_string_length. */
+ if ((byte_size == NULL && bit_size != NULL) ||
+ (byte_size != NULL && bit_size == NULL))
+ complaint (&symfile_complaints, _("DW_AT_byte_size AND "
+ "DW_AT_bit_size found together at the same time."));
+
+ /* If DW_AT_string_length AND DW_AT_byte_size exist together, it
+ describes the number of bytes that should be read from the length
+ memory location. */
+ if (byte_size != NULL && bit_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. */
+ DW_UNSND (byte_size) };
+
+ if (!attr_to_dynamic_prop (attr, die, cu, &high,
+ append_ops, ARRAY_SIZE (append_ops)))
+ complaint (&symfile_complaints,
+ _("Could not parse DW_AT_byte_size"));
+ }
+ else if (bit_size != NULL && byte_size == NULL)
+ complaint (&symfile_complaints, _("DW_AT_string_length AND "
+ "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 };
+
+ if (!attr_to_dynamic_prop (attr, die, cu, &high, append_ops,
+ ARRAY_SIZE (append_ops)))
+ complaint (&symfile_complaints,
+ _("Could not parse DW_AT_string_length"));
+ }
+
+ TYPE_RANGE_DATA (range_type)->high = high;
+ }
+ else
+ {
+ TYPE_HIGH_BOUND (range_type) = DW_UNSND (attr);
+ TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
+ }
}
else
{
- /* Check for the DW_AT_byte_size attribute. */
+ /* Check for the DW_AT_byte_size attribute, which represents the length
+ in this case. */
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr)
{
- length = DW_UNSND (attr);
+ TYPE_HIGH_BOUND (range_type) = DW_UNSND (attr);
+ TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
}
else
{
- length = 1;
+ TYPE_HIGH_BOUND (range_type) = 1;
+ TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
}
}
- index_type = objfile_type (objfile)->builtin_int;
- range_type = create_static_range_type (NULL, index_type, 1, length);
char_type = language_string_char_type (cu->language_defn, gdbarch);
type = create_string_type (NULL, char_type, range_type);
@@ -14540,13 +14611,15 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
return set_die_type (die, type, cu);
}
+
/* Parse dwarf attribute if it's a block, reference or constant and put the
resulting value of the attribute into struct bound_prop.
Returns 1 if ATTR could be resolved into PROP, 0 otherwise. */
static int
attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
- struct dwarf2_cu *cu, struct dynamic_prop *prop)
+ struct dwarf2_cu *cu, struct dynamic_prop *prop,
+ const gdb_byte *additional_data, int additional_data_size)
{
struct dwarf2_property_baton *baton;
struct obstack *obstack = &cu->objfile->objfile_obstack;
@@ -14559,8 +14632,25 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
baton = obstack_alloc (obstack, sizeof (*baton));
baton->referenced_type = NULL;
baton->locexpr.per_cu = cu->per_cu;
- baton->locexpr.size = DW_BLOCK (attr)->size;
- baton->locexpr.data = DW_BLOCK (attr)->data;
+
+ if (additional_data != NULL && additional_data_size > 0)
+ {
+ gdb_byte *data;
+
+ data = obstack_alloc (&cu->objfile->objfile_obstack,
+ 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;
+ }
prop->data.baton = baton;
prop->kind = PROP_LOCEXPR;
gdb_assert (prop->data.baton != NULL);
@@ -14590,8 +14680,26 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
baton = obstack_alloc (obstack, sizeof (*baton));
baton->referenced_type = die_type (target_die, target_cu);
baton->locexpr.per_cu = cu->per_cu;
- baton->locexpr.size = DW_BLOCK (target_attr)->size;
- baton->locexpr.data = DW_BLOCK (target_attr)->data;
+
+ if (additional_data != NULL && additional_data_size > 0)
+ {
+ gdb_byte *data;
+
+ data = obstack_alloc (&cu->objfile->objfile_obstack,
+ 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;
+ }
+
prop->data.baton = baton;
prop->kind = PROP_LOCEXPR;
gdb_assert (prop->data.baton != NULL);
@@ -14681,17 +14789,17 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
if (attr)
- attr_to_dynamic_prop (attr, die, cu, &low);
+ attr_to_dynamic_prop (attr, die, cu, &low, NULL, 0);
else if (!low_default_is_valid)
complaint (&symfile_complaints, _("Missing DW_AT_lower_bound "
"- DIE at 0x%x [in module %s]"),
die->offset.sect_off, objfile_name (cu->objfile));
attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
- if (!attr_to_dynamic_prop (attr, die, cu, &high))
+ if (!attr_to_dynamic_prop (attr, die, cu, &high, NULL, 0))
{
attr = dwarf2_attr (die, DW_AT_count, cu);
- if (attr_to_dynamic_prop (attr, die, cu, &high))
+ if (attr_to_dynamic_prop (attr, die, cu, &high, NULL, 0))
{
/* If bounds are constant do the final calculation here. */
if (low.kind == PROP_CONST && high.kind == PROP_CONST)
@@ -21695,7 +21803,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
{
struct dynamic_prop prop;
- if (attr_to_dynamic_prop (attr, die, cu, &prop))
+ if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
{
TYPE_ALLOCATED_PROP (type)
= obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
@@ -21709,7 +21817,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
{
struct dynamic_prop prop;
- if (attr_to_dynamic_prop (attr, die, cu, &prop))
+ if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
{
TYPE_ASSOCIATED_PROP (type)
= obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
@@ -21719,7 +21827,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
/* Read DW_AT_data_location and set in type. */
attr = dwarf2_attr (die, DW_AT_data_location, cu);
- if (attr_to_dynamic_prop (attr, die, cu, &prop))
+ if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
{
TYPE_DATA_LOCATION (type)
= obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* Re: [V2 09/23] vla: changed string length semantic.
2014-07-11 9:21 ` [V2 09/23] vla: changed string length semantic Keven Boell
@ 2014-07-18 15:38 ` Jan Kratochvil
2014-07-21 13:23 ` Keven Boell
0 siblings, 1 reply; 51+ messages in thread
From: Jan Kratochvil @ 2014-07-18 15:38 UTC (permalink / raw)
To: Keven Boell; +Cc: gdb-patches, sanimir.agovic
[-- Attachment #1: Type: text/plain, Size: 1535 bytes --]
Hi Keven,
the regression discussed in
Re: [V2 00/23] Fortran dynamic array support
https://sourceware.org/ml/gdb-patches/2014-07/msg00278.html
is IMO here:
On Fri, 11 Jul 2014 11:21:21 +0200, Keven Boell wrote:
> @@ -14590,8 +14680,26 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
> baton = obstack_alloc (obstack, sizeof (*baton));
> baton->referenced_type = die_type (target_die, target_cu);
> baton->locexpr.per_cu = cu->per_cu;
> - baton->locexpr.size = DW_BLOCK (target_attr)->size;
> - baton->locexpr.data = DW_BLOCK (target_attr)->data;
> +
> + if (additional_data != NULL && additional_data_size > 0)
> + {
> + gdb_byte *data;
> +
> + data = obstack_alloc (&cu->objfile->objfile_obstack,
> + 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;
> + }
> +
> prop->data.baton = baton;
> prop->kind = PROP_LOCEXPR;
> gdb_assert (prop->data.baton != NULL);
it was correctly using 'target_attr' but now it uses 'attr' instead.
The gdb.ada/ regression gets fixed for me by the attached patch.
Jan
[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 1254 bytes --]
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index e4f5240..f3e3f56 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -14684,18 +14684,20 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
gdb_byte *data;
data = obstack_alloc (&cu->objfile->objfile_obstack,
- DW_BLOCK (attr)->size + additional_data_size);
- memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
- memcpy (data + DW_BLOCK (attr)->size,
+ 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 (attr)->size + additional_data_size;
+ baton->locexpr.size = (DW_BLOCK (target_attr)->size
+ + additional_data_size);
}
else
{
- baton->locexpr.data = DW_BLOCK (attr)->data;
- baton->locexpr.size = DW_BLOCK (attr)->size;
+ baton->locexpr.data = DW_BLOCK (target_attr)->data;
+ baton->locexpr.size = DW_BLOCK (target_attr)->size;
}
prop->data.baton = baton;
^ permalink raw reply [flat|nested] 51+ messages in thread* Re: [V2 09/23] vla: changed string length semantic.
2014-07-18 15:38 ` Jan Kratochvil
@ 2014-07-21 13:23 ` Keven Boell
2014-07-21 19:54 ` Jan Kratochvil
0 siblings, 1 reply; 51+ messages in thread
From: Keven Boell @ 2014-07-21 13:23 UTC (permalink / raw)
To: Jan Kratochvil, Keven Boell; +Cc: gdb-patches, sanimir.agovic
On 18.07.2014 17:19, Jan Kratochvil wrote:
> Hi Keven,
>
> the regression discussed in
> Re: [V2 00/23] Fortran dynamic array support
> https://sourceware.org/ml/gdb-patches/2014-07/msg00278.html
>
> is IMO here:
>
> On Fri, 11 Jul 2014 11:21:21 +0200, Keven Boell wrote:
>> @@ -14590,8 +14680,26 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
>> baton = obstack_alloc (obstack, sizeof (*baton));
>> baton->referenced_type = die_type (target_die, target_cu);
>> baton->locexpr.per_cu = cu->per_cu;
>> - baton->locexpr.size = DW_BLOCK (target_attr)->size;
>> - baton->locexpr.data = DW_BLOCK (target_attr)->data;
>> +
>> + if (additional_data != NULL && additional_data_size > 0)
>> + {
>> + gdb_byte *data;
>> +
>> + data = obstack_alloc (&cu->objfile->objfile_obstack,
>> + 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;
>> + }
>> +
>> prop->data.baton = baton;
>> prop->kind = PROP_LOCEXPR;
>> gdb_assert (prop->data.baton != NULL);
>
> it was correctly using 'target_attr' but now it uses 'attr' instead.
>
> The gdb.ada/ regression gets fixed for me by the attached patch.
>
Thanks for your investigation. Seems like I did a copy and paste error here, you are
right, target_attr is the right variable to use in this case.
I pushed the updated series to Github: https://github.com/intel-gdb/vla/tree/vla-fortran
>
> Jan
>
Thanks,
Keven
^ permalink raw reply [flat|nested] 51+ messages in thread
* [V2 21/23] test: basic MI test for the dynamic array support.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
2014-07-11 9:21 ` [V2 09/23] vla: changed string length semantic Keven Boell
@ 2014-07-11 9:21 ` Keven Boell
2014-07-11 9:21 ` [V2 08/23] vla: get dynamic array corner cases to work Keven Boell
` (22 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:21 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Tests dynamic array evaluations using MI protocol.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
testsuite/gdb.mi/:
* mi-vla-fortran.exp: New file.
* vla.f90: New file.
Change-Id: I37caa85b1498478f5eff0f52d3fd431388aaab6f
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/testsuite/gdb.mi/mi-vla-fortran.exp | 182 +++++++++++++++++++++++++++++++
gdb/testsuite/gdb.mi/vla.f90 | 42 +++++++
2 files changed, 224 insertions(+)
create mode 100644 gdb/testsuite/gdb.mi/mi-vla-fortran.exp
create mode 100644 gdb/testsuite/gdb.mi/vla.f90
diff --git a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
new file mode 100644
index 0000000..72b0be2
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
@@ -0,0 +1,182 @@
+# Copyright 2014 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/>.
+
+# Verify that, using the MI, we can evaluate a simple C Variable Length
+# Array (VLA).
+
+load_lib mi-support.exp
+set MIFLAGS "-i=mi"
+
+gdb_exit
+if [mi_gdb_start] {
+ continue
+}
+
+standard_testfile vla.f90
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
+ {debug f90}] != "" } {
+ untested mi-vla-fortran.exp
+ return -1
+}
+
+mi_delete_breakpoints
+mi_gdb_reinitialize_dir $srcdir/$subdir
+mi_gdb_load ${binfile}
+
+set bp_lineno [gdb_get_line_number "vla1-not-allocated"]
+mi_create_breakpoint "-t vla.f90:$bp_lineno" 1 "del" "vla" \
+ ".*vla.f90" $bp_lineno $hex \
+ "insert breakpoint at line $bp_lineno (vla not allocated)"
+mi_run_cmd
+mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
+ { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
+mi_gdb_test "500-data-evaluate-expression vla1" \
+ "500\\^done,value=\"<not allocated>\"" "evaluate not allocated vla"
+
+mi_create_varobj_checked vla1_not_allocated vla1 "<not allocated>" \
+ "create local variable vla1_not_allocated"
+mi_gdb_test "501-var-info-type vla1_not_allocated" \
+ "501\\^done,type=\"<not allocated>\"" \
+ "info type variable vla1_not_allocated"
+mi_gdb_test "502-var-show-format vla1_not_allocated" \
+ "502\\^done,format=\"natural\"" \
+ "show format variable vla1_not_allocated"
+mi_gdb_test "503-var-evaluate-expression vla1_not_allocated" \
+ "503\\^done,value=\"\\\[0\\\]\"" \
+ "eval variable vla1_not_allocated"
+mi_list_array_varobj_children_with_index "vla1_not_allocated" "0" "1" \
+ "real\\\(kind=4\\\)" "get children of vla1_not_allocated"
+
+
+
+set bp_lineno [gdb_get_line_number "vla1-allocated"]
+mi_create_breakpoint "-t vla.f90:$bp_lineno" 2 "del" "vla" ".*vla.f90" \
+ $bp_lineno $hex "insert breakpoint at line $bp_lineno (vla allocated)"
+mi_run_cmd
+mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
+ { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
+mi_gdb_test "510-data-evaluate-expression vla1" \
+ "510\\^done,value=\"\\(0, 0, 0, 0, 0\\)\"" "evaluate allocated vla"
+
+mi_create_varobj_checked vla1_allocated vla1 "real\\\(kind=4\\\) \\\(5\\\)" \
+ "create local variable vla1_allocated"
+mi_gdb_test "511-var-info-type vla1_allocated" \
+ "511\\^done,type=\"real\\\(kind=4\\\) \\\(5\\\)\"" \
+ "info type variable vla1_allocated"
+mi_gdb_test "512-var-show-format vla1_allocated" \
+ "512\\^done,format=\"natural\"" \
+ "show format variable vla1_allocated"
+mi_gdb_test "513-var-evaluate-expression vla1_allocated" \
+ "513\\^done,value=\"\\\[5\\\]\"" \
+ "eval variable vla1_allocated"
+mi_list_array_varobj_children_with_index "vla1_allocated" "5" "1" \
+ "real\\\(kind=4\\\)" "get children of vla1_allocated"
+
+
+set bp_lineno [gdb_get_line_number "vla1-filled"]
+mi_create_breakpoint "-t vla.f90:$bp_lineno" 3 "del" "vla" ".*vla.f90" \
+ $bp_lineno $hex "insert breakpoint at line $bp_lineno"
+mi_run_cmd
+mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
+ { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
+mi_gdb_test "520-data-evaluate-expression vla1" \
+ "520\\^done,value=\"\\(1, 1, 1, 1, 1\\)\"" "evaluate filled vla"
+
+
+set bp_lineno [gdb_get_line_number "vla1-modified"]
+mi_create_breakpoint "-t vla.f90:$bp_lineno" 4 "del" "vla" ".*vla.f90" \
+ $bp_lineno $hex "insert breakpoint at line $bp_lineno"
+mi_run_cmd
+mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
+ { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
+mi_gdb_test "530-data-evaluate-expression vla1" \
+ "530\\^done,value=\"\\(1, 42, 1, 24, 1\\)\"" "evaluate filled vla"
+mi_gdb_test "540-data-evaluate-expression vla1(1)" \
+ "540\\^done,value=\"1\"" "evaluate filled vla"
+mi_gdb_test "550-data-evaluate-expression vla1(2)" \
+ "550\\^done,value=\"42\"" "evaluate filled vla"
+mi_gdb_test "560-data-evaluate-expression vla1(4)" \
+ "560\\^done,value=\"24\"" "evaluate filled vla"
+
+
+set bp_lineno [gdb_get_line_number "vla1-deallocated"]
+mi_create_breakpoint "-t vla.f90:$bp_lineno" 5 "del" "vla" ".*vla.f90" \
+ $bp_lineno $hex "insert breakpoint at line $bp_lineno"
+mi_run_cmd
+mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
+ { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
+mi_gdb_test "570-data-evaluate-expression vla1" \
+ "570\\^done,value=\"<not allocated>\"" "evaluate not allocated vla"
+
+
+set bp_lineno [gdb_get_line_number "pvla2-not-associated"]
+mi_create_breakpoint "-t vla.f90:$bp_lineno" 6 "del" "vla" ".*vla.f90" \
+ $bp_lineno $hex "insert breakpoint at line $bp_lineno"
+mi_run_cmd
+mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
+ { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
+mi_gdb_test "580-data-evaluate-expression pvla2" \
+ "580\\^done,value=\"<not associated>\"" "evaluate not associated vla"
+
+mi_create_varobj_checked pvla2_not_associated pvla2 "<not associated>" \
+ "create local variable pvla2_not_associated"
+mi_gdb_test "581-var-info-type pvla2_not_associated" \
+ "581\\^done,type=\"<not associated>\"" \
+ "info type variable pvla2_not_associated"
+mi_gdb_test "582-var-show-format pvla2_not_associated" \
+ "582\\^done,format=\"natural\"" \
+ "show format variable pvla2_not_associated"
+mi_gdb_test "583-var-evaluate-expression pvla2_not_associated" \
+ "583\\^done,value=\"\\\[0\\\]\"" \
+ "eval variable pvla2_not_associated"
+mi_list_array_varobj_children_with_index "pvla2_not_associated" "0" "1" \
+ "real\\\(kind=4\\\)" "get children of pvla2_not_associated"
+
+
+set bp_lineno [gdb_get_line_number "pvla2-associated"]
+mi_create_breakpoint "-t vla.f90:$bp_lineno" 7 "del" "vla" ".*vla.f90" \
+ $bp_lineno $hex "insert breakpoint at line $bp_lineno"
+mi_run_cmd
+mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
+ { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
+mi_gdb_test "590-data-evaluate-expression pvla2" \
+ "590\\^done,value=\"\\(\\( 2, 2, 2, 2, 2\\) \\( 2, 2, 2, 2, 2\\) \\)\"" \
+ "evaluate associated vla"
+
+mi_create_varobj_checked pvla2_associated pvla2 \
+ "real\\\(kind=4\\\) \\\(5,2\\\)" "create local variable pvla2_associated"
+mi_gdb_test "591-var-info-type pvla2_associated" \
+ "591\\^done,type=\"real\\\(kind=4\\\) \\\(5,2\\\)\"" \
+ "info type variable pvla2_associated"
+mi_gdb_test "592-var-show-format pvla2_associated" \
+ "592\\^done,format=\"natural\"" \
+ "show format variable pvla2_associated"
+mi_gdb_test "593-var-evaluate-expression pvla2_associated" \
+ "593\\^done,value=\"\\\[2\\\]\"" \
+ "eval variable pvla2_associated"
+
+
+set bp_lineno [gdb_get_line_number "pvla2-set-to-null"]
+mi_create_breakpoint "-t vla.f90:$bp_lineno" 8 "del" "vla" ".*vla.f90" \
+ $bp_lineno $hex "insert breakpoint at line $bp_lineno"
+mi_run_cmd
+mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
+ { "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
+mi_gdb_test "600-data-evaluate-expression pvla2" \
+ "600\\^done,value=\"<not associated>\"" "evaluate vla pointer set to null"
+
+mi_gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.mi/vla.f90 b/gdb/testsuite/gdb.mi/vla.f90
new file mode 100644
index 0000000..46edad2
--- /dev/null
+++ b/gdb/testsuite/gdb.mi/vla.f90
@@ -0,0 +1,42 @@
+! Copyright 2014 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
+ real, allocatable :: vla1 (:)
+ real, target, allocatable :: vla2(:, :)
+ real, pointer :: pvla2 (:, :)
+ logical :: l
+
+ allocate (vla1 (5)) ! vla1-not-allocated
+ l = allocated(vla1) ! vla1-allocated
+
+ vla1(:) = 1
+ vla1(2) = 42 ! vla1-filled
+ vla1(4) = 24
+
+ deallocate (vla1) ! vla1-modified
+ l = allocated(vla1) ! vla1-deallocated
+
+ allocate (vla2 (5, 2))
+ vla2(:, :) = 2
+
+ pvla2 => vla2 ! pvla2-not-associated
+ l = associated(pvla2) ! pvla2-associated
+
+ pvla2(2, 1) = 42
+
+ pvla2 => null()
+ l = associated(pvla2) ! pvla2-set-to-null
+end program vla
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 08/23] vla: get dynamic array corner cases to work
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
2014-07-11 9:21 ` [V2 09/23] vla: changed string length semantic Keven Boell
2014-07-11 9:21 ` [V2 21/23] test: basic MI test for the dynamic array support Keven Boell
@ 2014-07-11 9:21 ` Keven Boell
2014-07-11 9:21 ` [V2 12/23] vla: add NEWS entry for dynamic array support Keven Boell
` (21 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:21 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
This patch does not overwrite the value type in
case it is a dynamic type. For dynamic types GDB
resolved its dynamic values in a copy of the type.
The call to deprecated_set_value_type overwrites the
resolved type with the original type, which breaks
e.g. pointer to a Fortran type, which contains a dynamic
array.
Old:
(gdb) print &vla1
(PTR TO -> ( real(kind=4) (23959136:23959184))) 0x7fffffffd490
New:
(gdb) print &vla1
(PTR TO -> ( real(kind=4) (5))) 0x7fffffffd490
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
* value.c (readjust_indirect_value_type): Add
check for dynamic types.
Change-Id: If1c6fb0bd3c1d04619e89a1b58850edb69bbfde0
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/value.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gdb/value.c b/gdb/value.c
index ff5df8d..0d53d12 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -3568,7 +3568,8 @@ readjust_indirect_value_type (struct value *value, struct type *enc_type,
struct value *original_value)
{
/* Re-adjust type. */
- deprecated_set_value_type (value, TYPE_TARGET_TYPE (original_type));
+ if (!is_dynamic_type (TYPE_TARGET_TYPE (original_type)))
+ deprecated_set_value_type (value, TYPE_TARGET_TYPE (original_type));
/* Add embedding info. */
set_value_enclosing_type (value, enc_type);
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 12/23] vla: add NEWS entry for dynamic array support
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (2 preceding siblings ...)
2014-07-11 9:21 ` [V2 08/23] vla: get dynamic array corner cases to work Keven Boell
@ 2014-07-11 9:21 ` Keven Boell
2014-07-11 9:58 ` Eli Zaretskii
2014-07-11 9:21 ` [V2 19/23] test: accessing dynamic array history values Keven Boell
` (20 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:21 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
2014-06-27 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
* NEWS: add entry for dynamic array support
in Fortran.
Change-Id: I0cb3b118e834fca36bc9047d57daf3dd915c11a9
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/NEWS | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gdb/NEWS b/gdb/NEWS
index d9a19ae..1f22fea 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,10 @@
*** Changes since GDB 7.8
+* Fortran dynamic array support: GDB has now support for
+ dynamic arrays in Fortran. It allows the user to evaluate
+ dynamic arrays like an ordinary static array.
+
*** Changes in GDB 7.8
* New command line options
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* Re: [V2 12/23] vla: add NEWS entry for dynamic array support
2014-07-11 9:21 ` [V2 12/23] vla: add NEWS entry for dynamic array support Keven Boell
@ 2014-07-11 9:58 ` Eli Zaretskii
0 siblings, 0 replies; 51+ messages in thread
From: Eli Zaretskii @ 2014-07-11 9:58 UTC (permalink / raw)
To: Keven Boell; +Cc: gdb-patches, keven.boell, sanimir.agovic
> From: Keven Boell <keven.boell@intel.com>
> Cc: keven.boell@intel.com, sanimir.agovic@intel.com
> Date: Fri, 11 Jul 2014 11:21:24 +0200
>
> 2014-06-27 Keven Boell <keven.boell@intel.com>
> Sanimir Agovic <sanimir.agovic@intel.com>
>
> * NEWS: add entry for dynamic array support
> in Fortran.
ChangeLog entries should start with a capital letter, as any English
sentence.
> +* Fortran dynamic array support: GDB has now support for
> + dynamic arrays in Fortran. It allows the user to evaluate
> + dynamic arrays like an ordinary static array.
2 comments:
. No need to say "Fortran dynamic array support", and then repeat
that in the next sentence.
. 2 spaces between sentences, please.
OK with those changes.
Thanks.
^ permalink raw reply [flat|nested] 51+ messages in thread
* [V2 19/23] test: accessing dynamic array history values.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (3 preceding siblings ...)
2014-07-11 9:21 ` [V2 12/23] vla: add NEWS entry for dynamic array support Keven Boell
@ 2014-07-11 9:21 ` Keven Boell
2014-07-11 9:21 ` [V2 05/23] vla: make field selection work with vla Keven Boell
` (19 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:21 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Tests if the history values of dynamic arrays can be
accessed and printed again with the correct values.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
testsuite/gdb.fortran/:
* vla-history.exp: New file.
Change-Id: Ib6d2d30272aefc24b6db5fa0633fe72274390e91
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/testsuite/gdb.fortran/vla-history.exp | 62 +++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
create mode 100644 gdb/testsuite/gdb.fortran/vla-history.exp
diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp b/gdb/testsuite/gdb.fortran/vla-history.exp
new file mode 100644
index 0000000..170e1eb
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-history.exp
@@ -0,0 +1,62 @@
+# Copyright 2014 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 "vla.f90"
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ {debug f90 quiet}] } {
+ return -1
+}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+# Set some breakpoints and print complete vla.
+gdb_breakpoint [gdb_get_line_number "vla1-init"]
+gdb_continue_to_breakpoint "vla1-init"
+gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
+
+gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
+gdb_continue_to_breakpoint "vla2-allocated"
+gdb_test "print vla1" " = \\( *\\( *\\( *0, *0, *0,\[()0, .\]*\\)" \
+ "print vla1 allocated"
+gdb_test "print vla2" " = \\( *\\( *\\( *0, *0, *0,\[()0, .\]*\\)" \
+ "print vla2 allocated"
+
+gdb_breakpoint [gdb_get_line_number "vla1-filled"]
+gdb_continue_to_breakpoint "vla1-filled"
+gdb_test "print vla1" \
+ " = \\( *\\( *\\( *1311, *1311, *1311,\[()1311, .\]*\\)" \
+ "print vla1 filled"
+
+# Try to access history values for full vla prints.
+gdb_test "print \$1" " = <not allocated>" "print \$1"
+gdb_test "print \$2" " = \\( *\\( *\\( *0, *0, *0,\[()0, .\]*\\)" \
+ "print \$2"
+gdb_test "print \$3" " = \\( *\\( *\\( *0, *0, *0,\[()0, .\]*\\)" \
+ "print \$3"
+gdb_test "print \$4" \
+ " = \\( *\\( *\\( *1311, *1311, *1311,\[()1311, .\]*\\)" "print \$4"
+
+gdb_breakpoint [gdb_get_line_number "vla2-filled"]
+gdb_continue_to_breakpoint "vla2-filled"
+gdb_test "print vla2(1,43,20)" " = 1311" "print vla2(1,43,20)"
+gdb_test "print vla1(1,3,8)" " = 1001" "print vla2(1,3,8)"
+
+# Try to access history values for vla values.
+gdb_test "print \$9" " = 1311" "print \$9"
+gdb_test "print \$10" " = 1001" "print \$10"
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 05/23] vla: make field selection work with vla
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (4 preceding siblings ...)
2014-07-11 9:21 ` [V2 19/23] test: accessing dynamic array history values Keven Boell
@ 2014-07-11 9:21 ` Keven Boell
2014-07-11 9:21 ` [V2 16/23] test: correct ptype of dynamic arrays in Fortran Keven Boell
` (18 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:21 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
In Fortran vla are pointers to arrays. Thus a
type only contains a pointer to such array and
we need to re-read the field to retrieve the
correct vla.
old (wrong value):
(gdb) p type_var%vla(14)
$1 = 1
new (correct value):
(gdb) p type_var%vla(14)
$1 = 42
2014-05-28 Sanimir Agovic <sanimir.agovic@intel.com>
Keven Boell <keven.boell@intel.com>
* value.c (value_primitive_field): Re-evaluate
field value to get the actual value.
Change-Id: Ic22c37324963aca520c52a80fbbd0042d1fddc05
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/value.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/gdb/value.c b/gdb/value.c
index 1d514a5..ff5df8d 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2970,13 +2970,22 @@ value_primitive_field (struct value *arg1, int offset,
v = allocate_value_lazy (type);
else
{
- v = allocate_value (type);
- value_contents_copy_raw (v, value_embedded_offset (v),
- arg1, value_embedded_offset (arg1) + offset,
- TYPE_LENGTH (type));
+ if (TYPE_DATA_LOCATION (type)
+ && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
+ v = value_at_lazy (type, value_address (arg1) + offset);
+ else
+ {
+ v = allocate_value (type);
+ value_contents_copy_raw (v, value_embedded_offset (v),
+ arg1, value_embedded_offset (arg1) + offset,
+ TYPE_LENGTH (type));
+ }
}
- v->offset = (value_offset (arg1) + offset
- + value_embedded_offset (arg1));
+
+ if (!TYPE_DATA_LOCATION (type)
+ || !TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
+ v->offset = (value_offset (arg1) + offset
+ + value_embedded_offset (arg1));
}
set_value_component_location (v, arg1);
VALUE_REGNUM (v) = VALUE_REGNUM (arg1);
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 16/23] test: correct ptype of dynamic arrays in Fortran.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (5 preceding siblings ...)
2014-07-11 9:21 ` [V2 05/23] vla: make field selection work with vla Keven Boell
@ 2014-07-11 9:21 ` Keven Boell
2014-07-11 9:21 ` [V2 01/23] dwarf: add dwarf3 DW_OP_push_object_address opcode Keven Boell
` (17 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:21 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Tests ensure that the ptype of dynamic arrays in
Fortran can be printed in GDB correctly.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
testsuite/gdb.fortran/:
* vla-ptype.exp: New file.
Change-Id: I508a0537be7cac5739a263788be89b18e84d8f8f
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/testsuite/gdb.fortran/vla-ptype.exp | 96 +++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
create mode 100644 gdb/testsuite/gdb.fortran/vla-ptype.exp
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
new file mode 100644
index 0000000..9267723
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
@@ -0,0 +1,96 @@
+# Copyright 2014 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 "vla.f90"
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ {debug f90 quiet}] } {
+ return -1
+}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+# Check the ptype of various VLA states and pointer to VLA's.
+gdb_breakpoint [gdb_get_line_number "vla1-init"]
+gdb_continue_to_breakpoint "vla1-init"
+gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not initialized"
+gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not initialized"
+gdb_test "ptype pvla" "type = <not associated>" "ptype pvla not initialized"
+gdb_test "ptype vla1(3, 6, 9)" "no such vector element because not allocated" \
+ "ptype vla1(3, 6, 9) not initialized"
+gdb_test "ptype vla2(5, 45, 20)" \
+ "no such vector element because not allocated" \
+ "ptype vla1(5, 45, 20) not initialized"
+
+gdb_breakpoint [gdb_get_line_number "vla1-allocated"]
+gdb_continue_to_breakpoint "vla1-allocated"
+gdb_test "ptype vla1" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \
+ "ptype vla1 allocated"
+
+gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
+gdb_continue_to_breakpoint "vla2-allocated"
+gdb_test "ptype vla2" "type = real\\\(kind=4\\\) \\\(7,42:50,13:35\\\)" \
+ "ptype vla2 allocated"
+
+gdb_breakpoint [gdb_get_line_number "vla1-filled"]
+gdb_continue_to_breakpoint "vla1-filled"
+gdb_test "ptype vla1" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \
+ "ptype vla1 filled"
+gdb_test "ptype vla1(3, 6, 9)" "type = real\\\(kind=4\\\)" \
+ "ptype vla1(3, 6, 9)"
+
+gdb_breakpoint [gdb_get_line_number "vla2-filled"]
+gdb_continue_to_breakpoint "vla2-filled"
+gdb_test "ptype vla2" "type = real\\\(kind=4\\\) \\\(7,42:50,13:35\\\)" \
+ "ptype vla2 filled"
+gdb_test "ptype vla2(5, 45, 20)" "type = real\\\(kind=4\\\)" \
+ "ptype vla1(5, 45, 20) filled"
+
+gdb_breakpoint [gdb_get_line_number "pvla-associated"]
+gdb_continue_to_breakpoint "pvla-associated"
+gdb_test "ptype pvla" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \
+ "ptype pvla associated"
+gdb_test "ptype pvla(3, 6, 9)" "type = real\\\(kind=4\\\)" \
+ "ptype pvla(3, 6, 9)"
+
+gdb_breakpoint [gdb_get_line_number "pvla-re-associated"]
+gdb_continue_to_breakpoint "pvla-re-associated"
+gdb_test "ptype pvla" "type = real\\\(kind=4\\\) \\\(7,42:50,13:35\\\)" \
+ "ptype pvla re-associated"
+gdb_test "ptype vla2(5, 45, 20)" "type = real\\\(kind=4\\\)" \
+ "ptype vla1(5, 45, 20) re-associated"
+
+gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
+gdb_continue_to_breakpoint "pvla-deassociated"
+gdb_test "ptype pvla" "type = <not associated>" "ptype pvla deassociated"
+gdb_test "ptype pvla(5, 45, 20)" \
+ "no such vector element because not associated" \
+ "ptype pvla(5, 45, 20) not associated"
+
+gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
+gdb_continue_to_breakpoint "vla1-deallocated"
+gdb_test "ptype vla1" "type = <not allocated>" "ptype vla1 not allocated"
+gdb_test "ptype vla1(3, 6, 9)" "no such vector element because not allocated" \
+ "ptype vla1(3, 6, 9) not allocated"
+
+gdb_breakpoint [gdb_get_line_number "vla2-deallocated"]
+gdb_continue_to_breakpoint "vla2-deallocated"
+gdb_test "ptype vla2" "type = <not allocated>" "ptype vla2 not allocated"
+gdb_test "ptype vla2(5, 45, 20)" \
+ "no such vector element because not allocated" \
+ "ptype vla2(5, 45, 20) not allocated"
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 01/23] dwarf: add dwarf3 DW_OP_push_object_address opcode
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (6 preceding siblings ...)
2014-07-11 9:21 ` [V2 16/23] test: correct ptype of dynamic arrays in Fortran Keven Boell
@ 2014-07-11 9:21 ` Keven Boell
2014-07-11 9:22 ` [V2 14/23] test: evaluate dynamic arrays using Fortran primitives Keven Boell
` (16 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:21 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
The opcode pushes the address of the object being evaluated. The semantic is
equivalent to the implicit push of the base address of a data member location.
Address fields were introduced in order to store the address to push for an
object into the baton.
2014-05-28 Sanimir Agovic <sanimir.agovic@intel.com>
Keven Boell <keven.boell@intel.com>
* dwarf2expr.c (execute_stack_op) <DW_OP_push_object_address>: New case.
* dwarf2expr.h (struct dwarf_expr_context_funcs)
<DW_OP_push_object_address>: New function pointer get_object_addr.
* dwarf2loc.c (struct dwarf_expr_baton): Add obj_address.
(dwarf_expr_get_obj_addr): New function.
(struct dwarf_expr_context_funcs): Add
dwarf_expr_get_obj_addr to dwarf_expr_ctx_funcs.
(dwarf2_evaluate_loc_desc_full): Initialize baton.obj_address.
(dwarf2_locexpr_baton_eval): Set baton.obj_address to addr.
(needs_get_obj_addr): New function.
(struct dwarf_expr_context_funcs): Add needs_get_obj_addr to
needs_frame_ctx_funcs.
Change-Id: Ied9e1ba632e8d35d0ec00cc832b96d432449fd82
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/dwarf2expr.c | 6 ++++++
gdb/dwarf2expr.h | 4 ----
gdb/dwarf2loc.c | 45 +++++++++++++++++++++++++++++++++++++++++----
gdb/dwarf2loc.h | 1 +
gdb/gdbtypes.c | 20 ++++++++++----------
5 files changed, 58 insertions(+), 18 deletions(-)
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index 36c9f66..274ba62 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -1478,6 +1478,12 @@ execute_stack_op (struct dwarf_expr_context *ctx,
}
break;
+ case DW_OP_push_object_address:
+ /* Return the address of the object we are currently observing. */
+ result = (ctx->funcs->get_object_address) (ctx->baton);
+ result_val = value_from_ulongest (address_type, result);
+ break;
+
default:
error (_("Unhandled dwarf expression opcode 0x%x"), op);
}
diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h
index 39dadf3..8cebbe8 100644
--- a/gdb/dwarf2expr.h
+++ b/gdb/dwarf2expr.h
@@ -84,12 +84,8 @@ struct dwarf_expr_context_funcs
This can throw an exception if the index is out of range. */
CORE_ADDR (*get_addr_index) (void *baton, unsigned int index);
-#if 0
- /* Not yet implemented. */
-
/* Return the `object address' for DW_OP_push_object_address. */
CORE_ADDR (*get_object_address) (void *baton);
-#endif
};
/* The location of a value. */
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index fcab9b9..eaa499e 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -306,6 +306,7 @@ struct dwarf_expr_baton
{
struct frame_info *frame;
struct dwarf2_per_cu_data *per_cu;
+ CORE_ADDR obj_address;
};
/* Helper functions for dwarf2_evaluate_loc_desc. */
@@ -1209,6 +1210,7 @@ dwarf_expr_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx,
baton_local.frame = caller_frame;
baton_local.per_cu = caller_per_cu;
+ baton_local.obj_address = 0;
saved_ctx.gdbarch = ctx->gdbarch;
saved_ctx.addr_size = ctx->addr_size;
@@ -1238,6 +1240,22 @@ dwarf_expr_get_addr_index (void *baton, unsigned int index)
return dwarf2_read_addr_index (debaton->per_cu, index);
}
+/* Callback function for get_object_address. Return the address of the VLA
+ object. */
+
+static CORE_ADDR
+dwarf_expr_get_obj_addr (void *baton)
+{
+ struct dwarf_expr_baton *debaton = baton;
+
+ gdb_assert (debaton != NULL);
+
+ if (debaton->obj_address == 0)
+ error (_("Location address is not set."));
+
+ return debaton->obj_address;
+}
+
/* VALUE must be of type lval_computed with entry_data_value_funcs. Perform
the indirect method on it, that is use its stored target value, the sole
purpose of entry_data_value_funcs.. */
@@ -2202,7 +2220,8 @@ static const struct dwarf_expr_context_funcs dwarf_expr_ctx_funcs =
dwarf_expr_dwarf_call,
dwarf_expr_get_base_type,
dwarf_expr_push_dwarf_reg_entry_value,
- dwarf_expr_get_addr_index
+ dwarf_expr_get_addr_index,
+ dwarf_expr_get_obj_addr
};
/* Evaluate a location description, starting at DATA and with length
@@ -2231,6 +2250,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
baton.frame = frame;
baton.per_cu = per_cu;
+ baton.obj_address = 0;
ctx = new_dwarf_expr_context ();
old_chain = make_cleanup_free_dwarf_expr_context (ctx);
@@ -2436,6 +2456,7 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
static int
dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
+ CORE_ADDR addr,
CORE_ADDR *valp)
{
struct dwarf_expr_context *ctx;
@@ -2451,6 +2472,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
baton.frame = get_selected_frame (NULL);
baton.per_cu = dlbaton->per_cu;
+ baton.obj_address = addr;
objfile = dwarf2_per_cu_objfile (dlbaton->per_cu);
@@ -2491,7 +2513,8 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
/* See dwarf2loc.h. */
int
-dwarf2_evaluate_property (const struct dynamic_prop *prop, CORE_ADDR *value)
+dwarf2_evaluate_property (const struct dynamic_prop *prop, CORE_ADDR address,
+ CORE_ADDR *value)
{
if (prop == NULL)
return 0;
@@ -2502,7 +2525,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, CORE_ADDR *value)
{
const struct dwarf2_property_baton *baton = prop->data.baton;
- if (dwarf2_locexpr_baton_eval (&baton->locexpr, value))
+ if (dwarf2_locexpr_baton_eval (&baton->locexpr, address, value))
{
if (baton->referenced_type)
{
@@ -2653,6 +2676,15 @@ needs_get_addr_index (void *baton, unsigned int index)
return 1;
}
+/* DW_OP_push_object_address has a frame already passed through. */
+
+static CORE_ADDR
+needs_get_obj_addr (void *baton)
+{
+ /* Nothing to do. */
+ return 1;
+}
+
/* Virtual method table for dwarf2_loc_desc_needs_frame below. */
static const struct dwarf_expr_context_funcs needs_frame_ctx_funcs =
@@ -2667,7 +2699,8 @@ static const struct dwarf_expr_context_funcs needs_frame_ctx_funcs =
needs_frame_dwarf_call,
NULL, /* get_base_type */
needs_dwarf_reg_entry_value,
- needs_get_addr_index
+ needs_get_addr_index,
+ needs_get_obj_addr
};
/* Return non-zero iff the location expression at DATA (length SIZE)
@@ -3316,6 +3349,10 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
unimplemented (op);
break;
+ case DW_OP_push_object_address:
+ unimplemented (op);
+ break;
+
case DW_OP_skip:
offset = extract_signed_integer (op_ptr, 2, byte_order);
op_ptr += 2;
diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h
index 8ad5fa9..04e2792 100644
--- a/gdb/dwarf2loc.h
+++ b/gdb/dwarf2loc.h
@@ -96,6 +96,7 @@ struct value *dwarf2_evaluate_loc_desc (struct type *type,
into VALUE, otherwise returns 0. */
int dwarf2_evaluate_property (const struct dynamic_prop *prop,
+ CORE_ADDR address,
CORE_ADDR *value);
CORE_ADDR dwarf2_read_addr_index (struct dwarf2_per_cu_data *per_cu,
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index d0c002f..08e5884 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1653,11 +1653,11 @@ is_dynamic_type (struct type *type)
return 0;
}
-/* Given a dynamic range type (dyn_range_type), return a static version
- of that type. */
+/* Given a dynamic range type (dyn_range_type) and address,
+ return a static version of that type. */
static struct type *
-resolve_dynamic_range (struct type *dyn_range_type)
+resolve_dynamic_range (struct type *dyn_range_type, CORE_ADDR addr)
{
CORE_ADDR value;
struct type *static_range_type;
@@ -1668,7 +1668,7 @@ resolve_dynamic_range (struct type *dyn_range_type)
gdb_assert (TYPE_CODE (dyn_range_type) == TYPE_CODE_RANGE);
prop = &TYPE_RANGE_DATA (dyn_range_type)->low;
- if (dwarf2_evaluate_property (prop, &value))
+ if (dwarf2_evaluate_property (prop, addr, &value))
{
low_bound.kind = PROP_CONST;
low_bound.data.const_val = value;
@@ -1680,7 +1680,7 @@ resolve_dynamic_range (struct type *dyn_range_type)
}
prop = &TYPE_RANGE_DATA (dyn_range_type)->high;
- if (dwarf2_evaluate_property (prop, &value))
+ if (dwarf2_evaluate_property (prop, addr, &value))
{
high_bound.kind = PROP_CONST;
high_bound.data.const_val = value;
@@ -1707,7 +1707,7 @@ resolve_dynamic_range (struct type *dyn_range_type)
of the associated array. */
static struct type *
-resolve_dynamic_array (struct type *type)
+resolve_dynamic_array (struct type *type, CORE_ADDR addr)
{
CORE_ADDR value;
struct type *elt_type;
@@ -1718,12 +1718,12 @@ resolve_dynamic_array (struct type *type)
elt_type = type;
range_type = check_typedef (TYPE_INDEX_TYPE (elt_type));
- range_type = resolve_dynamic_range (range_type);
+ range_type = resolve_dynamic_range (range_type, addr);
ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY)
- elt_type = resolve_dynamic_array (TYPE_TARGET_TYPE (type));
+ elt_type = resolve_dynamic_array (TYPE_TARGET_TYPE (type), addr);
else
elt_type = TYPE_TARGET_TYPE (type);
@@ -1853,11 +1853,11 @@ resolve_dynamic_type (struct type *type, CORE_ADDR addr)
}
case TYPE_CODE_ARRAY:
- resolved_type = resolve_dynamic_array (type);
+ resolved_type = resolve_dynamic_array (type, addr);
break;
case TYPE_CODE_RANGE:
- resolved_type = resolve_dynamic_range (type);
+ resolved_type = resolve_dynamic_range (type, addr);
break;
case TYPE_CODE_UNION:
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 14/23] test: evaluate dynamic arrays using Fortran primitives.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (7 preceding siblings ...)
2014-07-11 9:21 ` [V2 01/23] dwarf: add dwarf3 DW_OP_push_object_address opcode Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:22 ` [V2 02/23] dwarf: add DW_AT_data_location support Keven Boell
` (15 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Tests ensure that Fortran primitives can be evaluated
correctly when used as a dynamic array.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
testsuite/gdb.fortran/:
* vla-datatypes.f90: New file.
* vla-datatypes.exp: New file.
Change-Id: I8e82fa3833d77bfd7e9b4bdc40e3f96ce5e72da2
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/testsuite/gdb.fortran/vla-datatypes.exp | 82 +++++++++++++++++++++++++++
gdb/testsuite/gdb.fortran/vla-datatypes.f90 | 51 +++++++++++++++++
2 files changed, 133 insertions(+)
create mode 100644 gdb/testsuite/gdb.fortran/vla-datatypes.exp
create mode 100644 gdb/testsuite/gdb.fortran/vla-datatypes.f90
diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
new file mode 100644
index 0000000..20276d6
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
@@ -0,0 +1,82 @@
+# Copyright 2014 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__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+gdb_breakpoint [gdb_get_line_number "vlas-allocated"]
+gdb_continue_to_breakpoint "vlas-allocated"
+gdb_test "next" " = allocated\\\(realvla\\\)" \
+ "next to allocation status of intvla"
+gdb_test "print l" " = \\.TRUE\\." "intvla allocated"
+gdb_test "next" " = allocated\\\(complexvla\\\)" \
+ "next to allocation status of realvla"
+gdb_test "print l" " = \\.TRUE\\." "realvla allocated"
+gdb_test "next" " = allocated\\\(logicalvla\\\)" \
+ "next to allocation status of complexvla"
+gdb_test "print l" " = \\.TRUE\\." "complexvla allocated"
+gdb_test "next" " = allocated\\\(charactervla\\\)" \
+ "next to allocation status of logicalvla"
+gdb_test "print l" " = \\.TRUE\\." "logicalvla allocated"
+gdb_test "next" "intvla\\\(:,:,:\\\) = 1" \
+ "next to allocation status of charactervla"
+gdb_test "print l" " = \\.TRUE\\." "charactervla allocated"
+
+gdb_breakpoint [gdb_get_line_number "vlas-initialized"]
+gdb_continue_to_breakpoint "vlas-initialized"
+gdb_test "ptype intvla" "type = integer\\\(kind=4\\\) \\\(11,22,33\\\)" \
+ "ptype intvla"
+gdb_test "ptype realvla" "type = real\\\(kind=4\\\) \\\(11,22,33\\\)" \
+ "ptype realvla"
+gdb_test "ptype complexvla" "type = complex\\\(kind=4\\\) \\\(11,22,33\\\)" \
+ "ptype complexvla"
+gdb_test "ptype logicalvla" "type = logical\\\(kind=4\\\) \\\(11,22,33\\\)" \
+ "ptype logicalvla"
+gdb_test "ptype charactervla" "type = character\\\*1 \\\(11,22,33\\\)" \
+ "ptype charactervla"
+
+gdb_test "print intvla(5,5,5)" " = 1" "print intvla(5,5,5) (1st)"
+gdb_test "print realvla(5,5,5)" " = 3.14\\d+" \
+ "print realvla(5,5,5) (1st)"
+gdb_test "print complexvla(5,5,5)" " = \\\(2,-3\\\)" \
+ "print complexvla(5,5,5) (1st)"
+gdb_test "print logicalvla(5,5,5)" " = \\.TRUE\\." \
+ "print logicalvla(5,5,5) (1st)"
+gdb_test "print charactervla(5,5,5)" " = 'K'" \
+ "print charactervla(5,5,5) (1st)"
+
+gdb_breakpoint [gdb_get_line_number "vlas-modified"]
+gdb_continue_to_breakpoint "vlas-modified"
+gdb_test "print intvla(5,5,5)" " = 42" "print intvla(5,5,5) (2nd)"
+gdb_test "print realvla(5,5,5)" " = 4.13\\d+" \
+ "print realvla(5,5,5) (2nd)"
+gdb_test "print complexvla(5,5,5)" " = \\\(-3,2\\\)" \
+ "print complexvla(5,5,5) (2nd)"
+gdb_test "print logicalvla(5,5,5)" " = \\.FALSE\\." \
+ "print logicalvla(5,5,5) (2nd)"
+gdb_test "print charactervla(5,5,5)" " = 'X'" \
+ "print charactervla(5,5,5) (2nd)"
diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.f90 b/gdb/testsuite/gdb.fortran/vla-datatypes.f90
new file mode 100644
index 0000000..b11879a
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-datatypes.f90
@@ -0,0 +1,51 @@
+! Copyright 2014 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 2 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, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+program vla_primitives
+ integer, allocatable :: intvla(:, :, :)
+ real, allocatable :: realvla(:, :, :)
+ complex, allocatable :: complexvla(:, :, :)
+ logical, allocatable :: logicalvla(:, :, :)
+ character, allocatable :: charactervla(:, :, :)
+ logical :: l
+
+ allocate (intvla (11,22,33))
+ allocate (realvla (11,22,33))
+ allocate (complexvla (11,22,33))
+ allocate (logicalvla (11,22,33))
+ allocate (charactervla (11,22,33))
+
+ l = allocated(intvla) ! vlas-allocated
+ l = allocated(realvla)
+ l = allocated(complexvla)
+ l = allocated(logicalvla)
+ l = allocated(charactervla)
+
+ intvla(:,:,:) = 1
+ realvla(:,:,:) = 3.14
+ complexvla(:,:,:) = cmplx(2.0,-3.0)
+ logicalvla(:,:,:) = .TRUE.
+ charactervla(:,:,:) = char(75)
+
+ intvla(5,5,5) = 42 ! vlas-initialized
+ realvla(5,5,5) = 4.13
+ complexvla(5,5,5) = cmplx(-3.0,2.0)
+ logicalvla(5,5,5) = .FALSE.
+ charactervla(5,5,5) = 'X'
+
+ ! dummy statement for bp
+ l = .FALSE. ! vlas-modified
+end program vla_primitives
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 02/23] dwarf: add DW_AT_data_location support
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (8 preceding siblings ...)
2014-07-11 9:22 ` [V2 14/23] test: evaluate dynamic arrays using Fortran primitives Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:22 ` [V2 06/23] vla: reconstruct value to compute bounds of target type Keven Boell
` (14 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
An object might have a descriptor proceeding the actual value.
To point the debugger to the actually value of an object
DW_AT_data_location is used for. For example the compile may
emit for this entity:
1| int foo[N];
the following descriptor:
struct array {
size_t size;
void* data; // DW_AT_data_location describes this location
}
This allows GDB to print the actual data of an type.
E.g. for the related dwarf output of a dynamic array
using DW_AT_data_location:
<1><b1>: Abbrev Number: 8 (DW_TAG_array_type)
<b2> DW_AT_data_location: 2 byte block: 97 6
(DW_OP_push_object_address; DW_OP_deref)
2014-05-28 Sanimir Agovic <sanimir.agovic@intel.com>
Keven Boell <keven.boell@intel.com>
* dwarf2read.c (set_die_type): Parse and save DW_AT_data_location
attribute.
* gdbtypes.c (is_dynamic_type): Consider a type being dynamic if
the data location has not yet been resolved.
(resolve_dynamic_type): Evaluate data location baton
if present and save its value.
* gdbtypes.h <main_type>: Add data_location.
(TYPE_DATA_LOCATION): New macro.
(TYPE_DATA_LOCATION_ADDR): New macro.
(TYPE_DATA_LOCATION_IS_ADDRESS): New macro.
* value.c: Include dwarf2loc.h.
(value_fetch_lazy): Use data location addres to read value from
memory.
(coerce_ref): Construct new value from data location.
Change-Id: Ic633fa125efdb5e438204e4f80bb3a1c97758b12
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/dwarf2read.c | 11 +++++++++++
gdb/gdbtypes.c | 33 ++++++++++++++++++++++++++++++---
gdb/gdbtypes.h | 15 +++++++++++++++
gdb/value.c | 8 +++++++-
4 files changed, 63 insertions(+), 4 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 276d2f1..20886b0 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -21673,6 +21673,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
{
struct dwarf2_per_cu_offset_and_type **slot, ofs;
struct objfile *objfile = cu->objfile;
+ struct attribute *attr;
+ struct dynamic_prop prop;
/* For Ada types, make sure that the gnat-specific data is always
initialized (if not already set). There are a few types where
@@ -21687,6 +21689,15 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
&& !HAVE_GNAT_AUX_INFO (type))
INIT_GNAT_SPECIFIC (type);
+ /* Read DW_AT_data_location and set in type. */
+ attr = dwarf2_attr (die, DW_AT_data_location, cu);
+ if (attr_to_dynamic_prop (attr, die, cu, &prop))
+ {
+ TYPE_DATA_LOCATION (type)
+ = obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
+ *TYPE_DATA_LOCATION (type) = prop;
+ }
+
if (dwarf2_per_objfile->die_type_hash == NULL)
{
dwarf2_per_objfile->die_type_hash =
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 08e5884..f4da142 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1630,11 +1630,19 @@ is_dynamic_type (struct type *type)
{
gdb_assert (TYPE_NFIELDS (type) == 1);
- /* The array is dynamic if either the bounds are dynamic,
- or the elements it contains have a dynamic contents. */
+ /* The array is dynamic if either
+ - the bounds are dynamic,
+ - the elements it contains have a dynamic contents
+ - a data_locaton attribute was found. */
if (is_dynamic_type (TYPE_INDEX_TYPE (type)))
return 1;
- return is_dynamic_type (TYPE_TARGET_TYPE (type));
+ else if (TYPE_DATA_LOCATION (type) != NULL
+ && (TYPE_DATA_LOCATION_KIND (type) == PROP_LOCEXPR
+ || TYPE_DATA_LOCATION_KIND (type) == PROP_LOCLIST))
+ return 1;
+ else
+ return is_dynamic_type (TYPE_TARGET_TYPE (type));
+ break;
}
case TYPE_CODE_STRUCT:
@@ -1830,6 +1838,8 @@ resolve_dynamic_type (struct type *type, CORE_ADDR addr)
{
struct type *real_type = check_typedef (type);
struct type *resolved_type = type;
+ const struct dynamic_prop *prop;
+ CORE_ADDR value;
if (!is_dynamic_type (real_type))
return type;
@@ -1869,6 +1879,16 @@ resolve_dynamic_type (struct type *type, CORE_ADDR addr)
break;
}
+ /* Resolve data_location attribute. */
+ prop = TYPE_DATA_LOCATION (resolved_type);
+ if (dwarf2_evaluate_property (prop, addr, &value))
+ {
+ TYPE_DATA_LOCATION_ADDR (resolved_type) = value;
+ TYPE_DATA_LOCATION_KIND (resolved_type) = PROP_CONST;
+ }
+ else
+ TYPE_DATA_LOCATION (resolved_type) = NULL;
+
return resolved_type;
}
@@ -4078,6 +4098,13 @@ copy_type_recursive (struct objfile *objfile,
*TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
}
+ /* Copy the data location information. */
+ if (TYPE_DATA_LOCATION (type) != NULL)
+ {
+ TYPE_DATA_LOCATION (new_type) = xmalloc (sizeof (struct dynamic_prop));
+ *TYPE_DATA_LOCATION (new_type) = *TYPE_DATA_LOCATION (type);
+ }
+
/* Copy pointers to other types. */
if (TYPE_TARGET_TYPE (type))
TYPE_TARGET_TYPE (new_type) =
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index bb6352d..17b9fe0 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -725,6 +725,11 @@ struct main_type
struct func_type *func_stuff;
} type_specific;
+
+ /* * Contains a location description value for the current type. Evaluating
+ this field yields to the location of the data for an object. */
+
+ struct dynamic_prop *data_location;
};
/* * A ``struct type'' describes a particular instance of a type, with
@@ -1204,6 +1209,16 @@ extern void allocate_gnat_aux_type (struct type *);
#define TYPE_LOW_BOUND_KIND(range_type) \
TYPE_RANGE_DATA(range_type)->low.kind
+/* Attribute accessors for the type data location. */
+#define TYPE_DATA_LOCATION(thistype) \
+ TYPE_MAIN_TYPE(thistype)->data_location
+#define TYPE_DATA_LOCATION_BATON(thistype) \
+ TYPE_DATA_LOCATION (thistype)->data.baton
+#define TYPE_DATA_LOCATION_ADDR(thistype) \
+ TYPE_DATA_LOCATION (thistype)->data.const_val
+#define TYPE_DATA_LOCATION_KIND(thistype) \
+ TYPE_DATA_LOCATION (thistype)->kind
+
/* Moto-specific stuff for FORTRAN arrays. */
#define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \
diff --git a/gdb/value.c b/gdb/value.c
index 557056f..3c73683 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -3699,8 +3699,14 @@ value_fetch_lazy (struct value *val)
}
else if (VALUE_LVAL (val) == lval_memory)
{
- CORE_ADDR addr = value_address (val);
struct type *type = check_typedef (value_enclosing_type (val));
+ CORE_ADDR addr;
+
+ if (TYPE_DATA_LOCATION (type) != NULL
+ && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
+ addr = TYPE_DATA_LOCATION_ADDR (type);
+ else
+ addr = value_address (val);
if (TYPE_LENGTH (type))
read_value_memory (val, 0, value_stack (val),
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 06/23] vla: reconstruct value to compute bounds of target type
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (9 preceding siblings ...)
2014-07-11 9:22 ` [V2 02/23] dwarf: add DW_AT_data_location support Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:22 ` [V2 04/23] vla: make dynamic fortran arrays functional Keven Boell
` (13 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Printing a pointer to an array, gdb tries to print the
target type including its bounds. To follow this
semantic with vla, this patch re-constructs the value to
resolve the bounds of the target type.
2014-05-28 Sanimir Agovic <sanimir.agovic@intel.com>
Keven Boell <keven.boell@intel.com>
* typeprint.c (whatis_exp): Re-construct value to
compute bounds of target type.
* c-valprint.c (c_value_print): Re-construct value
to compute bounds of target type.
Change-Id: Ia8a25021c7cc206711ca6f359ae5566a367e3b3d
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/c-valprint.c | 11 ++++++++++-
gdb/typeprint.c | 7 +++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index f4694b0..8c45276 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -538,7 +538,16 @@ c_value_print (struct value *val, struct ui_file *stream,
{
/* normal case */
fprintf_filtered (stream, "(");
- type_print (value_type (val), "", stream, -1);
+ if (is_dynamic_type (TYPE_TARGET_TYPE (type)))
+ {
+ struct value *v;
+
+ v = value_ind (val);
+ v = value_addr (v);
+ type_print (value_type (v), "", stream, -1);
+ }
+ else
+ type_print (value_type (val), "", stream, -1);
fprintf_filtered (stream, ") ");
}
}
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 026f3a2..4c861ac 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -459,6 +459,13 @@ whatis_exp (char *exp, int show)
type = value_type (val);
+ if (TYPE_CODE (type) == TYPE_CODE_PTR)
+ if (is_dynamic_type (TYPE_TARGET_TYPE (type)))
+ {
+ val = value_addr (value_ind (val));
+ type = value_type (val);
+ }
+
get_user_print_options (&opts);
if (opts.objectprint)
{
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 04/23] vla: make dynamic fortran arrays functional.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (10 preceding siblings ...)
2014-07-11 9:22 ` [V2 06/23] vla: reconstruct value to compute bounds of target type Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:22 ` [V2 11/23] vla: add stride support to fortran arrays Keven Boell
` (12 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
This patch enables GDB to print the value of a dynamic
array (VLA) if allocated/associated in fortran. If not the
allocation status will be printed to the command line.
(gdb) p vla_not_allocated
$1 = <not allocated>
(gdb) p vla_allocated
$1 = (1, 2, 3)
(gdb) p vla_not_associated
$1 = <not associated>
(gdb) p vla_associated
$1 = (3, 2, 1)
The patch covers various locations where the allocation/
association status makes sense to print.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
* dwarf2loc.c (dwarf2_address_data_valid): New
function.
* dwarf2loc.h (dwarf2_address_data_valid): New
function.
* f-typeprint.c (f_print_type): Print allocation/
association status.
(f_type_print_varspec_suffix): Print allocation/
association status for &-operator usages.
* gdbtypes.c (create_array_type_with_stride): Add
query for valid data location.
(is_dynamic_type): Extend dynamic type detection
with allocated/associated. Add type detection for
fields.
(resolve_dynamic_range): Copy type before resolving
it as dynamic attributes need to be preserved.
(resolve_dynamic_array): Copy type before resolving
it as dynamic attributes need to be preserved. Add
resolving of allocated/associated attributes.
(resolve_dynamic_type): Add call to nested
type resolving.
(copy_type_recursive): Add allocated/associated
attributes to be copied.
(copy_type): Copy allocated/associated/data_location
as well as the fields structure if available.
* valarith.c (value_subscripted_rvalue): Print allocated/
associated status when indexing a VLA.
* valprint.c (valprint_check_validity): Print allocated/
associated status.
(val_print_not_allocated): New function.
(val_print_not_associated): New function.
* valprint.h (val_print_not_allocated): New function.
(val_print_not_associated): New function.
* value.c (set_value_component_location): Adjust the value
address for single value prints.
Change-Id: Idfb44c8a6b38008f8e2c84cb0fdb13729ec160f4
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/dwarf2loc.c | 19 ++++++++++
gdb/dwarf2loc.h | 6 ++++
gdb/f-typeprint.c | 62 ++++++++++++++++++++++-----------
gdb/gdbtypes.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++---
gdb/valarith.c | 9 ++++-
gdb/valprint.c | 40 +++++++++++++++++++++
gdb/valprint.h | 4 +++
gdb/value.c | 20 +++++++++++
8 files changed, 233 insertions(+), 27 deletions(-)
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index eaa499e..a624dac 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -2346,6 +2346,11 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0);
do_cleanups (value_chain);
+
+ /* Select right frame to correctly evaluate VLA's during a backtrace. */
+ if (is_dynamic_type (type))
+ select_frame (frame);
+
retval = value_at_lazy (type, address + byte_offset);
if (in_stack_memory)
set_value_stack (retval, 1);
@@ -2569,6 +2574,20 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, CORE_ADDR address,
return 0;
}
+/* See dwarf2loc.h. */
+
+int
+dwarf2_address_data_valid (const struct type *type)
+{
+ if (TYPE_NOT_ASSOCIATED (type))
+ return 0;
+
+ if (TYPE_NOT_ALLOCATED (type))
+ return 0;
+
+ return 1;
+}
+
\f
/* Helper functions and baton for dwarf2_loc_desc_needs_frame. */
diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h
index 04e2792..fb65c5c 100644
--- a/gdb/dwarf2loc.h
+++ b/gdb/dwarf2loc.h
@@ -102,6 +102,12 @@ int dwarf2_evaluate_property (const struct dynamic_prop *prop,
CORE_ADDR dwarf2_read_addr_index (struct dwarf2_per_cu_data *per_cu,
unsigned int addr_index);
+/* Checks if a dwarf location definition is valid.
+ Returns 1 if valid; 0 otherwise. */
+
+extern int dwarf2_address_data_valid (const struct type *type);
+
+
/* The symbol location baton types used by the DWARF-2 reader (i.e.
SYMBOL_LOCATION_BATON for a LOC_COMPUTED symbol). "struct
dwarf2_locexpr_baton" is for a symbol with a single location
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 8356aab..69e67f4 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -30,6 +30,7 @@
#include "gdbcore.h"
#include "target.h"
#include "f-lang.h"
+#include "valprint.h"
#include <string.h>
#include <errno.h>
@@ -56,6 +57,17 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream,
enum type_code code;
int demangled_args;
+ if (TYPE_NOT_ASSOCIATED (type))
+ {
+ val_print_not_associated (stream);
+ return;
+ }
+ if (TYPE_NOT_ALLOCATED (type))
+ {
+ val_print_not_allocated (stream);
+ return;
+ }
+
f_type_print_base (type, stream, show, level);
code = TYPE_CODE (type);
if ((varstring != NULL && *varstring != '\0')
@@ -170,28 +182,36 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
if (arrayprint_recurse_level == 1)
fprintf_filtered (stream, "(");
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
- f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0,
- arrayprint_recurse_level);
-
- lower_bound = f77_get_lowerbound (type);
- if (lower_bound != 1) /* Not the default. */
- fprintf_filtered (stream, "%d:", lower_bound);
-
- /* Make sure that, if we have an assumed size array, we
- print out a warning and print the upperbound as '*'. */
-
- if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
- fprintf_filtered (stream, "*");
+ if (TYPE_NOT_ASSOCIATED (type))
+ val_print_not_associated (stream);
+ else if (TYPE_NOT_ALLOCATED (type))
+ val_print_not_allocated (stream);
else
- {
- upper_bound = f77_get_upperbound (type);
- fprintf_filtered (stream, "%d", upper_bound);
- }
-
- if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
- f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0,
- arrayprint_recurse_level);
+ {
+
+ if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
+ f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0,
+ arrayprint_recurse_level);
+
+ lower_bound = f77_get_lowerbound (type);
+ if (lower_bound != 1) /* Not the default. */
+ fprintf_filtered (stream, "%d:", lower_bound);
+
+ /* Make sure that, if we have an assumed size array, we
+ print out a warning and print the upperbound as '*'. */
+
+ if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
+ fprintf_filtered (stream, "*");
+ else
+ {
+ upper_bound = f77_get_upperbound (type);
+ fprintf_filtered (stream, "%d", upper_bound);
+ }
+
+ if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
+ f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0,
+ arrayprint_recurse_level);
+ }
if (arrayprint_recurse_level == 1)
fprintf_filtered (stream, ")");
else
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index f4da142..c7c5c3b 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1003,7 +1003,8 @@ create_array_type_with_stride (struct type *result_type,
TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
TYPE_TARGET_TYPE (result_type) = element_type;
- if (has_static_range (TYPE_RANGE_DATA (range_type)))
+ if (has_static_range (TYPE_RANGE_DATA (range_type))
+ && dwarf2_address_data_valid (result_type))
{
LONGEST low_bound, high_bound;
@@ -1616,11 +1617,30 @@ stub_noname_complaint (void)
int
is_dynamic_type (struct type *type)
{
+ int index;
+
+ if (!type)
+ return 0;
+
type = check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_REF)
type = check_typedef (TYPE_TARGET_TYPE (type));
+ if (TYPE_ASSOCIATED_PROP (type))
+ return 1;
+
+ if (TYPE_ALLOCATED_PROP (type))
+ return 1;
+
+ /* Scan field types in the Fortran case for nested dynamic types.
+ This will be done only for Fortran as in the C++ case an endless recursion
+ can occur in the area of classes. */
+ if (current_language->la_language == language_fortran)
+ for (index = 0; index < TYPE_NFIELDS (type); index++)
+ if (is_dynamic_type (TYPE_FIELD_TYPE (type, index)))
+ return 1;
+
switch (TYPE_CODE (type))
{
case TYPE_CODE_RANGE:
@@ -1672,6 +1692,7 @@ resolve_dynamic_range (struct type *dyn_range_type, CORE_ADDR addr)
const struct dynamic_prop *prop;
const struct dwarf2_locexpr_baton *baton;
struct dynamic_prop low_bound, high_bound;
+ struct type *range_copy = copy_type (dyn_range_type);
gdb_assert (TYPE_CODE (dyn_range_type) == TYPE_CODE_RANGE);
@@ -1703,8 +1724,8 @@ resolve_dynamic_range (struct type *dyn_range_type, CORE_ADDR addr)
high_bound.data.const_val = 0;
}
- static_range_type = create_range_type (copy_type (dyn_range_type),
- TYPE_TARGET_TYPE (dyn_range_type),
+ static_range_type = create_range_type (range_copy,
+ TYPE_TARGET_TYPE (range_copy),
&low_bound, &high_bound);
TYPE_RANGE_DATA (static_range_type)->flag_bound_evaluated = 1;
return static_range_type;
@@ -1721,6 +1742,8 @@ resolve_dynamic_array (struct type *type, CORE_ADDR addr)
struct type *elt_type;
struct type *range_type;
struct type *ary_dim;
+ struct dynamic_prop *prop;
+ struct type *copy = copy_type (type);
gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY);
@@ -1728,14 +1751,28 @@ resolve_dynamic_array (struct type *type, CORE_ADDR addr)
range_type = check_typedef (TYPE_INDEX_TYPE (elt_type));
range_type = resolve_dynamic_range (range_type, addr);
+ prop = TYPE_ALLOCATED_PROP (type);
+ if (dwarf2_evaluate_property (prop, addr, &value))
+ {
+ TYPE_ALLOCATED_PROP (copy)->kind = PROP_CONST;
+ TYPE_ALLOCATED_PROP (copy)->data.const_val = value;
+ }
+
+ prop = TYPE_ASSOCIATED_PROP (type);
+ if (dwarf2_evaluate_property (prop, addr, &value))
+ {
+ TYPE_ASSOCIATED_PROP (copy)->kind = PROP_CONST;
+ TYPE_ASSOCIATED_PROP (copy)->data.const_val = value;
+ }
+
ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY)
- elt_type = resolve_dynamic_array (TYPE_TARGET_TYPE (type), addr);
+ elt_type = resolve_dynamic_array (TYPE_TARGET_TYPE (copy), addr);
else
elt_type = TYPE_TARGET_TYPE (type);
- return create_array_type (copy_type (type),
+ return create_array_type (copy,
elt_type,
range_type);
}
@@ -1831,6 +1868,7 @@ resolve_dynamic_struct (struct type *type, CORE_ADDR addr)
return resolved_type;
}
+
/* See gdbtypes.h */
struct type *
@@ -4105,6 +4143,20 @@ copy_type_recursive (struct objfile *objfile,
*TYPE_DATA_LOCATION (new_type) = *TYPE_DATA_LOCATION (type);
}
+ /* Copy allocated information. */
+ if (TYPE_ALLOCATED_PROP (type) != NULL)
+ {
+ TYPE_ALLOCATED_PROP (new_type) = xmalloc (sizeof (struct dynamic_prop));
+ *TYPE_ALLOCATED_PROP (new_type) = *TYPE_ALLOCATED_PROP (type);
+ }
+
+ /* Copy associated information. */
+ if (TYPE_ASSOCIATED_PROP (type) != NULL)
+ {
+ TYPE_ASSOCIATED_PROP (new_type) = xmalloc (sizeof (struct dynamic_prop));
+ *TYPE_ASSOCIATED_PROP (new_type) = *TYPE_ASSOCIATED_PROP (type);
+ }
+
/* Copy pointers to other types. */
if (TYPE_TARGET_TYPE (type))
TYPE_TARGET_TYPE (new_type) =
@@ -4151,6 +4203,44 @@ copy_type (const struct type *type)
memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type),
sizeof (struct main_type));
+ if (TYPE_ALLOCATED_PROP (type))
+ {
+ TYPE_ALLOCATED_PROP (new_type)
+ = OBSTACK_ZALLOC (&TYPE_OWNER (type).objfile->objfile_obstack,
+ struct dynamic_prop);
+ memcpy (TYPE_ALLOCATED_PROP (new_type), TYPE_ALLOCATED_PROP (type),
+ sizeof (struct dynamic_prop));
+ }
+
+ if (TYPE_ASSOCIATED_PROP (type))
+ {
+ TYPE_ASSOCIATED_PROP (new_type)
+ = OBSTACK_ZALLOC (&TYPE_OWNER (type).objfile->objfile_obstack,
+ struct dynamic_prop);
+ memcpy (TYPE_ASSOCIATED_PROP (new_type), TYPE_ASSOCIATED_PROP (type),
+ sizeof (struct dynamic_prop));
+ }
+
+ if (TYPE_DATA_LOCATION (type))
+ {
+ TYPE_DATA_LOCATION (new_type)
+ = OBSTACK_ZALLOC (&TYPE_OWNER (type).objfile->objfile_obstack,
+ struct dynamic_prop);
+ memcpy (TYPE_DATA_LOCATION (new_type), TYPE_DATA_LOCATION (type),
+ sizeof (struct dynamic_prop));
+ }
+
+ if (TYPE_NFIELDS (type))
+ {
+ int nfields = TYPE_NFIELDS (type);
+
+ TYPE_FIELDS (new_type)
+ = OBSTACK_CALLOC (&TYPE_OWNER (type).objfile->objfile_obstack,
+ nfields, struct field);
+ memcpy (TYPE_FIELDS (new_type), TYPE_FIELDS (type),
+ nfields * sizeof (struct field));
+ }
+
return new_type;
}
\f
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 4da41cb..3e7685a 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -200,7 +200,14 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
&& elt_offs >= TYPE_LENGTH (array_type)))
- error (_("no such vector element"));
+ {
+ if (TYPE_NOT_ASSOCIATED (array_type))
+ error (_("no such vector element because not associated"));
+ else if (TYPE_NOT_ALLOCATED (array_type))
+ error (_("no such vector element because not allocated"));
+ else
+ error (_("no such vector element"));
+ }
if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
v = allocate_value_lazy (elt_type);
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 8600b34..2f8eac1 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -307,6 +307,18 @@ valprint_check_validity (struct ui_file *stream,
{
CHECK_TYPEDEF (type);
+ if (TYPE_NOT_ASSOCIATED (type))
+ {
+ val_print_not_associated (stream);
+ return 0;
+ }
+
+ if (TYPE_NOT_ALLOCATED (type))
+ {
+ val_print_not_allocated (stream);
+ return 0;
+ }
+
if (TYPE_CODE (type) != TYPE_CODE_UNION
&& TYPE_CODE (type) != TYPE_CODE_STRUCT
&& TYPE_CODE (type) != TYPE_CODE_ARRAY)
@@ -362,6 +374,18 @@ val_print_invalid_address (struct ui_file *stream)
fprintf_filtered (stream, _("<invalid address>"));
}
+void
+val_print_not_allocated (struct ui_file *stream)
+{
+ fprintf_filtered (stream, _("<not allocated>"));
+}
+
+void
+val_print_not_associated (struct ui_file *stream)
+{
+ fprintf_filtered (stream, _("<not associated>"));
+}
+
/* A generic val_print that is suitable for use by language
implementations of the la_val_print method. This function can
handle most type codes, though not all, notably exception
@@ -803,12 +827,16 @@ static int
value_check_printable (struct value *val, struct ui_file *stream,
const struct value_print_options *options)
{
+ const struct type *type;
+
if (val == 0)
{
fprintf_filtered (stream, _("<address of value unknown>"));
return 0;
}
+ type = value_type (val);
+
if (value_entirely_optimized_out (val))
{
if (options->summary && !val_print_scalar_type_p (value_type (val)))
@@ -834,6 +862,18 @@ value_check_printable (struct value *val, struct ui_file *stream,
return 0;
}
+ if (TYPE_NOT_ASSOCIATED (type))
+ {
+ val_print_not_associated (stream);
+ return 0;
+ }
+
+ if (TYPE_NOT_ALLOCATED (type))
+ {
+ val_print_not_allocated (stream);
+ return 0;
+ }
+
return 1;
}
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 6698247..7a415cf 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -217,4 +217,8 @@ extern void output_command_const (const char *args, int from_tty);
extern int val_print_scalar_type_p (struct type *type);
+extern void val_print_not_allocated (struct ui_file *stream);
+
+extern void val_print_not_associated (struct ui_file *stream);
+
#endif
diff --git a/gdb/value.c b/gdb/value.c
index 3c73683..1d514a5 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -43,6 +43,7 @@
#include "tracepoint.h"
#include "cp-abi.h"
#include "user-regs.h"
+#include "dwarf2loc.h"
/* Prototypes for exported functions. */
@@ -1646,6 +1647,25 @@ set_value_component_location (struct value *component,
if (funcs->copy_closure)
component->location.computed.closure = funcs->copy_closure (whole);
}
+
+ /* For dynamic types compute the address of the component value location in
+ sub range types based on the location of the sub range type, if not being
+ an internal GDB variable or parts of it. */
+ if (VALUE_LVAL (component) != lval_internalvar
+ && VALUE_LVAL (component) != lval_internalvar_component)
+ {
+ CORE_ADDR addr;
+ struct type *type = value_type (whole);
+
+ addr = value_raw_address (component);
+
+ if (TYPE_DATA_LOCATION (type)
+ && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
+ {
+ addr = TYPE_DATA_LOCATION_ADDR (type);
+ set_value_address (component, addr);
+ }
+ }
}
\f
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 11/23] vla: add stride support to fortran arrays.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (11 preceding siblings ...)
2014-07-11 9:22 ` [V2 04/23] vla: make dynamic fortran arrays functional Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:22 ` [V2 15/23] test: dynamic arrays passed to subroutines Keven Boell
` (11 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
2014-05-28 Sanimir Agovic <sanimir.agovic@intel.com>
Keven Boell <keven.boell@intel.com>
* dwarf2read.c (read_subrange_type): Read dynamic
stride attributes.
* gdbtypes.c (create_array_type_with_stride): Add
stride support
(create_range_type): Add stride parameter.
(create_static_range_type): Pass default stride
parameter.
(resolve_dynamic_range): Evaluate stride baton.
(resolve_dynamic_type): Adjust data location with
the value of byte stride.
* gdbtypes.h (TYPE_BYTE_STRIDE): New macro.
(TYPE_BYTE_STRIDE_BLOCK): New macro.
(TYPE_BYTE_STRIDE_LOCLIST): New macro.
(TYPE_BYTE_STRIDE_KIND): New macro.
* valarith.c (value_subscripted_rvalue): Use stride.
Change-Id: I3d810c0dc37f9d9fd84dba4c764cdefc52d8501e
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/dwarf2read.c | 13 +++++++++++--
gdb/f-valprint.c | 8 +++++++-
gdb/gdbtypes.c | 39 +++++++++++++++++++++++++++++++++------
gdb/gdbtypes.h | 17 +++++++++++++++++
gdb/valarith.c | 14 +++++++++++++-
5 files changed, 81 insertions(+), 10 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 9b755b2..0aed0c9 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -14734,7 +14734,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
struct type *base_type, *orig_base_type;
struct type *range_type;
struct attribute *attr;
- struct dynamic_prop low, high;
+ struct dynamic_prop low, high, stride;
int low_default_is_valid;
int high_bound_is_count = 0;
const char *name;
@@ -14754,7 +14754,9 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
low.kind = PROP_CONST;
high.kind = PROP_CONST;
+ stride.kind = PROP_CONST;
high.data.const_val = 0;
+ stride.data.const_val = 0;
/* Set LOW_DEFAULT_IS_VALID if current language and DWARF version allow
omitting DW_AT_lower_bound. */
@@ -14787,6 +14789,13 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
break;
}
+ attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
+ if (attr)
+ if (!attr_to_dynamic_prop (attr, die, cu, &stride, NULL, 0))
+ complaint (&symfile_complaints, _("Missing DW_AT_byte_stride "
+ "- DIE at 0x%x [in module %s]"),
+ die->offset.sect_off, objfile_name (cu->objfile));
+
attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
if (attr)
attr_to_dynamic_prop (attr, die, cu, &low, NULL, 0);
@@ -14863,7 +14872,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
&& !TYPE_UNSIGNED (base_type) && (high.data.const_val & negative_mask))
high.data.const_val |= negative_mask;
- range_type = create_range_type (NULL, orig_base_type, &low, &high);
+ range_type = create_range_type (NULL, orig_base_type, &low, &high, &stride);
if (high_bound_is_count)
TYPE_RANGE_DATA (range_type)->flag_upper_bound_is_count = 1;
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 8de4070..38f32e0 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -124,8 +124,14 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
if (nss != ndimensions)
{
- size_t dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type));
+ size_t dim_size;
size_t offs = 0;
+ LONGEST byte_stride = abs (TYPE_BYTE_STRIDE (range_type));
+
+ if (byte_stride)
+ dim_size = byte_stride;
+ else
+ dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type));
for (i = lowerbound;
(i < upperbound + 1 && (*elts) < options->print_max);
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index da773f6..3f52d61 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -805,7 +805,8 @@ allocate_stub_method (struct type *type)
struct type *
create_range_type (struct type *result_type, struct type *index_type,
const struct dynamic_prop *low_bound,
- const struct dynamic_prop *high_bound)
+ const struct dynamic_prop *high_bound,
+ const struct dynamic_prop *stride)
{
if (result_type == NULL)
result_type = alloc_type_copy (index_type);
@@ -820,6 +821,7 @@ create_range_type (struct type *result_type, struct type *index_type,
TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
TYPE_RANGE_DATA (result_type)->low = *low_bound;
TYPE_RANGE_DATA (result_type)->high = *high_bound;
+ TYPE_RANGE_DATA (result_type)->stride = *stride;
if (low_bound->kind == PROP_CONST && low_bound->data.const_val >= 0)
TYPE_UNSIGNED (result_type) = 1;
@@ -841,7 +843,7 @@ struct type *
create_static_range_type (struct type *result_type, struct type *index_type,
LONGEST low_bound, LONGEST high_bound)
{
- struct dynamic_prop low, high;
+ struct dynamic_prop low, high, stride;
low.kind = PROP_CONST;
low.data.const_val = low_bound;
@@ -849,7 +851,11 @@ create_static_range_type (struct type *result_type, struct type *index_type,
high.kind = PROP_CONST;
high.data.const_val = high_bound;
- result_type = create_range_type (result_type, index_type, &low, &high);
+ stride.kind = PROP_CONST;
+ stride.data.const_val = 0;
+
+ result_type = create_range_type (result_type, index_type,
+ &low, &high, &stride);
return result_type;
}
@@ -1006,16 +1012,21 @@ create_array_type_with_stride (struct type *result_type,
if (has_static_range (TYPE_RANGE_DATA (range_type))
&& dwarf2_address_data_valid (result_type))
{
- LONGEST low_bound, high_bound;
+ LONGEST low_bound, high_bound, byte_stride;
if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
low_bound = high_bound = 0;
CHECK_TYPEDEF (element_type);
+
+ byte_stride = abs (TYPE_BYTE_STRIDE (range_type));
+
/* Be careful when setting the array length. Ada arrays can be
empty arrays with the high_bound being smaller than the low_bound.
In such cases, the array length should be zero. */
if (high_bound < low_bound)
TYPE_LENGTH (result_type) = 0;
+ else if (byte_stride > 0)
+ TYPE_LENGTH (result_type) = byte_stride * (high_bound - low_bound + 1);
else if (bit_stride > 0)
TYPE_LENGTH (result_type) =
(bit_stride * (high_bound - low_bound + 1) + 7) / 8;
@@ -1702,7 +1713,7 @@ resolve_dynamic_range (struct type *dyn_range_type, CORE_ADDR addr)
struct type *static_range_type;
const struct dynamic_prop *prop;
const struct dwarf2_locexpr_baton *baton;
- struct dynamic_prop low_bound, high_bound;
+ struct dynamic_prop low_bound, high_bound, stride;
struct type *range_copy = copy_type (dyn_range_type);
gdb_assert (TYPE_CODE (dyn_range_type) == TYPE_CODE_RANGE);
@@ -1734,10 +1745,17 @@ resolve_dynamic_range (struct type *dyn_range_type, CORE_ADDR addr)
high_bound.kind = PROP_UNDEFINED;
high_bound.data.const_val = 0;
}
+
+ prop = &TYPE_RANGE_DATA (dyn_range_type)->stride;
+ if (dwarf2_evaluate_property (prop, addr, &value))
+ {
+ stride.kind = PROP_CONST;
+ stride.data.const_val = value;
+ }
static_range_type = create_range_type (range_copy,
TYPE_TARGET_TYPE (range_copy),
- &low_bound, &high_bound);
+ &low_bound, &high_bound, &stride);
TYPE_RANGE_DATA (static_range_type)->flag_bound_evaluated = 1;
return static_range_type;
}
@@ -1940,6 +1958,15 @@ resolve_dynamic_type (struct type *type, CORE_ADDR addr)
prop = TYPE_DATA_LOCATION (resolved_type);
if (dwarf2_evaluate_property (prop, addr, &value))
{
+ struct type *range_type = TYPE_INDEX_TYPE (resolved_type);
+
+ /* Adjust the data location with the value of byte stride if set, which
+ can describe the separation between successive elements along the
+ dimension. */
+ if (TYPE_BYTE_STRIDE (range_type) < 0)
+ value += (TYPE_HIGH_BOUND (range_type) - TYPE_LOW_BOUND (range_type))
+ * TYPE_BYTE_STRIDE (range_type);
+
TYPE_DATA_LOCATION_ADDR (resolved_type) = value;
TYPE_DATA_LOCATION_KIND (resolved_type) = PROP_CONST;
}
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index bf0ae81..5818f79 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -670,6 +670,10 @@ struct main_type
struct dynamic_prop high;
+ /* * Stride of range. */
+
+ struct dynamic_prop stride;
+
/* True if HIGH range bound contains the number of elements in the
subrange. This affects how the final hight bound is computed. */
@@ -1220,6 +1224,15 @@ extern void allocate_gnat_aux_type (struct type *);
TYPE_RANGE_DATA(range_type)->high.kind
#define TYPE_LOW_BOUND_KIND(range_type) \
TYPE_RANGE_DATA(range_type)->low.kind
+#define TYPE_BYTE_STRIDE(range_type) \
+ TYPE_RANGE_DATA(range_type)->stride.data.const_val
+#define TYPE_BYTE_STRIDE_BLOCK(range_type) \
+ TYPE_RANGE_DATA(range_type)->stride.data.locexpr
+#define TYPE_BYTE_STRIDE_LOCLIST(range_type) \
+ TYPE_RANGE_DATA(range_type)->stride.data.loclist
+#define TYPE_BYTE_STRIDE_KIND(range_type) \
+ TYPE_RANGE_DATA(range_type)->stride.kind
+
/* Attribute accessors for the type data location. */
#define TYPE_DATA_LOCATION(thistype) \
@@ -1251,6 +1264,9 @@ extern void allocate_gnat_aux_type (struct type *);
TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
#define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
+#define TYPE_ARRAY_STRIDE_IS_UNDEFINED(arraytype) \
+ (TYPE_BYTE_STRIDE(TYPE_INDEX_TYPE(arraytype)) == 0)
+
#define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
(TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
@@ -1719,6 +1735,7 @@ extern struct type *create_array_type_with_stride
extern struct type *create_range_type (struct type *, struct type *,
const struct dynamic_prop *,
+ const struct dynamic_prop *,
const struct dynamic_prop *);
extern struct type *create_array_type (struct type *, struct type *,
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 3e7685a..fb9671b 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -195,9 +195,21 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
struct type *array_type = check_typedef (value_type (array));
struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
unsigned int elt_size = TYPE_LENGTH (elt_type);
- unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
+ unsigned int elt_offs = longest_to_int (index - lowerbound);
+ LONGEST elt_stride = TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (array_type));
struct value *v;
+ if (elt_stride > 0)
+ elt_offs *= elt_stride;
+ else if (elt_stride < 0)
+ {
+ int offs = (elt_offs + 1) * elt_stride;
+
+ elt_offs = TYPE_LENGTH (array_type) + offs;
+ }
+ else
+ elt_offs *= elt_size;
+
if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
&& elt_offs >= TYPE_LENGTH (array_type)))
{
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 15/23] test: dynamic arrays passed to subroutines.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (12 preceding siblings ...)
2014-07-11 9:22 ` [V2 11/23] vla: add stride support to fortran arrays Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-08-01 20:11 ` Jan Kratochvil
2014-07-11 9:22 ` [V2 22/23] test: test sizeof for dynamic fortran arrays Keven Boell
` (10 subsequent siblings)
24 siblings, 1 reply; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Tests dynamic arrays passed to subroutines and handled
in different ways inside the routine.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
testsuite/gdb.fortran/:
* vla-sub.f90: New file.
* vla-ptype-sub.exp: New file.
* vla-value-sub-arbitrary.exp: New file.
* vla-value-sub-finish.exp: New file.
* vla-value-sub.exp: New file.
Change-Id: I76db950fbacbf15b1f5e887bfd164eb8f85c55d1
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/testsuite/gdb.fortran/vla-ptype-sub.exp | 87 +++++++++++++++++++
gdb/testsuite/gdb.fortran/vla-sub.f90 | 82 ++++++++++++++++++
.../gdb.fortran/vla-value-sub-arbitrary.exp | 35 ++++++++
gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp | 49 +++++++++++
gdb/testsuite/gdb.fortran/vla-value-sub.exp | 90 ++++++++++++++++++++
5 files changed, 343 insertions(+)
create mode 100644 gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
create mode 100644 gdb/testsuite/gdb.fortran/vla-sub.f90
create mode 100644 gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
create mode 100644 gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
create mode 100644 gdb/testsuite/gdb.fortran/vla-value-sub.exp
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
new file mode 100644
index 0000000..2ee2914
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
@@ -0,0 +1,87 @@
+# Copyright 2014 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 "vla-sub.f90"
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ {debug f90 quiet}] } {
+ return -1
+}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+# Pass fixed array to function and handle them as vla in function.
+gdb_breakpoint [gdb_get_line_number "not-filled"]
+gdb_continue_to_breakpoint "not-filled (1st)"
+gdb_test "ptype array1" "type = integer\\\(kind=4\\\) \\\(42,42\\\)" \
+ "ptype array1 (passed fixed)"
+gdb_test "ptype array2" "type = real\\\(kind=4\\\) \\\(42,42,42\\\)" \
+ "ptype array2 (passed fixed)"
+gdb_test "ptype array1(40, 10)" "type = integer\\\(kind=4\\\)" \
+ "ptype array1(40, 10) (passed fixed)"
+gdb_test "ptype array2(13, 11, 5)" "type = real\\\(kind=4\\\)" \
+ "ptype array2(13, 11, 5) (passed fixed)"
+
+# Pass sub arrays to function and handle them as vla in function.
+gdb_continue_to_breakpoint "not-filled (2nd)"
+gdb_test "ptype array1" "type = integer\\\(kind=4\\\) \\\(6,6\\\)" \
+ "ptype array1 (passed sub-array)"
+gdb_test "ptype array2" "type = real\\\(kind=4\\\) \\\(6,6,6\\\)" \
+ "ptype array2 (passed sub-array)"
+gdb_test "ptype array1(3, 3)" "type = integer\\\(kind=4\\\)" \
+ "ptype array1(3, 3) (passed sub-array)"
+gdb_test "ptype array2(4, 4, 4)" "type = real\\\(kind=4\\\)" \
+ "ptype array2(4, 4, 4) (passed sub-array)"
+
+# Check ptype outside of bounds. This should not crash GDB.
+gdb_test "ptype array1(100, 100)" "no such vector element" \
+ "ptype array1(100, 100) subarray do not crash (passed sub-array)"
+gdb_test "ptype array2(100, 100, 100)" "no such vector element" \
+ "ptype array2(100, 100, 100) subarray do not crash (passed sub-array)"
+
+# Pass vla to function.
+gdb_continue_to_breakpoint "not-filled (3rd)"
+gdb_test "ptype array1" "type = integer\\\(kind=4\\\) \\\(20,20\\\)" \
+ "ptype array1 (passed vla)"
+gdb_test "ptype array2" "type = real\\\(kind=4\\\) \\\(10,10,10\\\)" \
+ "ptype array2 (passed vla)"
+gdb_test "ptype array1(3, 3)" "type = integer\\\(kind=4\\\)" \
+ "ptype array1(3, 3) (passed vla)"
+gdb_test "ptype array2(4, 4, 4)" "type = real\\\(kind=4\\\)" \
+ "ptype array2(4, 4, 4) (passed vla)"
+
+# Check ptype outside of bounds. This should not crash GDB.
+gdb_test "ptype array1(100, 100)" "no such vector element" \
+ "ptype array1(100, 100) VLA do not crash (passed vla)"
+gdb_test "ptype array2(100, 100, 100)" "no such vector element" \
+ "ptype array2(100, 100, 100) VLA do not crash (passed vla)"
+
+# Pass fixed array to function and handle it as VLA of arbitrary length in
+# function.
+gdb_breakpoint [gdb_get_line_number "end-of-bar"]
+gdb_continue_to_breakpoint "end-of-bar"
+gdb_test "ptype array1" \
+ "type = (PTR TO -> \\( )?integer(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?" \
+ "ptype array1 (arbitrary length)"
+gdb_test "ptype array2" \
+ "type = (PTR TO -> \\( )?integer(\\(kind=4\\)|\\*4) \\(4:9,10:\\*\\)\\)?" \
+ "ptype array2 (arbitrary length)"
+gdb_test "ptype array1(100)" "type = integer\\\(kind=4\\\)" \
+ "ptype array1(100) (arbitrary length)"
+gdb_test "ptype array2(4,100)" "type = integer\\\(kind=4\\\)" \
+ "ptype array2(4,100) (arbitrary length)"
diff --git a/gdb/testsuite/gdb.fortran/vla-sub.f90 b/gdb/testsuite/gdb.fortran/vla-sub.f90
new file mode 100644
index 0000000..8c2c9ff
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-sub.f90
@@ -0,0 +1,82 @@
+! Copyright 2014 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 2 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, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+!
+! Original file written by Jakub Jelinek <jakub@redhat.com> and
+! Jan Kratochvil <jan.kratochvil@redhat.com>.
+! Modified for the GDB testcases by Keven Boell <keven.boell@intel.com>.
+
+subroutine foo (array1, array2)
+ integer :: array1 (:, :)
+ real :: array2 (:, :, :)
+
+ array1(:,:) = 5 ! not-filled
+ array1(1, 1) = 30
+
+ array2(:,:,:) = 6 ! array1-filled
+ array2(:,:,:) = 3
+ array2(1,1,1) = 30
+ array2(3,3,3) = 90 ! array2-almost-filled
+end subroutine
+
+subroutine bar (array1, array2)
+ integer :: array1 (*)
+ integer :: array2 (4:9, 10:*)
+
+ array1(5:10) = 1311
+ array1(7) = 1
+ array1(100) = 100
+ array2(4,10) = array1(7)
+ array2(4,100) = array1(7)
+ return ! end-of-bar
+end subroutine
+
+program vla_sub
+ interface
+ subroutine foo (array1, array2)
+ integer :: array1 (:, :)
+ real :: array2 (:, :, :)
+ end subroutine
+ end interface
+ interface
+ subroutine bar (array1, array2)
+ integer :: array1 (*)
+ integer :: array2 (4:9, 10:*)
+ end subroutine
+ end interface
+
+ real, allocatable :: vla1 (:, :, :)
+ integer, allocatable :: vla2 (:, :)
+
+ ! used for subroutine
+ integer :: sub_arr1(42, 42)
+ real :: sub_arr2(42, 42, 42)
+ integer :: sub_arr3(42)
+
+ sub_arr1(:,:) = 1 ! vla2-deallocated
+ sub_arr2(:,:,:) = 2
+ sub_arr3(:) = 3
+
+ call foo(sub_arr1, sub_arr2)
+ call foo(sub_arr1(5:10, 5:10), sub_arr2(10:15,10:15,10:15))
+
+ allocate (vla1 (10,10,10))
+ allocate (vla2 (20,20))
+ vla1(:,:,:) = 1311
+ vla2(:,:) = 42
+ call foo(vla2, vla1)
+
+ call bar(sub_arr3, sub_arr1)
+end program vla_sub
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
new file mode 100644
index 0000000..fd11adb
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
@@ -0,0 +1,35 @@
+# Copyright 2014 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 "vla-sub.f90"
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ {debug f90 quiet}] } {
+ return -1
+}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+# Check VLA with arbitary length and check that elements outside of
+# bounds of the passed VLA can be accessed correctly.
+gdb_breakpoint [gdb_get_line_number "end-of-bar"]
+gdb_continue_to_breakpoint "end-of-bar"
+gdb_test "p array1(42)" " = 3" "print arbitary array1(42)"
+gdb_test "p array1(100)" " = 100" "print arbitary array1(100)"
+gdb_test "p array2(4,10)" " = 1" "print arbitary array2(4,10)"
+gdb_test "p array2(4,100)" " = 1" "print arbitary array2(4,100)"
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
new file mode 100644
index 0000000..a163617
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
@@ -0,0 +1,49 @@
+# Copyright 2014 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 "vla-sub.f90"
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ {debug f90 quiet}] } {
+ return -1
+}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+# "up" works with GCC but other Fortran compilers may copy the values into the
+# outer function only on the exit of the inner function.
+# We need both variants as depending on the arch we optionally may still be
+# executing the caller line or not after `finish'.
+
+gdb_breakpoint [gdb_get_line_number "array2-almost-filled"]
+gdb_continue_to_breakpoint "array2-almost-filled"
+gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
+ "print array2 in foo after it was filled"
+gdb_test "print array2(2,1,1)=20" " = 20" \
+ "set array(2,2,2) to 20 in subroutine"
+gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
+ "print array2 in foo after it was mofified in debugger"
+
+gdb_test "finish" \
+ ".*foo\\\(sub_arr1\\\(5:10, 5:10\\\), sub_arr2\\\(10:15,10:15,10:15\\\)\\\)" \
+ "finish function"
+gdb_test "p sub_arr1(5, 7)" " = 5" "sub_arr1(5, 7) after finish"
+gdb_test "p sub_arr1(1, 1)" " = 30" "sub_arr1(1, 1) after finish"
+gdb_test "p sub_arr2(1, 1, 1)" " = 30" "sub_arr2(1, 1, 1) after finish"
+gdb_test "p sub_arr2(2, 1, 1)" " = 20" "sub_arr2(2, 1, 1) after finish"
+
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
new file mode 100644
index 0000000..848f9d7
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
@@ -0,0 +1,90 @@
+# Copyright 2014 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 "vla-sub.f90"
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ {debug f90 quiet}] } {
+ return -1
+}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+# Check the values of VLA's in subroutine can be evaluated correctly
+
+# Try to access values from a fixed array handled as VLA in subroutine.
+gdb_breakpoint [gdb_get_line_number "not-filled"]
+gdb_continue_to_breakpoint "not-filled (1st)"
+gdb_test "print array1" " = \\(\[()1, .\]*\\)" \
+ "print passed array1 in foo (passed fixed array)"
+
+gdb_breakpoint [gdb_get_line_number "array1-filled"]
+gdb_continue_to_breakpoint "array1-filled (1st)"
+gdb_test "print array1(5, 7)" " = 5" \
+ "print array1(5, 7) after filled in foo (passed fixed array)"
+gdb_test "print array1(1, 1)" " = 30" \
+ "print array1(1, 1) after filled in foo (passed fixed array)"
+
+gdb_breakpoint [gdb_get_line_number "array2-almost-filled"]
+gdb_continue_to_breakpoint "array2-almost-filled (1st)"
+gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
+ "print array2 in foo after it was filled (passed fixed array)"
+gdb_test "print array2(2,1,1)=20" " = 20" \
+ "set array(2,2,2) to 20 in subroutine (passed fixed array)"
+gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
+ "print array2 in foo after it was mofified in debugger (passed fixed array)"
+
+
+# Try to access values from a fixed sub-array handled as VLA in subroutine.
+gdb_continue_to_breakpoint "not-filled (2nd)"
+gdb_test "print array1" " = \\(\[()5, .\]*\\)" \
+ "print passed array1 in foo (passed sub-array)"
+
+gdb_continue_to_breakpoint "array1-filled (2nd)"
+gdb_test "print array1(5, 5)" " = 5" \
+ "print array1(5, 5) after filled in foo (passed sub-array)"
+gdb_test "print array1(1, 1)" " = 30" \
+ "print array1(1, 1) after filled in foo (passed sub-array)"
+
+gdb_continue_to_breakpoint "array2-almost-filled (2nd)"
+gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
+ "print array2 in foo after it was filled (passed sub-array)"
+gdb_test "print array2(2,1,1)=20" " = 20" \
+ "set array(2,2,2) to 20 in subroutine (passed sub-array)"
+gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
+ "print array2 in foo after it was mofified in debugger (passed sub-array)"
+
+
+# Try to access values from a VLA passed to subroutine.
+gdb_continue_to_breakpoint "not-filled (3rd)"
+gdb_test "print array1" " = \\(\[()42, .\]*\\)" \
+ "print passed array1 in foo (passed vla)"
+
+gdb_continue_to_breakpoint "array1-filled (3rd)"
+gdb_test "print array1(5, 5)" " = 5" \
+ "print array1(5, 5) after filled in foo (passed vla)"
+gdb_test "print array1(1, 1)" " = 30" \
+ "print array1(1, 1) after filled in foo (passed vla)"
+
+gdb_continue_to_breakpoint "array2-almost-filled (3rd)"
+gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
+ "print array2 in foo after it was filled (passed vla)"
+gdb_test "print array2(2,1,1)=20" " = 20" \
+ "set array(2,2,2) to 20 in subroutine (passed vla)"
+gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
+ "print array2 in foo after it was mofified in debugger (passed vla)"
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* Re: [V2 15/23] test: dynamic arrays passed to subroutines.
2014-07-11 9:22 ` [V2 15/23] test: dynamic arrays passed to subroutines Keven Boell
@ 2014-08-01 20:11 ` Jan Kratochvil
2014-08-07 6:58 ` Keven Boell
0 siblings, 1 reply; 51+ messages in thread
From: Jan Kratochvil @ 2014-08-01 20:11 UTC (permalink / raw)
To: Keven Boell; +Cc: gdb-patches, sanimir.agovic
On Fri, 11 Jul 2014 11:21:27 +0200, Keven Boell wrote:
> +gdb_test "finish" \
> + ".*foo\\\(sub_arr1\\\(5:10, 5:10\\\), sub_arr2\\\(10:15,10:15,10:15\\\)\\\)" \
> + "finish function"
This testcase FAILs for 32-bit targets (FAILs on both x86_64-m32 and on i686).
finish^M
Run till exit from #0 foo (array1=..., array2=...) at gdb/testsuite/gdb.fortran/vla-sub.f90:31^M
0x08048aa5 in vla_sub () at gdb/testsuite/gdb.fortran/vla-sub.f90:72^M
72 call foo(sub_arr1, sub_arr2)^M
(gdb) FAIL: gdb.fortran/vla-value-sub-finish.exp: finish function
8048aa0: e8 e9 fb ff ff call 804868e <foo_>
8048aa5: 83 c4 08 add $0x8,%esp
/home/jkratoch/redhat/gdb-vla-intel-noasan/gdb/testsuite/./gdb.fortran/vla-sub.f90:73
finish^M
Run till exit from #0 foo (array1=..., array2=...) at gdb/testsuite/gdb.fortran/vla-sub.f90:31^M
vla_sub () at gdb/testsuite/gdb.fortran/vla-sub.f90:73^M
73 call foo(sub_arr1(5:10, 5:10), sub_arr2(10:15,10:15,10:15))^M
(gdb) PASS: gdb.fortran/vla-value-sub-finish.exp: finish function
400d34: e8 23 fb ff ff callq 40085c <foo_>
/home/jkratoch/redhat/gdb-vla-intel-noasan/gdb/testsuite/./gdb.fortran/vla-sub.f90:73
It is understandable, "finish" command sometimes ends up on the caller source
line and sometimes on the next source line after caller, depending on the arch.
At least this way it happens on:
gcc-4.9.1-2.fc21.1.x86_64
Thanks,
Jan
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [V2 15/23] test: dynamic arrays passed to subroutines.
2014-08-01 20:11 ` Jan Kratochvil
@ 2014-08-07 6:58 ` Keven Boell
2014-08-12 6:56 ` Keven Boell
0 siblings, 1 reply; 51+ messages in thread
From: Keven Boell @ 2014-08-07 6:58 UTC (permalink / raw)
To: Jan Kratochvil, Keven Boell; +Cc: gdb-patches, sanimir.agovic
On 01.08.2014 22:11, Jan Kratochvil wrote:
> On Fri, 11 Jul 2014 11:21:27 +0200, Keven Boell wrote:
>> +gdb_test "finish" \
>> + ".*foo\\\(sub_arr1\\\(5:10, 5:10\\\), sub_arr2\\\(10:15,10:15,10:15\\\)\\\)" \
>> + "finish function"
>
> This testcase FAILs for 32-bit targets (FAILs on both x86_64-m32 and on i686).
>
> finish^M
> Run till exit from #0 foo (array1=..., array2=...) at gdb/testsuite/gdb.fortran/vla-sub.f90:31^M
> 0x08048aa5 in vla_sub () at gdb/testsuite/gdb.fortran/vla-sub.f90:72^M
> 72 call foo(sub_arr1, sub_arr2)^M
> (gdb) FAIL: gdb.fortran/vla-value-sub-finish.exp: finish function
> 8048aa0: e8 e9 fb ff ff call 804868e <foo_>
> 8048aa5: 83 c4 08 add $0x8,%esp
> /home/jkratoch/redhat/gdb-vla-intel-noasan/gdb/testsuite/./gdb.fortran/vla-sub.f90:73
>
> finish^M
> Run till exit from #0 foo (array1=..., array2=...) at gdb/testsuite/gdb.fortran/vla-sub.f90:31^M
> vla_sub () at gdb/testsuite/gdb.fortran/vla-sub.f90:73^M
> 73 call foo(sub_arr1(5:10, 5:10), sub_arr2(10:15,10:15,10:15))^M
> (gdb) PASS: gdb.fortran/vla-value-sub-finish.exp: finish function
> 400d34: e8 23 fb ff ff callq 40085c <foo_>
> /home/jkratoch/redhat/gdb-vla-intel-noasan/gdb/testsuite/./gdb.fortran/vla-sub.f90:73
>
> It is understandable, "finish" command sometimes ends up on the caller source
> line and sometimes on the next source line after caller, depending on the arch.
>
> At least this way it happens on:
> gcc-4.9.1-2.fc21.1.x86_64
>
I'll try to get this reproduced with gcc 4.9.x. I was using 4.8.
>
> Thanks,
> Jan
>
Thanks,
Keven
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [V2 15/23] test: dynamic arrays passed to subroutines.
2014-08-07 6:58 ` Keven Boell
@ 2014-08-12 6:56 ` Keven Boell
0 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-08-12 6:56 UTC (permalink / raw)
To: Jan Kratochvil, Keven Boell; +Cc: gdb-patches, sanimir.agovic
On 07.08.2014 08:58, Keven Boell wrote:
> On 01.08.2014 22:11, Jan Kratochvil wrote:
>> On Fri, 11 Jul 2014 11:21:27 +0200, Keven Boell wrote:
>>> +gdb_test "finish" \
>>> + ".*foo\\\(sub_arr1\\\(5:10, 5:10\\\), sub_arr2\\\(10:15,10:15,10:15\\\)\\\)" \
>>> + "finish function"
>>
>> This testcase FAILs for 32-bit targets (FAILs on both x86_64-m32 and on i686).
>>
>> finish^M
>> Run till exit from #0 foo (array1=..., array2=...) at gdb/testsuite/gdb.fortran/vla-sub.f90:31^M
>> 0x08048aa5 in vla_sub () at gdb/testsuite/gdb.fortran/vla-sub.f90:72^M
>> 72 call foo(sub_arr1, sub_arr2)^M
>> (gdb) FAIL: gdb.fortran/vla-value-sub-finish.exp: finish function
>> 8048aa0: e8 e9 fb ff ff call 804868e <foo_>
>> 8048aa5: 83 c4 08 add $0x8,%esp
>> /home/jkratoch/redhat/gdb-vla-intel-noasan/gdb/testsuite/./gdb.fortran/vla-sub.f90:73
>>
>> finish^M
>> Run till exit from #0 foo (array1=..., array2=...) at gdb/testsuite/gdb.fortran/vla-sub.f90:31^M
>> vla_sub () at gdb/testsuite/gdb.fortran/vla-sub.f90:73^M
>> 73 call foo(sub_arr1(5:10, 5:10), sub_arr2(10:15,10:15,10:15))^M
>> (gdb) PASS: gdb.fortran/vla-value-sub-finish.exp: finish function
>> 400d34: e8 23 fb ff ff callq 40085c <foo_>
>> /home/jkratoch/redhat/gdb-vla-intel-noasan/gdb/testsuite/./gdb.fortran/vla-sub.f90:73
>>
>> It is understandable, "finish" command sometimes ends up on the caller source
>> line and sometimes on the next source line after caller, depending on the arch.
>>
>> At least this way it happens on:
>> gcc-4.9.1-2.fc21.1.x86_64
>>
>
> I'll try to get this reproduced with gcc 4.9.x. I was using 4.8.
I was able to reproduce the fail on FC20 with gcc 4.9 and adapted the
regular expression accordingly.
You can find an update on https://github.com/intel-gdb/vla/tree/vla-fortran
>
>>
>> Thanks,
>> Jan
>>
>
> Thanks,
> Keven
>
Keven
^ permalink raw reply [flat|nested] 51+ messages in thread
* [V2 22/23] test: test sizeof for dynamic fortran arrays.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (13 preceding siblings ...)
2014-07-11 9:22 ` [V2 15/23] test: dynamic arrays passed to subroutines Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:22 ` [V2 20/23] test: dynamic string evaluations Keven Boell
` (9 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Tests sizeof output of dynamic arrays in various states.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
testsuite/gdb.fortran/:
* vla-sizeof.exp: New file.
Change-Id: I68d81d03ff2daa32ab87d2750873652d684e7389
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/testsuite/gdb.fortran/vla-sizeof.exp | 46 ++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
create mode 100644 gdb/testsuite/gdb.fortran/vla-sizeof.exp
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
new file mode 100644
index 0000000..6053c17
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
@@ -0,0 +1,46 @@
+# Copyright 2014 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 "vla.f90"
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ {debug f90 quiet}] } {
+ return -1
+}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+# Try to access values in non allocated VLA
+gdb_breakpoint [gdb_get_line_number "vla1-init"]
+gdb_continue_to_breakpoint "vla1-init"
+gdb_test "print sizeof(vla1)" " = 0" "print sizeof non-allocated vla1"
+
+# Try to access value in allocated VLA
+gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
+gdb_continue_to_breakpoint "vla2-allocated"
+gdb_test "print sizeof(vla1)" " = 4000" "print sizeof allocated vla1"
+
+# Try to access values in undefined pointer to VLA (dangling)
+gdb_breakpoint [gdb_get_line_number "vla1-filled"]
+gdb_continue_to_breakpoint "vla1-filled"
+gdb_test "print sizeof(pvla)" " = 0" "print sizeof non-associated pvla"
+
+# Try to access values in pointer to VLA and compare them
+gdb_breakpoint [gdb_get_line_number "pvla-associated"]
+gdb_continue_to_breakpoint "pvla-associated"
+gdb_test "print sizeof(pvla)" " = 4000" "print sizeof associated pvla"
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 20/23] test: dynamic string evaluations.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (14 preceding siblings ...)
2014-07-11 9:22 ` [V2 22/23] test: test sizeof for dynamic fortran arrays Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:22 ` [V2 07/23] vla: use value constructor instead of raw-buffer manipulation Keven Boell
` (8 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Tests various dynamic string evaluations. Dynamic strings
will be handled internally the same way as dynamic arrays.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
testsuite/gdb.fortran/:
* vla-strings.f90: New file.
* vla-strings.exp: New file.
Change-Id: Ib2f3dded2fbc5f0a9684050c5cfa22a450e18358
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/testsuite/gdb.fortran/vla-strings.exp | 104 +++++++++++++++++++++++++++++
gdb/testsuite/gdb.fortran/vla-strings.f90 | 40 +++++++++++
2 files changed, 144 insertions(+)
create mode 100644 gdb/testsuite/gdb.fortran/vla-strings.exp
create mode 100644 gdb/testsuite/gdb.fortran/vla-strings.f90
diff --git a/gdb/testsuite/gdb.fortran/vla-strings.exp b/gdb/testsuite/gdb.fortran/vla-strings.exp
new file mode 100644
index 0000000..7fc1734
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-strings.exp
@@ -0,0 +1,104 @@
+# Copyright 2014 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__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"]
+gdb_continue_to_breakpoint "var_char-allocated-1"
+gdb_test "print var_char" \
+ " = \\(PTR TO -> \\( character\\*10 \\)\\) ${hex}" \
+ "print var_char after allocated first time"
+gdb_test "print *var_char" \
+ " = '\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000\\\\000'" \
+ "print *var_char after allocated first time"
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*10 \\)" \
+ "whatis var_char first time"
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*10 \\)" \
+ "ptype var_char first time"
+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"
+gdb_test "print var_char" \
+ " = \\(PTR TO -> \\( character\\*3 \\)\\) ${hex}" \
+ "print var_char after filled first time"
+gdb_test "print *var_char" " = 'foo'" \
+ "print *var_char after filled first time"
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*3 \\)" \
+ "whatis var_char after filled first time"
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*3 \\)" \
+ "ptype var_char after filled first time"
+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"
+gdb_test "print var_char" \
+ " = \\(PTR TO -> \\( character\\*6 \\)\\) ${hex}" \
+ "print var_char after allocated second time"
+gdb_test "print *var_char" " = 'foobar'" \
+ "print *var_char after allocated second time"
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*6 \\)" \
+ "whatis var_char second time"
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*6 \\)" \
+ "ptype var_char second time"
+
+gdb_breakpoint [gdb_get_line_number "var_char-empty"]
+gdb_continue_to_breakpoint "var_char-empty"
+gdb_test "print var_char" \
+ " = \\(PTR TO -> \\( character\\*0 \\)\\) ${hex}" \
+ "print var_char after set empty"
+gdb_test "print *var_char" " = \"\"" "print *var_char after set empty"
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*0 \\)" \
+ "whatis var_char after set empty"
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*0 \\)" \
+ "ptype var_char after set empty"
+
+gdb_breakpoint [gdb_get_line_number "var_char-allocated-3"]
+gdb_continue_to_breakpoint "var_char-allocated-3"
+gdb_test "print var_char" \
+ " = \\(PTR TO -> \\( character\\*21 \\)\\) ${hex}" \
+ "print var_char after allocated third time"
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*21 \\)" \
+ "whatis var_char after allocated third time"
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*21 \\)" \
+ "ptype var_char after allocated third time"
+
+gdb_breakpoint [gdb_get_line_number "var_char_p-associated"]
+gdb_continue_to_breakpoint "var_char_p-associated"
+gdb_test "print var_char_p" \
+ " = \\(PTR TO -> \\( character\\*7 \\)\\) ${hex}" \
+ "print var_char_p after associated"
+gdb_test "print *var_char_p" " = 'johndoe'" \
+ "print *var_char_ after associated"
+gdb_test "whatis var_char_p" "type = PTR TO -> \\( character\\*7 \\)" \
+ "whatis var_char_p after associated"
+gdb_test "ptype var_char_p" "type = PTR TO -> \\( character\\*7 \\)" \
+ "ptype var_char_p after associated"
diff --git a/gdb/testsuite/gdb.fortran/vla-strings.f90 b/gdb/testsuite/gdb.fortran/vla-strings.f90
new file mode 100644
index 0000000..0a1d522
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-strings.f90
@@ -0,0 +1,40 @@
+! Copyright 2014 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 2 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, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+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
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 07/23] vla: use value constructor instead of raw-buffer manipulation
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (15 preceding siblings ...)
2014-07-11 9:22 ` [V2 20/23] test: dynamic string evaluations Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:22 ` [V2 18/23] test: dynamic arrays passed to functions Keven Boell
` (7 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Instead of pre-computing indices into a fortran array re-use
the value_* interfaces to subscript a fortran array.
2014-05-28 Sanimir Agovic <sanimir.agovic@intel.com>
Keven Boell <keven.boell@intel.com>
* f-valprint.c (f77_create_arrayprint_offset_tbl): Remove
function.
(F77_DIM_SIZE, F77_DIM_OFFSET): Remove macro.
(f77_print_array_1): Use value_subscript to subscript a
value array.
(f77_print_array): Remove call to f77_create_arrayprint_offset_tbl.
(f_val_print): Use value_field to construct a field value.
Change-Id: I09e482ceb114eeb0f08b5528d40ffed8d79119ee
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/f-valprint.c | 118 ++++++++++++++++++------------------------------------
1 file changed, 39 insertions(+), 79 deletions(-)
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 408c8cc..8de4070 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -39,8 +39,6 @@
extern void _initialize_f_valprint (void);
static void info_common_command (char *, int);
-static void f77_create_arrayprint_offset_tbl (struct type *,
- struct ui_file *);
static void f77_get_dynamic_length_of_aggregate (struct type *);
int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
@@ -48,15 +46,6 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
/* Array which holds offsets to be applied to get a row's elements
for a given array. Array also holds the size of each subarray. */
-/* The following macro gives us the size of the nth dimension, Where
- n is 1 based. */
-
-#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1])
-
-/* The following gives us the offset for row n where n is 1-based. */
-
-#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0])
-
int
f77_get_lowerbound (struct type *type)
{
@@ -114,47 +103,6 @@ f77_get_dynamic_length_of_aggregate (struct type *type)
* TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type)));
}
-/* Function that sets up the array offset,size table for the array
- type "type". */
-
-static void
-f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
-{
- struct type *tmp_type;
- int eltlen;
- int ndimen = 1;
- int upper, lower;
-
- tmp_type = type;
-
- while (TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY)
- {
- upper = f77_get_upperbound (tmp_type);
- lower = f77_get_lowerbound (tmp_type);
-
- F77_DIM_SIZE (ndimen) = upper - lower + 1;
-
- tmp_type = TYPE_TARGET_TYPE (tmp_type);
- ndimen++;
- }
-
- /* Now we multiply eltlen by all the offsets, so that later we
- can print out array elements correctly. Up till now we
- know an offset to apply to get the item but we also
- have to know how much to add to get to the next item. */
-
- ndimen--;
- eltlen = TYPE_LENGTH (tmp_type);
- F77_DIM_OFFSET (ndimen) = eltlen;
- while (--ndimen > 0)
- {
- eltlen *= F77_DIM_SIZE (ndimen + 1);
- F77_DIM_OFFSET (ndimen) = eltlen;
- }
-}
-
-
-
/* Actual function which prints out F77 arrays, Valaddr == address in
the superior. Address == the address in the inferior. */
@@ -167,41 +115,56 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
const struct value_print_options *options,
int *elts)
{
+ struct type *range_type = TYPE_INDEX_TYPE (check_typedef (type));
+ CORE_ADDR addr = address + embedded_offset;
+ LONGEST lowerbound, upperbound;
int i;
+ get_discrete_bounds (range_type, &lowerbound, &upperbound);
+
if (nss != ndimensions)
{
- for (i = 0;
- (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max);
+ size_t dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type));
+ size_t offs = 0;
+
+ for (i = lowerbound;
+ (i < upperbound + 1 && (*elts) < options->print_max);
i++)
{
+ struct value *subarray = value_from_contents_and_address
+ (TYPE_TARGET_TYPE (type), value_contents_for_printing_const (val)
+ + offs, addr + offs);
+
fprintf_filtered (stream, "( ");
- f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
- valaddr,
- embedded_offset + i * F77_DIM_OFFSET (nss),
- address,
- stream, recurse, val, options, elts);
+ f77_print_array_1 (nss + 1, ndimensions, value_type (subarray),
+ value_contents_for_printing (subarray),
+ value_embedded_offset (subarray),
+ value_address (subarray),
+ stream, recurse, subarray, options, elts);
+ offs += dim_size;
fprintf_filtered (stream, ") ");
}
- if (*elts >= options->print_max && i < F77_DIM_SIZE (nss))
+ if (*elts >= options->print_max && i < upperbound)
fprintf_filtered (stream, "...");
}
else
{
- for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
+ for (i = lowerbound; i < upperbound + 1 && (*elts) < options->print_max;
i++, (*elts)++)
{
- val_print (TYPE_TARGET_TYPE (type),
- valaddr,
- embedded_offset + i * F77_DIM_OFFSET (ndimensions),
- address, stream, recurse,
- val, options, current_language);
+ struct value *elt = value_subscript ((struct value *)val, i);
+
+ val_print (value_type (elt),
+ value_contents_for_printing (elt),
+ value_embedded_offset (elt),
+ value_address (elt), stream, recurse,
+ elt, options, current_language);
- if (i != (F77_DIM_SIZE (nss) - 1))
+ if (i != upperbound)
fprintf_filtered (stream, ", ");
if ((*elts == options->print_max - 1)
- && (i != (F77_DIM_SIZE (nss) - 1)))
+ && (i != upperbound))
fprintf_filtered (stream, "...");
}
}
@@ -228,12 +191,6 @@ f77_print_array (struct type *type, const gdb_byte *valaddr,
Type node corrupt! F77 arrays cannot have %d subscripts (%d Max)"),
ndimensions, MAX_FORTRAN_DIMS);
- /* Since F77 arrays are stored column-major, we set up an
- offset table to get at the various row's elements. The
- offset table contains entries for both offset and subarray size. */
-
- f77_create_arrayprint_offset_tbl (type, stream);
-
f77_print_array_1 (1, ndimensions, type, valaddr, embedded_offset,
address, stream, recurse, val, options, &elts);
}
@@ -378,12 +335,15 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
fprintf_filtered (stream, "( ");
for (index = 0; index < TYPE_NFIELDS (type); index++)
{
- int offset = TYPE_FIELD_BITPOS (type, index) / 8;
+ struct value *field = value_field
+ ((struct value *)original_value, index);
+
+ val_print (value_type (field),
+ value_contents_for_printing (field),
+ value_embedded_offset (field),
+ value_address (field), stream, recurse + 1,
+ field, options, current_language);
- val_print (TYPE_FIELD_TYPE (type, index), valaddr,
- embedded_offset + offset,
- address, stream, recurse + 1,
- original_value, options, current_language);
if (index != TYPE_NFIELDS (type) - 1)
fputs_filtered (", ", stream);
}
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 18/23] test: dynamic arrays passed to functions.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (16 preceding siblings ...)
2014-07-11 9:22 ` [V2 07/23] vla: use value constructor instead of raw-buffer manipulation Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:22 ` [V2 13/23] test: basic tests for dynamic array evaluations in Fortran Keven Boell
` (6 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Tests for dynamic arrays passed to functions
and returned from functions.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
testsuite/gdb.fortran/:
* vla-func.f90: New file.
* vla-func.exp: New file.
Change-Id: Ic3eb212f35f599e4c10a284c23125491653b17df
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/testsuite/gdb.fortran/vla-func.exp | 61 +++++++++++++++++++++++++++
gdb/testsuite/gdb.fortran/vla-func.f90 | 71 ++++++++++++++++++++++++++++++++
2 files changed, 132 insertions(+)
create mode 100644 gdb/testsuite/gdb.fortran/vla-func.exp
create mode 100644 gdb/testsuite/gdb.fortran/vla-func.f90
diff --git a/gdb/testsuite/gdb.fortran/vla-func.exp b/gdb/testsuite/gdb.fortran/vla-func.exp
new file mode 100644
index 0000000..f0f236b
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-func.exp
@@ -0,0 +1,61 @@
+# Copyright 2014 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
+}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+# Check VLA passed to first Fortran function.
+gdb_breakpoint [gdb_get_line_number "func1-vla-passed"]
+gdb_continue_to_breakpoint "func1-vla-passed"
+gdb_test "print vla" " = \\( *\\( *22, *22, *22,\[()22, .\]*\\)" \
+ "print vla (func1)"
+gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10,10\\\)" \
+ "ptype vla (func1)"
+
+gdb_breakpoint [gdb_get_line_number "func1-vla-modified"]
+gdb_continue_to_breakpoint "func1-vla-modified"
+gdb_test "print vla(5,5)" " = 55" "print vla(5,5) (func1)"
+gdb_test "print vla(7,7)" " = 77" "print vla(5,5) (func1)"
+
+# Check if the values are correct after returning from func1
+gdb_breakpoint [gdb_get_line_number "func1-returned"]
+gdb_continue_to_breakpoint "func1-returned"
+gdb_test "print ret" " = .TRUE." "print ret after func1 returned"
+
+# Check VLA passed to second Fortran function
+gdb_breakpoint [gdb_get_line_number "func2-vla-passed"]
+gdb_continue_to_breakpoint "func2-vla-passed"
+gdb_test "print vla" \
+ " = \\\(44, 44, 44, 44, 44, 44, 44, 44, 44, 44\\\)" \
+ "print vla (func2)"
+gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10\\\)" \
+ "ptype vla (func2)"
+
+# Check if the returned VLA has the correct values and ptype.
+gdb_breakpoint [gdb_get_line_number "func2-returned"]
+gdb_continue_to_breakpoint "func2-returned"
+gdb_test "print vla3" " = \\\(1, 2, 44, 4, 44, 44, 44, 8, 44, 44\\\)" \
+ "print vla3 (after func2)"
+gdb_test "ptype vla3" "type = integer\\\(kind=4\\\) \\\(10\\\)" \
+ "ptype vla3 (after func2)"
diff --git a/gdb/testsuite/gdb.fortran/vla-func.f90 b/gdb/testsuite/gdb.fortran/vla-func.f90
new file mode 100644
index 0000000..4f45da1
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-func.f90
@@ -0,0 +1,71 @@
+! Copyright 2014 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 2 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, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+logical function func1 (vla)
+ implicit none
+ integer, allocatable :: vla (:, :)
+ func1 = allocated(vla)
+ vla(5,5) = 55 ! func1-vla-passed
+ vla(7,7) = 77
+ return ! func1-vla-modified
+end function func1
+
+function func2(vla)
+ implicit none
+ integer :: vla (:)
+ integer :: func2(size(vla))
+ integer :: k
+
+ vla(1) = 1 ! func2-vla-passed
+ vla(2) = 2
+ vla(4) = 4
+ vla(8) = 8
+
+ func2 = vla
+end function func2
+
+program vla_func
+ implicit none
+ interface
+ logical function func1 (vla)
+ integer :: vla (:, :)
+ end function
+ end interface
+ interface
+ function func2 (vla)
+ integer :: vla (:)
+ integer func2(size(vla))
+ end function
+ end interface
+
+ logical :: ret
+ integer, allocatable :: vla1 (:, :)
+ integer, allocatable :: vla2 (:)
+ integer, allocatable :: vla3 (:)
+
+ ret = .FALSE.
+
+ allocate (vla1 (10,10))
+ vla1(:,:) = 22
+
+ allocate (vla2 (10))
+ vla2(:) = 44
+
+ ret = func1(vla1)
+ vla3 = func2(vla2) ! func1-returned
+
+ ret = .TRUE. ! func2-returned
+end program vla_func
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 13/23] test: basic tests for dynamic array evaluations in Fortran.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (17 preceding siblings ...)
2014-07-11 9:22 ` [V2 18/23] test: dynamic arrays passed to functions Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:22 ` [V2 17/23] test: evaluating allocation/association status Keven Boell
` (5 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Tests ensure that values of Fortran dynamic arrays
can be evaluated correctly in various ways and states.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
testsuite/gdb.fortran/:
* vla.f90: New file.
* vla-value.exp: New file.
Change-Id: I0229c3b58f72ae89c2ee42d1219e4538cb6bf023
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/testsuite/gdb.fortran/vla-value.exp | 148 +++++++++++++++++++++++++++++++
gdb/testsuite/gdb.fortran/vla.f90 | 56 ++++++++++++
2 files changed, 204 insertions(+)
create mode 100644 gdb/testsuite/gdb.fortran/vla-value.exp
create mode 100644 gdb/testsuite/gdb.fortran/vla.f90
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
new file mode 100644
index 0000000..d7b8a1e
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -0,0 +1,148 @@
+# Copyright 2014 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 "vla.f90"
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ {debug f90 quiet}] } {
+ return -1
+}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+# Try to access values in non allocated VLA
+gdb_breakpoint [gdb_get_line_number "vla1-init"]
+gdb_continue_to_breakpoint "vla1-init"
+gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
+gdb_test "print &vla1" \
+ " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not allocated>\\\)\\\)\\\) $hex" \
+ "print non-allocated &vla1"
+gdb_test "print vla1(1,1,1)" "no such vector element because not allocated" \
+ "print member in non-allocated vla1 (1)"
+gdb_test "print vla1(101,202,303)" \
+ "no such vector element because not allocated" \
+ "print member in non-allocated vla1 (2)"
+gdb_test "print vla1(5,2,18)=1" "no such vector element because not allocated" \
+ "set member in non-allocated vla1"
+
+# Try to access value in allocated VLA
+gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
+gdb_continue_to_breakpoint "vla2-allocated"
+gdb_test "next" "\\d+(\\t|\\s)+vla1\\\(3, 6, 9\\\) = 42" \
+ "step over value assignment of vla1"
+gdb_test "print &vla1" \
+ " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(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)"
+gdb_test "print vla1(9, 9, 9) = 999" " = 999" \
+ "print allocated vla1(9,9,9)=1"
+
+# Try to access values in allocated VLA after specific assignment
+gdb_breakpoint [gdb_get_line_number "vla1-filled"]
+gdb_continue_to_breakpoint "vla1-filled"
+gdb_test "print vla1(3, 6, 9)" " = 42" \
+ "print allocated vla1(3,6,9) after specific assignment (filled)"
+gdb_test "print vla1(1, 3, 8)" " = 1001" \
+ "print allocated vla1(1,3,8) after specific assignment (filled)"
+gdb_test "print vla1(9, 9, 9)" " = 999" \
+ "print allocated vla1(9,9,9) after assignment in debugger (filled)"
+
+# Try to access values in undefined pointer to VLA (dangling)
+gdb_test "print pvla" " = <not associated>" "print undefined pvla"
+gdb_test "print &pvla" \
+ " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not associated>\\\)\\\)\\\) $hex" \
+ "print non-associated &pvla"
+gdb_test "print pvla(1, 3, 8)" "no such vector element because not associated" \
+ "print undefined pvla(1,3,8)"
+
+# Try to access values in pointer to VLA and compare them
+gdb_breakpoint [gdb_get_line_number "pvla-associated"]
+gdb_continue_to_breakpoint "pvla-associated"
+gdb_test "print &pvla" \
+ " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(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)"
+gdb_test "print pvla(9, 9, 9)" " = 999" "print associated pvla(9,9,9)"
+
+# Fill values to VLA using pointer and check
+gdb_breakpoint [gdb_get_line_number "pvla-re-associated"]
+gdb_continue_to_breakpoint "pvla-re-associated"
+gdb_test "print pvla(5, 45, 20)" \
+ " = 1" "print pvla(5, 45, 20) after filled using pointer"
+gdb_test "print vla2(5, 45, 20)" \
+ " = 1" "print vla2(5, 45, 20) after filled using pointer"
+gdb_test "print pvla(7, 45, 14)" " = 2" \
+ "print pvla(7, 45, 14) after filled using pointer"
+gdb_test "print vla2(7, 45, 14)" " = 2" \
+ "print vla2(7, 45, 14) after filled using pointer"
+
+# Try to access values of deassociated VLA pointer
+gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
+gdb_continue_to_breakpoint "pvla-deassociated"
+gdb_test "print pvla(5, 45, 20)" \
+ "no such vector element because not associated" \
+ "print pvla(5, 45, 20) after deassociated"
+gdb_test "print pvla(7, 45, 14)" \
+ "no such vector element because not associated" \
+ "print pvla(7, 45, 14) after dissasociated"
+gdb_test "print pvla" " = <not associated>" \
+ "print vla1 after deassociated"
+
+# Try to access values of deallocated VLA
+gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
+gdb_continue_to_breakpoint "vla1-deallocated"
+gdb_test "print vla1(3, 6, 9)" "no such vector element because not allocated" \
+ "print allocated vla1(3,6,9) after specific assignment (deallocated)"
+gdb_test "print vla1(1, 3, 8)" "no such vector element because not allocated" \
+ "print allocated vla1(1,3,8) after specific assignment (deallocated)"
+gdb_test "print vla1(9, 9, 9)" "no such vector element because not allocated" \
+ "print allocated vla1(9,9,9) after assignment in debugger (deallocated)"
+
+
+# Try to assign VLA to user variable
+clean_restart ${testfile}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
+gdb_continue_to_breakpoint "vla2-allocated"
+gdb_test "next" "\\d+.*vla1\\(3, 6, 9\\) = 42" "next (1)"
+
+gdb_test_no_output "set \$myvar = vla1" "set \$myvar = vla1"
+gdb_test "print \$myvar" \
+ " = \\( *\\( *\\( *1311, *1311, *1311,\[()1311, .\]*\\)" \
+ "print \$myvar set to vla1"
+
+gdb_test "next" "\\d+.*vla1\\(1, 3, 8\\) = 1001" "next (2)"
+gdb_test "print \$myvar(3,6,9)" " = 1311" "print \$myvar(3,6,9)"
+
+gdb_breakpoint [gdb_get_line_number "pvla-associated"]
+gdb_continue_to_breakpoint "pvla-associated"
+gdb_test_no_output "set \$mypvar = pvla" "set \$mypvar = pvla"
+gdb_test "print \$mypvar(1,3,8)" " = 1001" "print \$mypvar(1,3,8)"
+
+# deallocate pointer and make sure user defined variable still has the
+# right value.
+gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
+gdb_continue_to_breakpoint "pvla-deassociated"
+gdb_test "print \$mypvar(1,3,8)" " = 1001" \
+ "print \$mypvar(1,3,8) after deallocated"
diff --git a/gdb/testsuite/gdb.fortran/vla.f90 b/gdb/testsuite/gdb.fortran/vla.f90
new file mode 100644
index 0000000..73425f3
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla.f90
@@ -0,0 +1,56 @@
+! Copyright 2014 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
+ real, target, allocatable :: vla1 (:, :, :)
+ real, target, allocatable :: vla2 (:, :, :)
+ real, target, allocatable :: vla3 (:, :)
+ real, pointer :: pvla (:, :, :)
+ logical :: l
+
+ allocate (vla1 (10,10,10)) ! vla1-init
+ l = allocated(vla1)
+
+ allocate (vla2 (1:7,42:50,13:35)) ! vla1-allocated
+ l = allocated(vla2)
+
+ vla1(:, :, :) = 1311 ! vla2-allocated
+ vla1(3, 6, 9) = 42
+ vla1(1, 3, 8) = 1001
+ vla1(6, 2, 7) = 13
+
+ vla2(:, :, :) = 1311 ! vla1-filled
+ vla2(5, 45, 20) = 42
+
+ pvla => vla1 ! vla2-filled
+ l = associated(pvla)
+
+ pvla => vla2 ! pvla-associated
+ l = associated(pvla)
+ pvla(5, 45, 20) = 1
+ pvla(7, 45, 14) = 2
+
+ pvla => null() ! pvla-re-associated
+ l = associated(pvla)
+
+ deallocate (vla1) ! pvla-deassociated
+ l = allocated(vla1)
+
+ deallocate (vla2) ! vla1-deallocated
+ l = allocated(vla2)
+
+ allocate (vla3 (2,2)) ! vla2-deallocated
+ vla3(:,:) = 13
+end program vla
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 17/23] test: evaluating allocation/association status
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (18 preceding siblings ...)
2014-07-11 9:22 ` [V2 13/23] test: basic tests for dynamic array evaluations in Fortran Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:22 ` [V2 03/23] vla: introduce allocated/associated flags Keven Boell
` (4 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Tests ensure that dynamic arrays in different states
(allocated/associated) can be evaluated.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
testsuite/gdb.fortran/:
* vla-alloc-assoc.exp: New file.
Change-Id: I6950473c3f1724ebf5c7b037706186b2cd6af5f0
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp | 65 +++++++++++++++++++++++++
1 file changed, 65 insertions(+)
create mode 100644 gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
new file mode 100644
index 0000000..20607c3
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
@@ -0,0 +1,65 @@
+# Copyright 2014 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 "vla.f90"
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
+ {debug f90 quiet}] } {
+ return -1
+}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+# Check the association status of various types of VLA's
+# and pointer to VLA's.
+gdb_breakpoint [gdb_get_line_number "vla1-allocated"]
+gdb_continue_to_breakpoint "vla1-allocated"
+gdb_test "print l" " = \\.TRUE\\." \
+ "print vla1 allocation status (allocated)"
+
+gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
+gdb_continue_to_breakpoint "vla2-allocated"
+gdb_test "print l" " = \\.TRUE\\." \
+ "print vla2 allocation status (allocated)"
+
+gdb_breakpoint [gdb_get_line_number "pvla-associated"]
+gdb_continue_to_breakpoint "pvla-associated"
+gdb_test "print l" " = \\.TRUE\\." \
+ "print pvla associated status (associated)"
+
+gdb_breakpoint [gdb_get_line_number "pvla-re-associated"]
+gdb_continue_to_breakpoint "pvla-re-associated"
+gdb_test "print l" " = \\.TRUE\\." \
+ "print pvla associated status (re-associated)"
+
+gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
+gdb_continue_to_breakpoint "pvla-deassociated"
+gdb_test "print l" " = \\.FALSE\\." \
+ "print pvla allocation status (deassociated)"
+
+gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
+gdb_continue_to_breakpoint "vla1-deallocated"
+gdb_test "print l" " = \\.FALSE\\." \
+ "print vla1 allocation status (deallocated)"
+gdb_test "print vla1" " = <not allocated>" \
+ "print deallocated vla1"
+
+gdb_breakpoint [gdb_get_line_number "vla2-deallocated"]
+gdb_continue_to_breakpoint "vla2-deallocated"
+gdb_test "print l" " = \\.FALSE\\." "print vla2 deallocated"
+gdb_test "print vla2" " = <not allocated>" "print deallocated vla2"
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 03/23] vla: introduce allocated/associated flags
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (19 preceding siblings ...)
2014-07-11 9:22 ` [V2 17/23] test: evaluating allocation/association status Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:22 ` [V2 23/23] test: stride support for dynamic arrays Keven Boell
` (3 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Fortran 90 provide types whose values may be dynamically
allocated or associated with a variable under explicit
program control. The purpose of this commit is to read
allocated/associated DWARF tags and store them to the
main_type.
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
* dwarf2read.c (set_die_type): Add reading of
allocated/associated flags.
* gdbtypes.h (struct main_type): Add allocated/
associated dwarf2_prop attributes.
(TYPE_ALLOCATED_PROP): New macro.
(TYPE_ASSOCIATED_PROP): New macro.
(TYPE_NOT_ALLOCATED): New macro.
(TYPE_NOT_ASSOCIATED): New macro.
Change-Id: I44a9e21986de16de061b3ea2a7689f1bfa28ed2e
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/dwarf2read.c | 28 ++++++++++++++++++++++++++++
gdb/gdbtypes.h | 26 ++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 20886b0..f612cd8 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -21689,6 +21689,34 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
&& !HAVE_GNAT_AUX_INFO (type))
INIT_GNAT_SPECIFIC (type);
+ /* Read DW_AT_allocated and set in type. */
+ attr = dwarf2_attr (die, DW_AT_allocated, cu);
+ if (attr_form_is_block (attr))
+ {
+ struct dynamic_prop prop;
+
+ if (attr_to_dynamic_prop (attr, die, cu, &prop))
+ {
+ TYPE_ALLOCATED_PROP (type)
+ = obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
+ *TYPE_ALLOCATED_PROP (type) = prop;
+ }
+ }
+
+ /* Read DW_AT_associated and set in type. */
+ attr = dwarf2_attr (die, DW_AT_associated, cu);
+ if (attr_form_is_block (attr))
+ {
+ struct dynamic_prop prop;
+
+ if (attr_to_dynamic_prop (attr, die, cu, &prop))
+ {
+ TYPE_ASSOCIATED_PROP (type)
+ = obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
+ *TYPE_ASSOCIATED_PROP (type) = prop;
+ }
+ }
+
/* Read DW_AT_data_location and set in type. */
attr = dwarf2_attr (die, DW_AT_data_location, cu);
if (attr_to_dynamic_prop (attr, die, cu, &prop))
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 17b9fe0..bf0ae81 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -730,6 +730,18 @@ struct main_type
this field yields to the location of the data for an object. */
struct dynamic_prop *data_location;
+
+ /* Structure for DW_AT_allocated.
+ The presence of this attribute indicates that the object of the type
+ can be allocated/deallocated. The value can be a dwarf expression,
+ reference, or a constant. */
+ struct dynamic_prop *allocated;
+
+ /* Structure for DW_AT_associated.
+ The presence of this attribute indicated that the object of the type
+ can be associated. The value can be a dwarf expression,
+ reference, or a constant. */
+ struct dynamic_prop *associated;
};
/* * A ``struct type'' describes a particular instance of a type, with
@@ -1218,6 +1230,20 @@ extern void allocate_gnat_aux_type (struct type *);
TYPE_DATA_LOCATION (thistype)->data.const_val
#define TYPE_DATA_LOCATION_KIND(thistype) \
TYPE_DATA_LOCATION (thistype)->kind
+#define TYPE_ALLOCATED_PROP(thistype) TYPE_MAIN_TYPE(thistype)->allocated
+#define TYPE_ASSOCIATED_PROP(thistype) TYPE_MAIN_TYPE(thistype)->associated
+
+/* Allocated status of type object. If set to non-zero it means the object
+ is allocated. A zero value means it is not allocated. */
+#define TYPE_NOT_ALLOCATED(t) (TYPE_ALLOCATED_PROP (t) \
+ && TYPE_ALLOCATED_PROP (t)->kind == PROP_CONST \
+ && !TYPE_ALLOCATED_PROP (t)->data.const_val)
+
+/* Associated status of type object. If set to non-zero it means the object
+ is associated. A zero value means it is not associated. */
+#define TYPE_NOT_ASSOCIATED(t) (TYPE_ASSOCIATED_PROP (t) \
+ && TYPE_ASSOCIATED_PROP (t)->kind == PROP_CONST \
+ && !TYPE_ASSOCIATED_PROP (t)->data.const_val)
/* Moto-specific stuff for FORTRAN arrays. */
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 23/23] test: stride support for dynamic arrays.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (20 preceding siblings ...)
2014-07-11 9:22 ` [V2 03/23] vla: introduce allocated/associated flags Keven Boell
@ 2014-07-11 9:22 ` Keven Boell
2014-07-11 9:28 ` [V2 10/23] vla: get Fortran dynamic strings working Keven Boell
` (2 subsequent siblings)
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:22 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
Tests the usage of stride values in dynamic arrays.
2014-05-28 Sanimir Agovic <sanimir.agovic@intel.com>
Keven Boell <keven.boell@intel.com>
testsuite/gdb.fortran/:
* vla-stride.exp: New file.
* vla-stride.f90: New file.
Change-Id: Ic4f68cf97046cc9f5f3664fe4c12d2b7528c22ee
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/testsuite/gdb.fortran/vla-stride.exp | 44 ++++++++++++++++++++++++++++++
gdb/testsuite/gdb.fortran/vla-stride.f90 | 30 ++++++++++++++++++++
2 files changed, 74 insertions(+)
create mode 100644 gdb/testsuite/gdb.fortran/vla-stride.exp
create mode 100644 gdb/testsuite/gdb.fortran/vla-stride.f90
diff --git a/gdb/testsuite/gdb.fortran/vla-stride.exp b/gdb/testsuite/gdb.fortran/vla-stride.exp
new file mode 100644
index 0000000..35f585d
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-stride.exp
@@ -0,0 +1,44 @@
+# Copyright 2014 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
+}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+gdb_breakpoint [gdb_get_line_number "re-reverse-elements"]
+gdb_continue_to_breakpoint "re-reverse-elements"
+gdb_test "print pvla" " = \\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\\)" \
+ "print re-reverse-elements"
+gdb_test "print pvla(1)" " = 1" "print first re-reverse-element"
+gdb_test "print pvla(10)" " = 10" "print last re-reverse-element"
+
+gdb_breakpoint [gdb_get_line_number "odd-elements"]
+gdb_continue_to_breakpoint "odd-elements"
+gdb_test "print pvla" " = \\\(1, 3, 5, 7, 9\\\)" "print odd-elements"
+gdb_test "print pvla(1)" " = 1" "print first odd-element"
+gdb_test "print pvla(5)" " = 9" "print last odd-element"
+
+gdb_breakpoint [gdb_get_line_number "single-element"]
+gdb_continue_to_breakpoint "single-element"
+gdb_test "print pvla" " = \\\(5\\\)" "print single-element"
+gdb_test "print pvla(1)" " = 5" "print one single-element"
diff --git a/gdb/testsuite/gdb.fortran/vla-stride.f90 b/gdb/testsuite/gdb.fortran/vla-stride.f90
new file mode 100644
index 0000000..6aa4f2b
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/vla-stride.f90
@@ -0,0 +1,30 @@
+! Copyright 2014 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 2 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, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+program vla_stride
+ integer, target, allocatable :: vla (:)
+ integer, pointer :: pvla (:)
+
+ allocate(vla(10))
+ vla = (/ (I, I = 1,10) /)
+
+ pvla => vla(10:1:-1)
+ pvla => pvla(10:1:-1)
+ pvla => vla(1:10:2) ! re-reverse-elements
+ pvla => vla(5:4:-2) ! odd-elements
+
+ pvla => null() ! single-element
+end program vla_stride
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* [V2 10/23] vla: get Fortran dynamic strings working.
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (21 preceding siblings ...)
2014-07-11 9:22 ` [V2 23/23] test: stride support for dynamic arrays Keven Boell
@ 2014-07-11 9:28 ` Keven Boell
2014-07-11 16:23 ` [V2 00/23] Fortran dynamic array support Jan Kratochvil
2014-07-29 19:35 ` Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support] Jan Kratochvil
24 siblings, 0 replies; 51+ messages in thread
From: Keven Boell @ 2014-07-11 9:28 UTC (permalink / raw)
To: gdb-patches; +Cc: keven.boell, sanimir.agovic
This patch enables the correct calculation of dynamic
string length.
Old:
(gdb) p my_dyn_string
$1 = (PTR TO -> ( character*23959136 )) 0x605fc0
(gdb) p *my_dyn_string
Cannot access memory at address 0x605fc0
New:
(gdb) p my_dyn_string
$1 = (PTR TO -> ( character*10 )) 0x605fc0
(gdb) p *my_dyn_string
$2 = 'foo'
2014-05-28 Keven Boell <keven.boell@intel.com>
Sanimir Agovic <sanimir.agovic@intel.com>
* gdbtypes.c (resolve_dynamic_type): Add
conditions to support string types.
(resolve_dynamic_array): Add conditions for dynamic
strings and create a new string type.
(is_dynamic_type): Follow pointer if a string type
was detected, as Fortran strings are represented
as pointers to strings internally.
Change-Id: I7d54d762a081ce034be37ac3e368bac8111dc4e6
Signed-off-by: Keven Boell <keven.boell@intel.com>
---
gdb/gdbtypes.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index c7c5c3b..da773f6 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1675,6 +1675,17 @@ is_dynamic_type (struct type *type)
&& is_dynamic_type (TYPE_FIELD_TYPE (type, i)))
return 1;
}
+ case TYPE_CODE_PTR:
+ {
+ if (TYPE_TARGET_TYPE (type)
+ && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRING)
+ return is_dynamic_type (check_typedef (TYPE_TARGET_TYPE (type)));
+
+ return 0;
+ break;
+ }
+ default:
+ return 0;
break;
}
@@ -1745,7 +1756,8 @@ resolve_dynamic_array (struct type *type, CORE_ADDR addr)
struct dynamic_prop *prop;
struct type *copy = copy_type (type);
- gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY);
+ gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY
+ || TYPE_CODE (type) == TYPE_CODE_STRING);
elt_type = type;
range_type = check_typedef (TYPE_INDEX_TYPE (elt_type));
@@ -1767,14 +1779,20 @@ resolve_dynamic_array (struct type *type, CORE_ADDR addr)
ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
- if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY)
+ if (ary_dim != NULL && (TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY
+ || TYPE_CODE (ary_dim) == TYPE_CODE_STRING))
elt_type = resolve_dynamic_array (TYPE_TARGET_TYPE (copy), addr);
else
elt_type = TYPE_TARGET_TYPE (type);
- return create_array_type (copy,
- elt_type,
- range_type);
+ if (TYPE_CODE (type) == TYPE_CODE_STRING)
+ return create_string_type (copy,
+ elt_type,
+ range_type);
+ else
+ return create_array_type (copy,
+ elt_type,
+ range_type);
}
/* Resolve dynamic bounds of members of the union TYPE to static
@@ -1901,6 +1919,7 @@ resolve_dynamic_type (struct type *type, CORE_ADDR addr)
}
case TYPE_CODE_ARRAY:
+ case TYPE_CODE_STRING:
resolved_type = resolve_dynamic_array (type, addr);
break;
--
1.7.9.5
^ permalink raw reply [flat|nested] 51+ messages in thread* Re: [V2 00/23] Fortran dynamic array support
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (22 preceding siblings ...)
2014-07-11 9:28 ` [V2 10/23] vla: get Fortran dynamic strings working Keven Boell
@ 2014-07-11 16:23 ` Jan Kratochvil
2014-07-16 16:19 ` Keven Boell
2014-07-29 19:35 ` Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support] Jan Kratochvil
24 siblings, 1 reply; 51+ messages in thread
From: Jan Kratochvil @ 2014-07-11 16:23 UTC (permalink / raw)
To: Keven Boell; +Cc: gdb-patches, sanimir.agovic
Hi Keven,
On Fri, 11 Jul 2014 11:21:12 +0200, Keven Boell wrote:
> Patch series V2 mainly addresses issues/comments given for V1.
this new patchset has crash regressions on Fedora 20 x86_64 for:
gdb.ada/dyn_arrayidx.exp
gdb.ada/info_exc.exp
gdb.ada/mi_exc_info.exp
and even more gdb.ada/*.exp crashes for i686 and x86_64-m32 runs.
gdb.ada/info_exc.exp
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000000000812303 in attr_to_dynamic_prop (attr=0x350a008, die=0x3509fd0, cu=0x317ebf0, prop=0x7fff1d6b09a0,
additional_data=0x0, additional_data_size=0) at dwarf2read.c:14697
14697 baton->locexpr.data = DW_BLOCK (attr)->data;
(gdb) bt
#0 0x0000000000812303 in attr_to_dynamic_prop (attr=0x350a008, die=0x3509fd0, cu=0x317ebf0, prop=0x7fff1d6b09a0,
additional_data=0x0, additional_data_size=0) at dwarf2read.c:14697
#1 0x00000000008126a2 in read_subrange_type (die=0x3509fd0, cu=0x317ebf0) at dwarf2read.c:14799
#2 0x000000000081acb5 in read_type_die_1 (die=0x3509fd0, cu=0x317ebf0) at dwarf2read.c:18623
#3 0x000000000081aafc in read_type_die (die=0x3509fd0, cu=0x317ebf0) at dwarf2read.c:18565
#4 0x000000000080f073 in read_array_type (die=0x3509f50, cu=0x317ebf0) at dwarf2read.c:13515
#5 0x000000000081ab9d in read_type_die_1 (die=0x3509f50, cu=0x317ebf0) at dwarf2read.c:18593
#6 0x000000000081aafc in read_type_die (die=0x3509f50, cu=0x317ebf0) at dwarf2read.c:18565
#7 0x000000000081aa72 in lookup_die_type (die=0x350a0a0, attr=0x350a0d8, cu=0x317ebf0) at dwarf2read.c:18537
#8 0x000000000081a50e in die_type (die=0x350a0a0, cu=0x317ebf0) at dwarf2read.c:18387
[...]
Jan
^ permalink raw reply [flat|nested] 51+ messages in thread* Re: [V2 00/23] Fortran dynamic array support
2014-07-11 16:23 ` [V2 00/23] Fortran dynamic array support Jan Kratochvil
@ 2014-07-16 16:19 ` Keven Boell
2014-07-16 16:33 ` Jan Kratochvil
0 siblings, 1 reply; 51+ messages in thread
From: Keven Boell @ 2014-07-16 16:19 UTC (permalink / raw)
To: Jan Kratochvil, Keven Boell; +Cc: gdb-patches, sanimir.agovic
Am 11.07.2014 18:06, Jan Kratochvil wrote:
> Hi Keven,
>
> On Fri, 11 Jul 2014 11:21:12 +0200, Keven Boell wrote:
>> Patch series V2 mainly addresses issues/comments given for V1.
>
> this new patchset has crash regressions on Fedora 20 x86_64 for:
> gdb.ada/dyn_arrayidx.exp
> gdb.ada/info_exc.exp
> gdb.ada/mi_exc_info.exp
> and even more gdb.ada/*.exp crashes for i686 and x86_64-m32 runs.
>
I was not able to reproduce the issues on Fedora 20 (64bit and 32bit).
Could you please let me know what compiler you have used?
Tried it with gnat 4.8.3 and it seems to work fine.
> gdb.ada/info_exc.exp
> Program terminated with signal SIGSEGV, Segmentation fault.
> #0 0x0000000000812303 in attr_to_dynamic_prop (attr=0x350a008, die=0x3509fd0, cu=0x317ebf0, prop=0x7fff1d6b09a0,
> additional_data=0x0, additional_data_size=0) at dwarf2read.c:14697
> 14697 baton->locexpr.data = DW_BLOCK (attr)->data;
> (gdb) bt
> #0 0x0000000000812303 in attr_to_dynamic_prop (attr=0x350a008, die=0x3509fd0, cu=0x317ebf0, prop=0x7fff1d6b09a0,
> additional_data=0x0, additional_data_size=0) at dwarf2read.c:14697
> #1 0x00000000008126a2 in read_subrange_type (die=0x3509fd0, cu=0x317ebf0) at dwarf2read.c:14799
> #2 0x000000000081acb5 in read_type_die_1 (die=0x3509fd0, cu=0x317ebf0) at dwarf2read.c:18623
> #3 0x000000000081aafc in read_type_die (die=0x3509fd0, cu=0x317ebf0) at dwarf2read.c:18565
> #4 0x000000000080f073 in read_array_type (die=0x3509f50, cu=0x317ebf0) at dwarf2read.c:13515
> #5 0x000000000081ab9d in read_type_die_1 (die=0x3509f50, cu=0x317ebf0) at dwarf2read.c:18593
> #6 0x000000000081aafc in read_type_die (die=0x3509f50, cu=0x317ebf0) at dwarf2read.c:18565
> #7 0x000000000081aa72 in lookup_die_type (die=0x350a0a0, attr=0x350a0d8, cu=0x317ebf0) at dwarf2read.c:18537
> #8 0x000000000081a50e in die_type (die=0x350a0a0, cu=0x317ebf0) at dwarf2read.c:18387
> [...]
>
>
>
> Jan
>
Thanks,
Keven
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [V2 00/23] Fortran dynamic array support
2014-07-16 16:19 ` Keven Boell
@ 2014-07-16 16:33 ` Jan Kratochvil
2014-07-18 12:33 ` Keven Boell
0 siblings, 1 reply; 51+ messages in thread
From: Jan Kratochvil @ 2014-07-16 16:33 UTC (permalink / raw)
To: Keven Boell; +Cc: Keven Boell, gdb-patches, sanimir.agovic
On Wed, 16 Jul 2014 17:45:52 +0200, Keven Boell wrote:
> Am 11.07.2014 18:06, Jan Kratochvil wrote:
> > On Fri, 11 Jul 2014 11:21:12 +0200, Keven Boell wrote:
> >> Patch series V2 mainly addresses issues/comments given for V1.
> >
> > this new patchset has crash regressions on Fedora 20 x86_64 for:
> > gdb.ada/dyn_arrayidx.exp
> > gdb.ada/info_exc.exp
> > gdb.ada/mi_exc_info.exp
> > and even more gdb.ada/*.exp crashes for i686 and x86_64-m32 runs.
> >
>
> I was not able to reproduce the issues on Fedora 20 (64bit and 32bit).
> Could you please let me know what compiler you have used?
> Tried it with gnat 4.8.3 and it seems to work fine.
I have checked it more now and I guess the difference that makes it crashing
is that I have installed here:
gcc-debuginfo-4.8.3-1.fc20.x86_64
Thanks,
Jan
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [V2 00/23] Fortran dynamic array support
2014-07-16 16:33 ` Jan Kratochvil
@ 2014-07-18 12:33 ` Keven Boell
2014-07-18 15:19 ` Jan Kratochvil
0 siblings, 1 reply; 51+ messages in thread
From: Keven Boell @ 2014-07-18 12:33 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Keven Boell, gdb-patches, sanimir.agovic
On 16.07.2014 18:32, Jan Kratochvil wrote:
> On Wed, 16 Jul 2014 17:45:52 +0200, Keven Boell wrote:
>> Am 11.07.2014 18:06, Jan Kratochvil wrote:
>>> On Fri, 11 Jul 2014 11:21:12 +0200, Keven Boell wrote:
>>>> Patch series V2 mainly addresses issues/comments given for V1.
>>>
>>> this new patchset has crash regressions on Fedora 20 x86_64 for:
>>> gdb.ada/dyn_arrayidx.exp
>>> gdb.ada/info_exc.exp
>>> gdb.ada/mi_exc_info.exp
>>> and even more gdb.ada/*.exp crashes for i686 and x86_64-m32 runs.
>>>
>>
>> I was not able to reproduce the issues on Fedora 20 (64bit and 32bit).
>> Could you please let me know what compiler you have used?
>> Tried it with gnat 4.8.3 and it seems to work fine.
>
> I have checked it more now and I guess the difference that makes it crashing
> is that I have installed here:
> gcc-debuginfo-4.8.3-1.fc20.x86_64
>
Also installing this package, the tests are still passing on my system.
Did you use newer/older compiler than 4.8.3?
>
> Thanks,
> Jan
>
Keven
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [V2 00/23] Fortran dynamic array support
2014-07-18 12:33 ` Keven Boell
@ 2014-07-18 15:19 ` Jan Kratochvil
0 siblings, 0 replies; 51+ messages in thread
From: Jan Kratochvil @ 2014-07-18 15:19 UTC (permalink / raw)
To: Keven Boell; +Cc: Keven Boell, gdb-patches, sanimir.agovic
On Fri, 18 Jul 2014 14:30:54 +0200, Keven Boell wrote:
> On 16.07.2014 18:32, Jan Kratochvil wrote:
> > I have checked it more now and I guess the difference that makes it crashing
> > is that I have installed here:
> > gcc-debuginfo-4.8.3-1.fc20.x86_64
>
> Also installing this package, the tests are still passing on my system.
> Did you use newer/older compiler than 4.8.3?
I have used 4.8.3-1.fc20.x86_64 as shown above.
I will try to find some system-independent reproducer.
Thanks,
Jan
^ permalink raw reply [flat|nested] 51+ messages in thread
* Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-07-11 9:21 [V2 00/23] Fortran dynamic array support Keven Boell
` (23 preceding siblings ...)
2014-07-11 16:23 ` [V2 00/23] Fortran dynamic array support Jan Kratochvil
@ 2014-07-29 19:35 ` Jan Kratochvil
2014-07-29 20:51 ` Jan Kratochvil
2014-08-01 21:05 ` [patch 2/2] " Jan Kratochvil
24 siblings, 2 replies; 51+ messages in thread
From: Jan Kratochvil @ 2014-07-29 19:35 UTC (permalink / raw)
To: Keven Boell; +Cc: gdb-patches, sanimir.agovic
[-- Attachment #1: Type: text/plain, Size: 3572 bytes --]
Hi Keven,
I hope you get it reproducible this time.
With your patchset ( 511bff520372ffc10fa2ff569c176bdf1e6e475d ) and after
applying IMO harmless patch:
[patch] Display Fortran strings in backtraces
https://sourceware.org/ml/gdb-patches/2014-07/msg00709.html
I get a crash on 32-bit host (not on x86_64 and neither on x86_64 debugging
32-bit target built with -m32). Tested Fedora 21pre and Fedora Rawhide.
It happens only for the testcase gdb.fortran/dynamic-other-frame.exp which
comes from the original archer/jankratochvil/vla branch, attaching it.
Running gdb/testsuite/gdb.fortran/dynamic-other-frame.exp ...
ERROR: Process no longer exists
UNRESOLVED: gdb.fortran/dynamic-other-frame.exp: bt
runtest gdb.fortran/dynamic-other-frame.exp
gdb -ex r --args ../gdb gdb.fortran/dynamic-other-frame -ex 'b bar_' -ex r -ex bt
------------------------------------------------------------------------------
Breakpoint 1, 0x080485cf in bar_ ()
#0 0x080485cf in bar_ ()
Program received signal SIGSEGV, Segmentation fault.
0x0830d943 in extract_unsigned_integer (addr=0x1350a697 <error: Cannot access memory at address 0x1350a697>, len=1, byte_order=BFD_ENDIAN_LITTLE) at findvar.c:110
110 retval = (retval << 8) | *p;
(gdb) bt
#0 0x0830d943 in extract_unsigned_integer (addr=0x1350a697 <error: Cannot access memory at address 0x1350a697>, len=1, byte_order=BFD_ENDIAN_LITTLE) at findvar.c:110
#1 0x0833bc5a in generic_printstr (stream=0x9b0e058, type=0x98725c8, string=0x9a29d78 "", length=162400544, encoding=0x97a0c18 "UTF-8", force_ellipses=0, quote_char=34, c_style_terminator=1, options=0xffffc400) at valprint.c:2436
#2 0x0843ac0c in c_printstr (stream=0x9b0e058, type=0x98725c8, string=0x9a29d78 "", length=162400544, user_encoding=0x0, force_ellipses=0, options=0xffffc400) at c-lang.c:220
#3 0x0846bb3c in f_val_print (type=0x9ae0940, valaddr=0x9a29d78 "", embedded_offset=0, address=134514304, stream=0x9b0e058, recurse=2, original_value=0x9a29d10, options=0xffffc400) at f-valprint.c:238
#4 0x083389da in val_print (type=0x9ae0940, valaddr=0x9a29d78 "", embedded_offset=0, address=134514304, stream=0x9b0e058, recurse=2, val=0x9a29d10, options=0xffffc520, language=0x8c25c00 <f_language_defn>) at valprint.c:813
#5 0x08338cd1 in common_val_print (val=0x9a29d10, stream=0x9b0e058, recurse=2, options=0xffffc520, language=0x8c25c00 <f_language_defn>) at valprint.c:900
#6 0x08378647 in print_frame_arg (arg=0xffffc5d4) at stack.c:289
#7 0x0837916a in print_frame_args (func=0x9ae0a20, frame=0x97c307c, num=-1, stream=0x9839440) at stack.c:674
#8 0x0837a1fd in print_frame (frame=0x97c307c, print_level=1, print_what=LOCATION, print_args=1, sal=...) at stack.c:1205
#9 0x08379708 in print_frame_info (frame=0x97c307c, print_level=1, print_what=LOCATION, print_args=1, set_current_sal=0) at stack.c:857
#10 0x0837b935 in backtrace_command_1 (count_exp=0x0, show_locals=0, no_filters=0, from_tty=1) at stack.c:1817
#11 0x0837bcf7 in backtrace_command (arg=0x0, from_tty=1) at stack.c:1914
------------------------------------------------------------------------------
It is a bit interesting this way no crash happens:
------------------------------------------------------------------------------
../gdb gdb.fortran/dynamic-other-frame -ex 'b bar_' -ex r -ex up
Breakpoint 1, 0x080485cf in bar_ ()
#1 0x08048566 in foo (string='hello', _string=5) at ./gdb.fortran/dynamic-other-frame.f90:27
27 call bar ! stop-here
------------------------------------------------------------------------------
Thanks,
Jan
[-- Attachment #2: dynamic-other-frame.patch --]
[-- Type: text/plain, Size: 4762 bytes --]
Index: gdb-7.7.90.20140613/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.7.90.20140613/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 2014-06-16 23:30:30.113940488 +0200
@@ -0,0 +1,24 @@
+! Copyright 2010 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 2 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, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+!
+! Ihis file is the Fortran source file for dynamic.exp.
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
+
+subroutine bar
+ real :: dummy
+ dummy = 1
+end subroutine bar
Index: gdb-7.7.90.20140613/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.7.90.20140613/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp 2014-06-16 23:30:30.113940488 +0200
@@ -0,0 +1,37 @@
+# Copyright 2010 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+set testfile "dynamic-other-frame"
+set srcfile1 ${testfile}.f90
+set srcfile2 ${testfile}-stub.f90
+set objfile2 [standard_output_file ${testfile}-stub.o]
+set executable ${testfile}
+set binfile [standard_output_file ${executable}]
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${objfile2}" object {f90}] != ""
+ || [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${objfile2}" "${binfile}" executable {debug f90}] != "" } {
+ untested "Couldn't compile ${srcfile1} or ${srcfile2}"
+ return -1
+}
+
+clean_restart ${executable}
+
+if ![runto bar_] then {
+ perror "couldn't run to bar_"
+ continue
+}
+
+gdb_test "bt" {foo \(string='hello'.*}
Index: gdb-7.7.90.20140613/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.7.90.20140613/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 2014-06-16 23:30:30.113940488 +0200
@@ -0,0 +1,36 @@
+! Copyright 2010 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 2 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, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+!
+! Ihis file is the Fortran source file for dynamic.exp.
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
+
+subroutine foo (string)
+ interface
+ subroutine bar
+ end subroutine
+ end interface
+ character string*(*)
+ call bar ! stop-here
+end subroutine foo
+program test
+ interface
+ subroutine foo (string)
+ character string*(*)
+ end subroutine
+ end interface
+ call foo ('hello')
+end
^ permalink raw reply [flat|nested] 51+ messages in thread* Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-07-29 19:35 ` Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support] Jan Kratochvil
@ 2014-07-29 20:51 ` Jan Kratochvil
2014-08-01 7:20 ` Keven Boell
2014-08-01 21:05 ` [patch 2/2] " Jan Kratochvil
1 sibling, 1 reply; 51+ messages in thread
From: Jan Kratochvil @ 2014-07-29 20:51 UTC (permalink / raw)
To: Keven Boell; +Cc: gdb-patches, sanimir.agovic
On Tue, 29 Jul 2014 20:30:23 +0200, Jan Kratochvil wrote:
> I get a crash on 32-bit host (not on x86_64 and neither on x86_64 debugging
> 32-bit target built with -m32). Tested Fedora 21pre and Fedora Rawhide.
Verified it crashes also on Fedora 20 i686 (released distro) to make the
reproducibility easier.
Jan
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-07-29 20:51 ` Jan Kratochvil
@ 2014-08-01 7:20 ` Keven Boell
2014-08-01 7:22 ` Jan Kratochvil
2014-08-01 21:02 ` [patch 1/2] " Jan Kratochvil
0 siblings, 2 replies; 51+ messages in thread
From: Keven Boell @ 2014-08-01 7:20 UTC (permalink / raw)
To: Jan Kratochvil, Keven Boell; +Cc: gdb-patches, sanimir.agovic
On 29.07.2014 22:27, Jan Kratochvil wrote:
> On Tue, 29 Jul 2014 20:30:23 +0200, Jan Kratochvil wrote:
>> I get a crash on 32-bit host (not on x86_64 and neither on x86_64 debugging
>> 32-bit target built with -m32). Tested Fedora 21pre and Fedora Rawhide.
>
> Verified it crashes also on Fedora 20 i686 (released distro) to make the
> reproducibility easier.
>
>
> Jan
>
Hi Jan,
I just tried it on Fedora 20 i686. Applied the patch, you mentioned, on top of
the Fortran VLA series and executed your dynamic-other-frame test. Everything
is working fine here, I cannot reproduce the crash. Did you apply also other
patches on top? Was it a clean system where you tried the patches?
(gdb) bt
#0 0x080485ca in bar_ ()
#1 0x0804856b in foo (string='hello', _string=5) at ../../../gdb/testsuite/gdb.fortran/dynamic-other-frame.f90:27
#2 0x08048587 in test () at ../../../gdb/testsuite/gdb.fortran/dynamic-other-frame.f90:35
#3 0x080485bd in main (argc=1, argv=0xbfffec4e) at ../../../gdb/testsuite/gdb.fortran/dynamic-other-frame.f90:36
#4 0x4301ab83 in __libc_start_main () from /lib/libc.so.6
#5 0x08048471 in _start ()
- Keven
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-08-01 7:20 ` Keven Boell
@ 2014-08-01 7:22 ` Jan Kratochvil
2014-08-01 21:02 ` [patch 1/2] " Jan Kratochvil
1 sibling, 0 replies; 51+ messages in thread
From: Jan Kratochvil @ 2014-08-01 7:22 UTC (permalink / raw)
To: Keven Boell; +Cc: Keven Boell, gdb-patches, sanimir.agovic
On Fri, 01 Aug 2014 09:20:19 +0200, Keven Boell wrote:
> I just tried it on Fedora 20 i686. Applied the patch, you mentioned, on top of
> the Fortran VLA series and executed your dynamic-other-frame test. Everything
> is working fine here, I cannot reproduce the crash. Did you apply also other
> patches on top? Was it a clean system where you tried the patches?
No. Yes.
OK, I will investigate it more.
Thanks,
Jan
^ permalink raw reply [flat|nested] 51+ messages in thread
* [patch 1/2] Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-08-01 7:20 ` Keven Boell
2014-08-01 7:22 ` Jan Kratochvil
@ 2014-08-01 21:02 ` Jan Kratochvil
2014-08-12 6:56 ` Keven Boell
1 sibling, 1 reply; 51+ messages in thread
From: Jan Kratochvil @ 2014-08-01 21:02 UTC (permalink / raw)
To: Keven Boell; +Cc: Keven Boell, gdb-patches, sanimir.agovic
[-- Attachment #1: Type: text/plain, Size: 792 bytes --]
On Fri, 01 Aug 2014 09:20:19 +0200, Keven Boell wrote:
> I just tried it on Fedora 20 i686. Applied the patch, you mentioned, on top of
> the Fortran VLA series and executed your dynamic-other-frame test. Everything
> is working fine here, I cannot reproduce the crash.
I have it reproducible on Fedora 20 i686 with plain
CFLAGS=-g ./configure;make;cd gdb/testsuite;make site.exp;runtest gdb.fortran/dynamic-other-frame.exp
Besides that I have updated the testcase with
gdb_test_no_output "set print frame-arguments all"
so that there is no longer needed the patch:
[patch] Display Fortran strings in backtraces
https://sourceware.org/ml/gdb-patches/2014-07/msg00709.html
The fix below has no regressions for me. Unfortunately I do not see why you
cannot reproduce it.
Thanks,
Jan
[-- Attachment #2: vlastringonly.patch --]
[-- Type: text/plain, Size: 4959 bytes --]
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 53cae2c..cf7ac26 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1659,6 +1659,7 @@ is_dynamic_type_internal (struct type *type, int top_level)
return !has_static_range (TYPE_RANGE_DATA (type));
case TYPE_CODE_ARRAY:
+ case TYPE_CODE_STRING:
{
gdb_assert (TYPE_NFIELDS (type) == 1);
diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 b/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90
new file mode 100644
index 0000000..261ce17
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90
@@ -0,0 +1,24 @@
+! Copyright 2010 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 2 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, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+!
+! Ihis file is the Fortran source file for dynamic.exp.
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
+
+subroutine bar
+ real :: dummy
+ dummy = 1
+end subroutine bar
diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp b/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
new file mode 100644
index 0000000..570a28c
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
@@ -0,0 +1,39 @@
+# Copyright 2010 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+set testfile "dynamic-other-frame"
+set srcfile1 ${testfile}.f90
+set srcfile2 ${testfile}-stub.f90
+set objfile2 [standard_output_file ${testfile}-stub.o]
+set executable ${testfile}
+set binfile [standard_output_file ${executable}]
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${objfile2}" object {f90}] != ""
+ || [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${objfile2}" "${binfile}" executable {debug f90}] != "" } {
+ untested "Couldn't compile ${srcfile1} or ${srcfile2}"
+ return -1
+}
+
+clean_restart ${executable}
+
+gdb_test_no_output "set print frame-arguments all"
+
+if ![runto bar_] then {
+ perror "couldn't run to bar_"
+ continue
+}
+
+gdb_test "bt" {foo \(string='hello'.*}
diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 b/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90
new file mode 100644
index 0000000..2bc637d
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90
@@ -0,0 +1,36 @@
+! Copyright 2010 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 2 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, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+!
+! Ihis file is the Fortran source file for dynamic.exp.
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
+
+subroutine foo (string)
+ interface
+ subroutine bar
+ end subroutine
+ end interface
+ character string*(*)
+ call bar ! stop-here
+end subroutine foo
+program test
+ interface
+ subroutine foo (string)
+ character string*(*)
+ end subroutine
+ end interface
+ call foo ('hello')
+end
^ permalink raw reply [flat|nested] 51+ messages in thread* Re: [patch 1/2] Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-08-01 21:02 ` [patch 1/2] " Jan Kratochvil
@ 2014-08-12 6:56 ` Keven Boell
2014-08-12 21:55 ` Jan Kratochvil
0 siblings, 1 reply; 51+ messages in thread
From: Keven Boell @ 2014-08-12 6:56 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Keven Boell, gdb-patches, sanimir.agovic
On 01.08.2014 23:02, Jan Kratochvil wrote:
> On Fri, 01 Aug 2014 09:20:19 +0200, Keven Boell wrote:
>> I just tried it on Fedora 20 i686. Applied the patch, you mentioned, on top of
>> the Fortran VLA series and executed your dynamic-other-frame test. Everything
>> is working fine here, I cannot reproduce the crash.
>
> I have it reproducible on Fedora 20 i686 with plain
> CFLAGS=-g ./configure;make;cd gdb/testsuite;make site.exp;runtest gdb.fortran/dynamic-other-frame.exp
>
> Besides that I have updated the testcase with
> gdb_test_no_output "set print frame-arguments all"
> so that there is no longer needed the patch:
> [patch] Display Fortran strings in backtraces
> https://sourceware.org/ml/gdb-patches/2014-07/msg00709.html
>
> The fix below has no regressions for me. Unfortunately I do not see why you
> cannot reproduce it.
>
I installed gcc 4.9 on my FC20 32bit system and tried to reproduce the issue like
you mentioned above. Also this command sequence doesn't give me a crash. However
I added the patch, which fixes the issue on your end, you mentioned in a different mail
on the patch series and ran a make check with and without the patch. No regressions
detected on my system. I've pushed the new series to Github:
https://github.com/intel-gdb/vla/tree/vla-fortran
Could you please give it a try?
>
> Thanks,
> Jan
>
Thanks,
Keven
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [patch 1/2] Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-08-12 6:56 ` Keven Boell
@ 2014-08-12 21:55 ` Jan Kratochvil
2014-08-14 20:03 ` Jan Kratochvil
0 siblings, 1 reply; 51+ messages in thread
From: Jan Kratochvil @ 2014-08-12 21:55 UTC (permalink / raw)
To: Keven Boell; +Cc: Keven Boell, gdb-patches, sanimir.agovic
On Tue, 12 Aug 2014 08:55:55 +0200, Keven Boell wrote:
> On 01.08.2014 23:02, Jan Kratochvil wrote:
> > I have it reproducible on Fedora 20 i686 with plain
> > CFLAGS=-g ./configure;make;cd gdb/testsuite;make site.exp;runtest gdb.fortran/dynamic-other-frame.exp
> >
> > Besides that I have updated the testcase with
> > gdb_test_no_output "set print frame-arguments all"
> > so that there is no longer needed the patch:
> > [patch] Display Fortran strings in backtraces
> > https://sourceware.org/ml/gdb-patches/2014-07/msg00709.html
> >
> > The fix below has no regressions for me. Unfortunately I do not see why you
> > cannot reproduce it.
>
> I installed gcc 4.9 on my FC20 32bit system
This is unrelated to gcc 4.9. The problem occurs with standard Fedora 20 i686
compiler which is currently gcc-4.8.3-1.fc20.i686.
I have tried this evening to really reproduce it in 32-bit VM but it does not
happen there, despite all the involved packages are exactly the same build.
IMO it has to depend also on my x86_64 kernel where I run the i686 host in
mock chroot - but I did not try to reproduce it cleanly now.
Providing at least 32-bit build of GDB and its core:
http://people.redhat.com/jkratoch/gdb-bt.tar.xz
It is from the latest Intel vla.git clean commit:
364a416f43095996835d635561e22edceb53d380
> and tried to reproduce the issue like
> you mentioned above. Also this command sequence doesn't give me a crash. However
> I added the patch, which fixes the issue on your end, you mentioned in a different mail
> on the patch series and ran a make check with and without the patch. No regressions
> detected on my system. I've pushed the new series to Github:
> https://github.com/intel-gdb/vla/tree/vla-fortran
The difference of this new branch is only in:
https://github.com/intel-gdb/vla/commit/364a416f43095996835d635561e22edceb53d380
This is a part of:
[patch 2/2] Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
https://sourceware.org/ml/gdb-patches/2014-08/msg00026.html
but that patch did not fix the bug, it was only trying to add some sanity
checking (which did not work, though).
The fix of the F20 i686 bug was this patch:
[patch 1/2] Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
https://sourceware.org/ml/gdb-patches/2014-08/msg00025.html
No part of that patch is in the github branch, even not the testcase.
I have verified If I apply the testcase from [patch 1/2] (=the latter one)
GDB still crashes - that is the core file gdb-bt.tar.xz above.
Thanks,
Jan
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [patch 1/2] Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-08-12 21:55 ` Jan Kratochvil
@ 2014-08-14 20:03 ` Jan Kratochvil
2014-08-20 14:09 ` Keven Boell
0 siblings, 1 reply; 51+ messages in thread
From: Jan Kratochvil @ 2014-08-14 20:03 UTC (permalink / raw)
To: Keven Boell; +Cc: Keven Boell, gdb-patches, sanimir.agovic
On Tue, 12 Aug 2014 23:55:32 +0200, Jan Kratochvil wrote:
> Providing at least 32-bit build of GDB and its core:
> http://people.redhat.com/jkratoch/gdb-bt.tar.xz
> It is from the latest Intel vla.git clean commit:
> 364a416f43095996835d635561e22edceb53d380
With the assertions added on the GIT branch it crashes even on F-20 x86_64
(used -fsanitize=address) so I hope it is reproducible now also for you.
Please confirm reproducibility / unreproducibility.
Thanks,
Jan
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [patch 1/2] Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-08-14 20:03 ` Jan Kratochvil
@ 2014-08-20 14:09 ` Keven Boell
2014-08-20 18:24 ` Jan Kratochvil
0 siblings, 1 reply; 51+ messages in thread
From: Keven Boell @ 2014-08-20 14:09 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Keven Boell, gdb-patches, sanimir.agovic
On 14.08.2014 22:02, Jan Kratochvil wrote:
> On Tue, 12 Aug 2014 23:55:32 +0200, Jan Kratochvil wrote:
>> Providing at least 32-bit build of GDB and its core:
>> http://people.redhat.com/jkratoch/gdb-bt.tar.xz
>> It is from the latest Intel vla.git clean commit:
>> 364a416f43095996835d635561e22edceb53d380
>
> With the assertions added on the GIT branch it crashes even on F-20 x86_64
> (used -fsanitize=address) so I hope it is reproducible now also for you.
> Please confirm reproducibility / unreproducibility.
>
Finally I was able to reproduce the crash in some of the VLA tests when
compiling with -fsanitize=address on FC20 32bit.
I've pushed a fix to
https://github.com/intel-gdb/vla/tree/vla-fortran
Let me know if this works for you now. At least on my FC20 32bit system it does
not crash anymore.
>
> Thanks,
> Jan
>
Keven
^ permalink raw reply [flat|nested] 51+ messages in thread
* Re: [patch 1/2] Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-08-20 14:09 ` Keven Boell
@ 2014-08-20 18:24 ` Jan Kratochvil
2014-08-21 7:27 ` Keven Boell
0 siblings, 1 reply; 51+ messages in thread
From: Jan Kratochvil @ 2014-08-20 18:24 UTC (permalink / raw)
To: Keven Boell; +Cc: Keven Boell, gdb-patches, sanimir.agovic
On Wed, 20 Aug 2014 16:07:58 +0200, Keven Boell wrote:
> Finally I was able to reproduce the crash in some of the VLA tests when
> compiling with -fsanitize=address on FC20 32bit.
> I've pushed a fix to
> https://github.com/intel-gdb/vla/tree/vla-fortran
>
> Let me know if this works for you now. At least on my FC20 32bit system it does
> not crash anymore.
I find this fix probably unrelated (as it is a completely different code) to
the internal error (formerly silent crash).
Tested 15f4f87976493f6e144a9bdb5eb7f0109543a393:
runtest gdb.fortran/dynamic-other-frame.exp
[...]
(gdb) bt^M
#0 0x000000000040071d in bar_ ()^M
#1 0x00000000004006c7 in foo (string=gdbtypes.c:2009: internal-error: dynamic_prop_get_const_val_ptr: Assertion `prop->kind == PROP_CONST' failed.^M
A problem internal to GDB has been detected,^M
Fedora {20,21} {x86_64,i686}: internal-error
Fedora {21,21} x86_64 -m32: PASS
But it depends on something suspicious, for a given build the testsuite
results are stable but for builds done at different time / under different
configurations the results differ.
Could you first check-in the gdb.fortran/dynamic-other-frame.exp testcase to
the Intel branch? I find it difficult to catch a crash of a testcase not even
present in your repository.
Thanks,
Jan
^ permalink raw reply [flat|nested] 51+ messages in thread* Re: [patch 1/2] Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-08-20 18:24 ` Jan Kratochvil
@ 2014-08-21 7:27 ` Keven Boell
2014-08-21 14:29 ` Jan Kratochvil
2014-08-22 7:20 ` Jan Kratochvil
0 siblings, 2 replies; 51+ messages in thread
From: Keven Boell @ 2014-08-21 7:27 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Keven Boell, gdb-patches, sanimir.agovic
On 20.08.2014 20:24, Jan Kratochvil wrote:
> On Wed, 20 Aug 2014 16:07:58 +0200, Keven Boell wrote:
>> Finally I was able to reproduce the crash in some of the VLA tests when
>> compiling with -fsanitize=address on FC20 32bit.
>> I've pushed a fix to
>> https://github.com/intel-gdb/vla/tree/vla-fortran
>>
>> Let me know if this works for you now. At least on my FC20 32bit system it does
>> not crash anymore.
>
> I find this fix probably unrelated (as it is a completely different code) to
> the internal error (formerly silent crash).
This prevents the crash I had on my F20 32bit box in f-typeprint.c when compiling with
-fsanitize=address. The crash occurred in one of our tests. The other crashes you
reported I'm unfortunately still not able to reproduce (tried different gcc versions, 32/64bit).
Since it seems that your environment differs from a clean FC20, it is hard for me to
reproduce and debug the issues you observe.
E.g. if I try to execute your compiled GDB on FC20 32bit, I get errors that some
shared libraries are missing (e.g. libbabeltrace.so.1).
So I wonder how we should go on from here?
>
> Tested 15f4f87976493f6e144a9bdb5eb7f0109543a393:
>
> runtest gdb.fortran/dynamic-other-frame.exp
> [...]
> (gdb) bt^M
> #0 0x000000000040071d in bar_ ()^M
> #1 0x00000000004006c7 in foo (string=gdbtypes.c:2009: internal-error: dynamic_prop_get_const_val_ptr: Assertion `prop->kind == PROP_CONST' failed.^M
> A problem internal to GDB has been detected,^M
>
> Fedora {20,21} {x86_64,i686}: internal-error
> Fedora {21,21} x86_64 -m32: PASS
>
> But it depends on something suspicious, for a given build the testsuite
> results are stable but for builds done at different time / under different
> configurations the results differ.
Do you know what configuration exactly caused this?
>
>
> Could you first check-in the gdb.fortran/dynamic-other-frame.exp testcase to
> the Intel branch? I find it difficult to catch a crash of a testcase not even
> present in your repository.
>
I've pushed the dynamic-other-frame test to our Github repository.
Could you please try to compile and run the tests on a clean FC20 32bit machine?
>
> Thanks,
> Jan
>
Thanks,
Keven
^ permalink raw reply [flat|nested] 51+ messages in thread* Re: [patch 1/2] Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-08-21 7:27 ` Keven Boell
@ 2014-08-21 14:29 ` Jan Kratochvil
2014-08-22 7:20 ` Jan Kratochvil
1 sibling, 0 replies; 51+ messages in thread
From: Jan Kratochvil @ 2014-08-21 14:29 UTC (permalink / raw)
To: Keven Boell; +Cc: Keven Boell, gdb-patches, sanimir.agovic
On Thu, 21 Aug 2014 09:27:21 +0200, Keven Boell wrote:
> Since it seems that your environment differs from a clean FC20, it is hard for me to
> reproduce and debug the issues you observe.
I understand this is a problem as I was not able to reproduce it in a clean VM
myself.
But thanks for the information you are still unable to reproduce it, I was not
sure. I will look more what it cause, I have to debug the problem myself now.
> E.g. if I try to execute your compiled GDB on FC20 32bit, I get errors that some
> shared libraries are missing (e.g. libbabeltrace.so.1).
> So I wonder how we should go on from here?
# repoquery -q --whatprovides libbabeltrace.so.1
libbabeltrace-0:1.2.1-1.fc20.i686
# yum install libbabeltrace.so.1
> > Tested 15f4f87976493f6e144a9bdb5eb7f0109543a393:
> >
> > runtest gdb.fortran/dynamic-other-frame.exp
> > [...]
> > (gdb) bt^M
> > #0 0x000000000040071d in bar_ ()^M
> > #1 0x00000000004006c7 in foo (string=gdbtypes.c:2009: internal-error: dynamic_prop_get_const_val_ptr: Assertion `prop->kind == PROP_CONST' failed.^M
> > A problem internal to GDB has been detected,^M
> >
> > Fedora {20,21} {x86_64,i686}: internal-error
> > Fedora {21,21} x86_64 -m32: PASS
> >
> > But it depends on something suspicious, for a given build the testsuite
> > results are stable but for builds done at different time / under different
> > configurations the results differ.
>
> Do you know what configuration exactly caused this?
I have built it yesterday with my script "errs12 --noasan" (not providing the
script as it may be misleading) but I was building it with internal-error even
with plain 'CFLAGS=-g ./configure; make' for past mail bugreports.
> I've pushed the dynamic-other-frame test to our Github repository.
> Could you please try to compile and run the tests on a clean FC20 32bit machine?
When I run it on FC20 32bit VM it really does not crash.
It crashes for me in:
mock -r fedora-20-x86_64 --init
mock -r fedora-20-x86_64 --shell
yum install ...
# even x86_64->i686
but it is all a bit customized so that clean mock may also not reproduce it.
I find it enough that you confirm you still have it unreproducible, I was not
sure. I will reply more later.
Thanks,
Jan
^ permalink raw reply [flat|nested] 51+ messages in thread* Re: [patch 1/2] Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-08-21 7:27 ` Keven Boell
2014-08-21 14:29 ` Jan Kratochvil
@ 2014-08-22 7:20 ` Jan Kratochvil
1 sibling, 0 replies; 51+ messages in thread
From: Jan Kratochvil @ 2014-08-22 7:20 UTC (permalink / raw)
To: Keven Boell; +Cc: Keven Boell, gdb-patches, sanimir.agovic
[-- Attachment #1: Type: text/plain, Size: 704 bytes --]
On Thu, 21 Aug 2014 09:27:21 +0200, Keven Boell wrote:
> I've pushed the dynamic-other-frame test to our Github repository.
> Could you please try to compile and run the tests on a clean FC20 32bit machine?
Please check-in also the attached modification on top of it.
I also have the internal-error also unreproducible with the testcase currently
present on the https://github.com/intel-gdb/vla.git branch vla-fortran.
Unfortunately even with the patch attached it sometimes does not crash for me
- such as in a clean VM I tried to install. But there is now at least
a chance you can have the bug reproducible.
(Sorry I haven't yet tracked down the bug myself as I promised yesterday.)
Thanks,
Jan
[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 371 bytes --]
--- a/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
@@ -29,6 +29,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${objfile2}" object {f90}]
clean_restart ${executable}
+gdb_test_no_output "set print frame-arguments all"
+
if ![runto bar_] then {
perror "couldn't run to bar_"
continue
^ permalink raw reply [flat|nested] 51+ messages in thread
* [patch 2/2] Re: Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support]
2014-07-29 19:35 ` Crash regression(?) printing Fortran strings in bt [Re: [V2 00/23] Fortran dynamic array support] Jan Kratochvil
2014-07-29 20:51 ` Jan Kratochvil
@ 2014-08-01 21:05 ` Jan Kratochvil
1 sibling, 0 replies; 51+ messages in thread
From: Jan Kratochvil @ 2014-08-01 21:05 UTC (permalink / raw)
To: Keven Boell; +Cc: gdb-patches, sanimir.agovic
[-- Attachment #1: Type: text/plain, Size: 329 bytes --]
Hi Keven,
in this patch I have tried to implement some sanity checking so that there
cannot happen what happened.
Unfortunately it has many regression in normal testcases, it would need to be
tuned more. But IMO it would be worth to implement some such checks, it is
easy to forget calling some dynamic-resolve.
Thanks,
Jan
[-- Attachment #2: vlastringsanityonly.patch --]
[-- Type: text/plain, Size: 3668 bytes --]
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index fbf13ce..145445f 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -14272,8 +14272,8 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
}
else
{
- TYPE_HIGH_BOUND (range_type) = DW_UNSND (attr);
TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
+ TYPE_HIGH_BOUND (range_type) = DW_UNSND (attr);
}
}
else
@@ -14283,13 +14283,13 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr)
{
- TYPE_HIGH_BOUND (range_type) = DW_UNSND (attr);
TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
+ TYPE_HIGH_BOUND (range_type) = DW_UNSND (attr);
}
else
{
- TYPE_HIGH_BOUND (range_type) = 1;
TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
+ TYPE_HIGH_BOUND (range_type) = 1;
}
}
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 53cae2c..cf7ac26 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2001,6 +2002,16 @@ resolve_dynamic_type (struct type *type, CORE_ADDR addr)
return resolve_dynamic_type_internal (type, addr, 1);
}
+/* See gdbtypes.h */
+
+LONGEST *
+dynamic_prop_get_const_val_ptr (struct dynamic_prop *prop)
+{
+ gdb_assert (prop->kind == PROP_CONST);
+
+ return &prop->data.const_val;
+}
+
/* Find the real type of TYPE. This function returns the real type,
after removing all layers of typedefs, and completing opaque or stub
types. Completion changes the TYPE argument, but stripping of
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 436edf8..78c8003 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1212,9 +1212,9 @@ extern void allocate_gnat_aux_type (struct type *);
#define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
#define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds
#define TYPE_LOW_BOUND(range_type) \
- TYPE_RANGE_DATA(range_type)->low.data.const_val
+ (*dynamic_prop_get_const_val_ptr (&TYPE_RANGE_DATA(range_type)->low))
#define TYPE_HIGH_BOUND(range_type) \
- TYPE_RANGE_DATA(range_type)->high.data.const_val
+ (*dynamic_prop_get_const_val_ptr (&TYPE_RANGE_DATA(range_type)->high))
#define TYPE_LOW_BOUND_UNDEFINED(range_type) \
(TYPE_RANGE_DATA(range_type)->low.kind == PROP_UNDEFINED)
#define TYPE_HIGH_BOUND_UNDEFINED(range_type) \
@@ -1224,13 +1224,7 @@ extern void allocate_gnat_aux_type (struct type *);
#define TYPE_LOW_BOUND_KIND(range_type) \
TYPE_RANGE_DATA(range_type)->low.kind
#define TYPE_BYTE_STRIDE(range_type) \
- TYPE_RANGE_DATA(range_type)->stride.data.const_val
-#define TYPE_BYTE_STRIDE_BLOCK(range_type) \
- TYPE_RANGE_DATA(range_type)->stride.data.locexpr
-#define TYPE_BYTE_STRIDE_LOCLIST(range_type) \
- TYPE_RANGE_DATA(range_type)->stride.data.loclist
-#define TYPE_BYTE_STRIDE_KIND(range_type) \
- TYPE_RANGE_DATA(range_type)->stride.kind
+ (*dynamic_prop_get_const_val_ptr (&TYPE_RANGE_DATA(range_type)->stride))
/* Attribute accessors for the type data location. */
@@ -1767,6 +1761,10 @@ extern struct type *resolve_dynamic_type (struct type *type, CORE_ADDR addr);
/* * Predicate if the type has dynamic values, which are not resolved yet. */
extern int is_dynamic_type (struct type *type);
+/* Fetch const_val reference from PROP. It is never dynamically resolved,
+ the correct KIND is checked by gdb_assert. */
+extern LONGEST *dynamic_prop_get_const_val_ptr (struct dynamic_prop *prop);
+
extern struct type *check_typedef (struct type *);
#define CHECK_TYPEDEF(TYPE) \
^ permalink raw reply [flat|nested] 51+ messages in thread