aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2012-05-24 22:09:21 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2012-05-24 22:09:21 +0000
commit685b110556624dff5bd9614edb016bad9b0642fc (patch)
tree64d053f31f925106a6e718c3dde77d56d850c704 /gdb
parent2c1fa544e14e0fa78b842c50c03b49dcfd3f6e02 (diff)
downloadgdb-685b110556624dff5bd9614edb016bad9b0642fc.zip
gdb-685b110556624dff5bd9614edb016bad9b0642fc.tar.gz
gdb-685b110556624dff5bd9614edb016bad9b0642fc.tar.bz2
gdb/
PR symtab/13277: Resolving opaque structures in ICC generated binaries. * dwarf2read.c (struct dwarf2_cu) <producer_is_icc>: New field. (producer_is_gxx_lt_4_6): Move the checking and caching to... (check_producer): ... this new function, which also checks for ICC and caches the result. (producer_is_icc): New function. (read_structure_type): Don't set TYPE_STUB_SUPPORTED if the producer was ICC. gdb/testsuite/ PR symtab/13277: Resolving opaque structures in ICC generated binaries. * gdb.dwarf2/dw2-icc-opaque.S: New file. * gdb.dwarf2/dw2-icc-opaque.exp: New file.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/dwarf2read.c80
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.S207
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.exp41
5 files changed, 317 insertions, 28 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3c1a167..1e4e1ac 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+2012-05-24 John Steele Scott <toojays@toojays.net>
+
+ PR symtab/13277: Resolving opaque structures in ICC generated binaries.
+ * dwarf2read.c (struct dwarf2_cu) <producer_is_icc>: New field.
+ (producer_is_gxx_lt_4_6): Move the checking and caching to...
+ (check_producer): ... this new function, which also checks for ICC
+ and caches the result.
+ (producer_is_icc): New function.
+ (read_structure_type): Don't set TYPE_STUB_SUPPORTED if the
+ producer was ICC.
+
2012-05-24 Pedro Alves <palves@redhat.com>
PR gdb/7205
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b590134..53100c5 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -429,12 +429,13 @@ struct dwarf2_cu
unoptimized code. For a future better test see GCC PR other/32998. */
unsigned int has_loclist : 1;
- /* These cache the results of producer_is_gxx_lt_4_6.
- CHECKED_PRODUCER is set if PRODUCER_IS_GXX_LT_4_6 is valid. This
- information is cached because profiling CU expansion showed
- excessive time spent in producer_is_gxx_lt_4_6. */
+ /* These cache the results for producer_is_gxx_lt_4_6 and producer_is_icc.
+ CHECKED_PRODUCER is set if both PRODUCER_IS_GXX_LT_4_6 and PRODUCER_IS_ICC
+ are valid. This information is cached because profiling CU expansion
+ showed excessive time spent in producer_is_gxx_lt_4_6. */
unsigned int checked_producer : 1;
unsigned int producer_is_gxx_lt_4_6 : 1;
+ unsigned int producer_is_icc : 1;
/* Non-zero if DW_AT_addr_base was found.
Used when processing DWO files. */
@@ -8271,16 +8272,14 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block,
}
}
-/* Check for GCC PR debug/45124 fix which is not present in any G++ version up
- to 4.5.any while it is present already in G++ 4.6.0 - the PR has been fixed
- during 4.6.0 experimental. */
+/* Check whether the producer field indicates either of GCC < 4.6, or the
+ Intel C/C++ compiler, and cache the result in CU. */
-static int
-producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu)
+static void
+check_producer (struct dwarf2_cu *cu)
{
const char *cs;
int major, minor, release;
- int result = 0;
if (cu->producer == NULL)
{
@@ -8292,22 +8291,11 @@ producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu)
for their space efficiency GDB cannot workaround gcc-4.5.x -gdwarf-4
combination. gcc-4.5.x -gdwarf-4 binaries have DW_AT_accessibility
interpreted incorrectly by GDB now - GCC PR debug/48229. */
-
- return 0;
- }
-
- if (cu->checked_producer)
- return cu->producer_is_gxx_lt_4_6;
-
- /* Skip any identifier after "GNU " - such as "C++" or "Java". */
-
- if (strncmp (cu->producer, "GNU ", strlen ("GNU ")) != 0)
- {
- /* For non-GCC compilers expect their behavior is DWARF version
- compliant. */
}
- else
+ else if (strncmp (cu->producer, "GNU ", strlen ("GNU ")) == 0)
{
+ /* Skip any identifier after "GNU " - such as "C++" or "Java". */
+
cs = &cu->producer[strlen ("GNU ")];
while (*cs && !isdigit (*cs))
cs++;
@@ -8316,13 +8304,30 @@ producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu)
/* Not recognized as GCC. */
}
else
- result = major < 4 || (major == 4 && minor < 6);
+ cu->producer_is_gxx_lt_4_6 = major < 4 || (major == 4 && minor < 6);
+ }
+ else if (strncmp (cu->producer, "Intel(R) C", strlen ("Intel(R) C")) == 0)
+ cu->producer_is_icc = 1;
+ else
+ {
+ /* For other non-GCC compilers, expect their behavior is DWARF version
+ compliant. */
}
cu->checked_producer = 1;
- cu->producer_is_gxx_lt_4_6 = result;
+}
- return result;
+/* Check for GCC PR debug/45124 fix which is not present in any G++ version up
+ to 4.5.any while it is present already in G++ 4.6.0 - the PR has been fixed
+ during 4.6.0 experimental. */
+
+static int
+producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu)
+{
+ if (!cu->checked_producer)
+ check_producer (cu);
+
+ return cu->producer_is_gxx_lt_4_6;
}
/* Return the default accessibility type if it is not overriden by
@@ -9005,6 +9010,18 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile)
smash_to_methodptr_type (type, new_type);
}
+/* Return non-zero if the CU's PRODUCER string matches the Intel C/C++ compiler
+ (icc). */
+
+static int
+producer_is_icc (struct dwarf2_cu *cu)
+{
+ if (!cu->checked_producer)
+ check_producer (cu);
+
+ return cu->producer_is_icc;
+}
+
/* Called when we find the DIE that starts a structure or union scope
(definition) to create a type for the structure or union. Fill in
the type's name and general properties; the members will not be
@@ -9107,7 +9124,14 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
TYPE_LENGTH (type) = 0;
}
- TYPE_STUB_SUPPORTED (type) = 1;
+ if (producer_is_icc (cu))
+ {
+ /* ICC does not output the required DW_AT_declaration
+ on incomplete types, but gives them a size of zero. */
+ }
+ else
+ TYPE_STUB_SUPPORTED (type) = 1;
+
if (die_is_declaration (die, cu))
TYPE_STUB (type) = 1;
else if (attr == NULL && die->child == NULL
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 5a0d71d..fd97ca9 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-24 John Steele Scott <toojays@toojays.net>
+
+ PR symtab/13277: Resolving opaque structures in ICC generated binaries.
+ * gdb.dwarf2/dw2-icc-opaque.S: New file.
+ * gdb.dwarf2/dw2-icc-opaque.exp: New file.
+
2012-05-23 Stan Shebs <stan@codesourcery.com>
* gdb.mi/mi-info-os.exp: New file.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.S b/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.S
new file mode 100644
index 0000000..7564fba
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.S
@@ -0,0 +1,207 @@
+/* Copyright (C) 2011-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/>. */
+
+/* This test demonstrates a failure to resolve opaque structure types in
+ binaries compiled by the Intel C compiler. This is GDB PR symtab/13277.
+
+ The test was derived from opaque-pointer.c, which contains the single line:
+
+ struct opaque_struct_t *p_struct;
+
+ and opaque_struct.c, which looks like:
+
+ struct opaque_struct_t
+ {
+ int wrapped_value;
+ };
+
+ struct opaque_struct_t opaque_internal = { 0 };
+
+ What follows is a simplified version of the debug info generated by ICC
+ version 12.0.4.191. */
+
+ .file "opaque-pointer.c"
+ .data
+ .comm p_struct,8,8
+ .global p_struct#
+
+ .section .debug_info
+ .align 1
+debug_info_seg1:
+ .4byte debug_info_seg1_end - 1f /* Length of compilation unit info. */
+1:
+ .2byte 0x0002 /* DWARF version number. */
+ .4byte .debug_abbrev_seg1 /* Points to abbrev section for this unit. */
+ .byte 0x04 /* Target address size. */
+
+ .byte 0x01 /* DIE 1: DW_TAG_compile_unit. */
+ .byte 0x01 /* DW_AT_language = DW_LANG_C89. */
+ .ascii "Intel(R) C Intel(R) 64 Compiler XE " /* DW_AT_producer. */
+ .ascii "for applications running on Intel(R) 64, "
+ .ascii "Version 12.0.4.191 Build 20110427\n "
+ .asciz "Fixes SameLinkageName MemberPointers"
+
+ .byte 0x02 /* DIE 2: DW_TAG_variable. */
+ .byte 0x01 /* DW_AT_accessibility. */
+ .asciz "p_struct" /* DW_AT_name. */
+ .4byte 3f - debug_info_seg1 /* DW_AT_type. */
+ .2byte 0x0305 /* DW_AT_location: 5 bytes, DW_OP_addr */
+ .4byte p_struct /* followed by the address of p_struct. */
+ .byte 0x01 /* DW_AT_external. */
+
+3:
+ .byte 0x03 /* DIE 3: DW_TAG_pointer_type. */
+ .4byte 4f - debug_info_seg1 /* DW_AT_type. */
+
+4:
+ .byte 0x04 /* DIE 4: DW_TAG_structure_type. */
+ .byte 0x01 /* DW_AT_accessibility. */
+ .byte 0x00 /* DW_AT_byte_size. */
+ .asciz "opaque_struct_t" /* DW_AT_name. */
+
+ .byte 0x00 /* End DIE 1. */
+debug_info_seg1_end:
+
+ .section .debug_abbrev
+.debug_abbrev_seg1:
+ .align 1
+ .byte 0x01 /* Abbrev 1. */
+ .byte 0x11 /* DW_TAG_compile_unit. */
+ .byte 0x01 /* DW_CHILDREN_yes. */
+ .byte 0x13 /* DW_AT_language. */
+ .byte 0x0b /* DW_FORM_data1. */
+ .byte 0x25 /* DW_AT_producer. */
+ .byte 0x08 /* DW_AT_string. */
+ .2byte 0x0000 /* End abbrev. */
+
+ .byte 0x02 /* Abbrev 2. */
+ .byte 0x34 /* DW_TAG_variable. */
+ .byte 0x00 /* DW_CHILDREN_no. */
+ .byte 0x32 /* DW_AT_accessibility. */
+ .byte 0x0b /* DW_FORM_data1. */
+ .byte 0x03 /* DW_AT_name. */
+ .byte 0x08 /* DW_FORM_string. */
+ .byte 0x49 /* DW_AT_type. */
+ .byte 0x13 /* DW_FORM_ref4. */
+ .byte 0x02 /* DW_AT_location. */
+ .byte 0x0a /* DW_FORM_block1. */
+ .byte 0x3f /* DW_AT_external. */
+ .byte 0x0c /* DW_FORM_flag. */
+ .2byte 0x0000 /* End abbrev. */
+
+ .byte 0x03 /* Abbrev 3. */
+ .byte 0x0f /* DW_TAG_pointer_type. */
+ .byte 0x00 /* DW_CHILDREN_no. */
+ .byte 0x49 /* DW_AT_type. */
+ .byte 0x13 /* DW_FORM_ref4. */
+ .2byte 0x0000 /* End abbrev. */
+
+ .byte 0x04 /* Abbrev 4. */
+ .byte 0x13 /* DW_TAG_structure_type. */
+ .byte 0x00 /* DW_CHILDREN_no. */
+ .byte 0x32 /* DW_AT_accessibility. */
+ .byte 0x0b /* DW_FORM_data1. */
+ .byte 0x0b /* DW_AT_byte_size. */
+ .byte 0x0b /* DW_FORM_data1. */
+ .byte 0x03 /* DW_AT_name. */
+ .byte 0x08 /* DW_FORM_string. */
+ .2byte 0x0000 /* End abbrev. */
+ .byte 0x00 /* End abbrev table. */
+
+
+ .file "opaque-struct.c"
+ .section .debug_info
+ .align 1
+debug_info_seg2:
+ .4byte debug_info_seg2_end - 1f /* Length of compilation unit info. */
+1:
+ .2byte 0x0002 /* DWARF version number. */
+ .4byte .debug_abbrev_seg2 /* Points to abbrev section for this unit. */
+ .byte 0x04 /* Target address size. */
+
+ .byte 0x01 /* DIE 1: DW_TAG_compile_unit. */
+ .byte 0x01 /* DW_AT_language = DW_LANG_C89. */
+ .ascii "Intel(R) C Intel(R) 64 Compiler XE " /* DW_AT_producer. */
+ .ascii "for applications running on Intel(R) 64, "
+ .ascii "Version 12.0.4.191 Build 20110427\n "
+ .asciz "Fixes SameLinkageName MemberPointers"
+
+ .byte 0x02 /* DIE 2: DW_TAG_structure_type. */
+ .byte 0x01 /* DW_AT_accessibility. */
+ .byte 0x04 /* DW_AT_byte_size. */
+ .asciz "opaque_struct_t" /* DW_AT_name. */
+
+
+ .byte 0x03 /* DIE 3: DW_TAG_member. */
+ .2byte 0x2302 /* DW_AT_data_member_location, 2 bytes, */
+ .byte 0x00 /* DW_OP_plus_uconst followed by zero. */
+ .asciz "wrapped_value" /* DW_AT_name. */
+ .4byte 4f - debug_info_seg2 /* DW_AT_type. */
+ .byte 0x00
+
+4:
+ .byte 0x04 /* DIE 4: DW_TAG_base_type. */
+ .byte 0x04 /* DW_AT_byte_size. */
+ .byte 0x05 /* DW_AT_encoding. */
+ .asciz "int" /* DW_AT_name. */
+
+ .byte 0x00 /* End DIE 1. */
+debug_info_seg2_end:
+
+ .section .debug_abbrev
+.debug_abbrev_seg2:
+ .align 1
+ .byte 0x01 /* Abbrev 1. */
+ .byte 0x11 /* DW_TAG_compile_unit. */
+ .byte 0x01 /* DW_CHILDREN_yes. */
+ .byte 0x13 /* DW_AT_language. */
+ .byte 0x0b /* DW_FORM_data1. */
+ .byte 0x25 /* DW_AT_producer. */
+ .byte 0x08 /* DW_FORM_string. */
+ .2byte 0x0000 /* End abbrev. */
+
+ .byte 0x02 /* Abbrev 2. */
+ .byte 0x13 /* DW_TAG_structure_type. */
+ .byte 0x01 /* DW_CHILDREN_yes. */
+ .byte 0x32 /* DW_AT_accessibility. */
+ .byte 0x0b /* DW_FORM_data1. */
+ .byte 0x0b /* DW_AT_byte_size. */
+ .byte 0x0b /* DW_FORM_data1. */
+ .byte 0x03 /* DW_AT_name. */
+ .byte 0x08 /* DW_FORM_string. */
+ .2byte 0x0000 /* End abbrev. */
+
+ .byte 0x03 /* Abbrev 3. */
+ .byte 0x0d /* DW_TAG_member. */
+ .byte 0x00 /* DW_CHILDREN_no. */
+ .byte 0x38 /* DW_AT_data_member_location. */
+ .byte 0x0a /* DW_FORM_block1. */
+ .byte 0x03 /* DW_AT_name. */
+ .byte 0x08 /* DW_FORM_string. */
+ .byte 0x49 /* DW_AT_type. */
+ .byte 0x13 /* DW_FORM_ref4. */
+ .2byte 0x0000 /* End abbrev. */
+
+ .byte 0x04 /* Abbrev 4. */
+ .byte 0x24 /* DW_TAG_base_type. */
+ .byte 0x00 /* DW_CHILDREN_no. */
+ .byte 0x0b /* DW_AT_byte_size. */
+ .byte 0x0b /* DW_FORM_data1. */
+ .byte 0x3e /* DW_AT_encoding. */
+ .byte 0x0b /* DW_FORM_data1. */
+ .byte 0x03 /* DW_AT_name. */
+ .byte 0x08 /* DW_FORM_string. */
+ .2byte 0x0000 /* End abbrev. */
+ .byte 0x00 /* End abbrev table. */
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.exp b/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.exp
new file mode 100644
index 0000000..1c7bea5
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-icc-opaque.exp
@@ -0,0 +1,41 @@
+# Copyright (C) 2011-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
+
+# Test that we can correctly resolve opaque structures compiled by the Intel
+# compiler, which does not set DW_AT_declaration on opaque structure types.
+# This is GDB PR symtab/13277.
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if {![dwarf2_support]} {
+ return 0
+}
+
+set testfile "dw2-icc-opaque"
+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
+
+# Before PR 13277 was fixed, this would output:
+# type = struct opaque_struct_t {
+# <no data fields>
+# } *
+gdb_test "ptype p_struct" "type = struct opaque_struct_t {\r\n *int wrapped_value;\r\n} \\*"