public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-jankratochvil-vla: https://bugzilla.redhat.com/show_bug.cgi?id=806920 gdb.dwarf2/dw2-subrange-no-type.exp
@ 2012-03-26 18:50 jkratoch
0 siblings, 0 replies; only message in thread
From: jkratoch @ 2012-03-26 18:50 UTC (permalink / raw)
To: archer-commits
The branch, archer-jankratochvil-vla has been updated
via 7d8bdfbdfd0e38fb314d70785b0516181b8d4e77 (commit)
from a999ae2c722b366b94987941f0ce899f95e8d679 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 7d8bdfbdfd0e38fb314d70785b0516181b8d4e77
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Mon Mar 26 20:49:51 2012 +0200
https://bugzilla.redhat.com/show_bug.cgi?id=806920
gdb.dwarf2/dw2-subrange-no-type.exp
-----------------------------------------------------------------------
Summary of changes:
gdb/dwarf2read.c | 76 +++++++-------
gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S | 121 +++++++++++++++++++++
gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp | 39 +++++++
3 files changed, 198 insertions(+), 38 deletions(-)
create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
First 500 lines of diff:
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 80e5fe4..f7fe256 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9014,6 +9014,44 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
/* Preserve BASE_TYPE's original type, just set its LENGTH. */
check_typedef (base_type);
+ /* Dwarf-2 specifications explicitly allows to create subrange types
+ without specifying a base type.
+ In that case, the base type must be set to the type of
+ the lower bound, upper bound or count, in that order, if any of these
+ three attributes references an object that has a type.
+ If no base type is found, the Dwarf-2 specifications say that
+ a signed integer type of size equal to the size of an address should
+ be used.
+ For the following C code: `extern char gdb_int [];'
+ GCC produces an empty range DIE.
+ FIXME: muller/2010-05-28: Possible references to object for low bound,
+ high bound or count are not yet handled by this code. */
+ if (TYPE_CODE (base_type) == TYPE_CODE_VOID)
+ {
+ struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
+ int addr_size = gdbarch_addr_bit (gdbarch) /8;
+ struct type *int_type = objfile_type (objfile)->builtin_int;
+
+ /* Test "int", "long int", and "long long int" objfile types,
+ and select the first one having a size above or equal to the
+ architecture address size. */
+ if (int_type && TYPE_LENGTH (int_type) >= addr_size)
+ base_type = int_type;
+ else
+ {
+ int_type = objfile_type (objfile)->builtin_long;
+ if (int_type && TYPE_LENGTH (int_type) >= addr_size)
+ base_type = int_type;
+ else
+ {
+ int_type = objfile_type (objfile)->builtin_long_long;
+ if (int_type && TYPE_LENGTH (int_type) >= addr_size)
+ base_type = int_type;
+ }
+ }
+ }
+
/* The die_type call above may have already set the type for this DIE. */
range_type = get_die_type (die, cu);
if (range_type)
@@ -9141,44 +9179,6 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
TYPE_HIGH_BOUND (range_type) = high;
}
- /* Dwarf-2 specifications explicitly allows to create subrange types
- without specifying a base type.
- In that case, the base type must be set to the type of
- the lower bound, upper bound or count, in that order, if any of these
- three attributes references an object that has a type.
- If no base type is found, the Dwarf-2 specifications say that
- a signed integer type of size equal to the size of an address should
- be used.
- For the following C code: `extern char gdb_int [];'
- GCC produces an empty range DIE.
- FIXME: muller/2010-05-28: Possible references to object for low bound,
- high bound or count are not yet handled by this code. */
- if (TYPE_CODE (base_type) == TYPE_CODE_VOID)
- {
- struct objfile *objfile = cu->objfile;
- struct gdbarch *gdbarch = get_objfile_arch (objfile);
- int addr_size = gdbarch_addr_bit (gdbarch) /8;
- struct type *int_type = objfile_type (objfile)->builtin_int;
-
- /* Test "int", "long int", and "long long int" objfile types,
- and select the first one having a size above or equal to the
- architecture address size. */
- if (int_type && TYPE_LENGTH (int_type) >= addr_size)
- base_type = int_type;
- else
- {
- int_type = objfile_type (objfile)->builtin_long;
- if (int_type && TYPE_LENGTH (int_type) >= addr_size)
- base_type = int_type;
- else
- {
- int_type = objfile_type (objfile)->builtin_long_long;
- if (int_type && TYPE_LENGTH (int_type) >= addr_size)
- base_type = int_type;
- }
- }
- }
-
/* DW_AT_bit_stride is currently unsupported as we count in bytes. */
attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
if (attr && attr_form_is_block (attr) && cu->language != language_ada)
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
new file mode 100644
index 0000000..9dbbf3c
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
@@ -0,0 +1,121 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2012 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/>. */
+
+/* Debug information */
+
+ .section .data
+vardata:
+ .rept 129
+ .ascii "x"
+ .endr
+ .ascii "UNSEEN\0"
+
+ .section .debug_info
+.Lcu1_begin:
+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
+.Lcu1_start:
+ .2byte 2 /* DWARF version number */
+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
+ .byte 4 /* Pointer Size (in bytes) */
+
+ /* CU die */
+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
+ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */
+ .byte 2 /* DW_AT_language (C) - */
+
+.Larray_type:
+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
+
+ .uleb128 8 /* Abbrev: DW_TAG_subrange_type without DW_AT_type */
+ .byte 0 /* DW_AT_lower_bound */
+ .byte 128 /* DW_AT_upper_bound */
+
+ .byte 0 /* End of children of die */
+
+.Lchar_type:
+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
+ .ascii "char\0" /* DW_AT_name */
+ .byte 1 /* DW_AT_byte_size */
+ .byte 6 /* DW_AT_encoding */
+
+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
+ .ascii "notype_string\0" /* DW_AT_name */
+ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */
+ .byte 2f - 1f /* DW_AT_location */
+1: .byte 3 /* DW_OP_addr */
+ .4byte vardata /* <addr> */
+2:
+
+ .byte 0 /* End of children of CU */
+.Lcu1_end:
+
+ .section .debug_abbrev
+.Ldebug_abbrev0:
+ .uleb128 1 /* Abbrev code */
+ .uleb128 0x11 /* DW_TAG_compile_unit */
+ .byte 0x1 /* has_children */
+ .uleb128 0x25 /* DW_AT_producer */
+ .uleb128 0x8 /* DW_FORM_string */
+ .uleb128 0x13 /* DW_AT_language */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
+ .uleb128 2 /* Abbrev code */
+ .uleb128 0x1 /* TAG: DW_TAG_array_type */
+ .byte 0x1 /* DW_children_yes */
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
+ .uleb128 4 /* Abbrev code */
+ .uleb128 0x24 /* DW_TAG_base_type */
+ .byte 0x0 /* no_children */
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0x8 /* DW_FORM_string */
+ .uleb128 0xb /* DW_AT_byte_size */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x3e /* DW_AT_encoding */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
+ .uleb128 6 /* Abbrev code */
+ .uleb128 0x34 /* DW_TAG_variable */
+ .byte 0x0 /* no_children */
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0x8 /* DW_FORM_string */
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .uleb128 0x2 /* DW_AT_location */
+ .uleb128 0xa /* DW_FORM_block1 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
+ .uleb128 8 /* Abbrev code */
+ .uleb128 0x21 /* DW_TAG_subrange_type without DW_AT_type */
+ .byte 0x0 /* no children */
+ .uleb128 0x22 /* DW_AT_lower_bound */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x2f /* DW_AT_upper_bound */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
+ .byte 0x0 /* Terminator */
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
new file mode 100644
index 0000000..a13e346
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
@@ -0,0 +1,39 @@
+# Copyright 2012 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/>.
+load_lib dwarf.exp
+
+# https://bugzilla.redhat.com/show_bug.cgi?id=806920
+# read_subrange_type <TYPE_CODE (base_type) == TYPE_CODE_VOID> reinitialization
+# of BASE_TYPE was done too late, it affects DW_TAG_subrange_type without
+# specified DW_AT_type, present only in XLF produced code.
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if {![dwarf2_support]} {
+ return 0
+}
+
+set testfile dw2-subrange-no-type
+set srcfile ${testfile}.S
+set executable ${testfile}.x
+set binfile ${objdir}/${subdir}/${executable}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } {
+ return -1
+}
+
+clean_restart $executable
+
+gdb_test "ptype notype_string" {type = char \[129\]}
+gdb_test "p notype_string" " = 'x' <repeats 129 times>"
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-03-26 18:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-26 18:50 [SCM] archer-jankratochvil-vla: https://bugzilla.redhat.com/show_bug.cgi?id=806920 gdb.dwarf2/dw2-subrange-no-type.exp jkratoch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).