Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] PR symtab/13277: Resolving opaque structures in ICC generated binaries.
@ 2011-10-16  8:03 John Steele Scott
  2011-10-19  9:01 ` Jan Kratochvil
  0 siblings, 1 reply; 37+ messages in thread
From: John Steele Scott @ 2011-10-16  8:03 UTC (permalink / raw)
  To: gdb-patches

ICC does not set DW_AT_declaration on opaque structure declarations, so
gdb will show such structures as "<no data fields>" unless executing code
within the compilation unit which contains the complete declaration.

However, ICC does set DW_AT_byte_size to zero on opaque declarations.

This patch adds a check for DW_AT_byte_size == 0 with producer == ICC to
allow gdb to resolve opaque structures in binaries which were built with
ICC.

See http://sourceware.org/bugzilla/show_bug.cgi?id=13277 for more
details, including an example.

Changelog:

2011-10-16  John Steele Scott

     PR symtab/13277: Resolving opaque structures in ICC generated binaries.
     * symtab.c (producer_is_icc): New function.
     * symtab.h (producer_is_icc): Declare.
     * dwarf2read.c (read_structure_type): Set TYPE_STUB on structures
     with a byte size of zero, if the binary was produced by ICC.

--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7636,6 +7636,11 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
      /* RealView does not output the required DW_AT_declaration
         on incomplete types.  */
      TYPE_STUB (type) = 1;
+  else if (attr != NULL&&  die->child == NULL&&  TYPE_LENGTH (type) == 0
+	&&  producer_is_icc (cu->producer))
+    /* ICC does not output the required DW_AT_declaration
+       on incomplete types, but gives them a size of zero.  */
+    TYPE_STUB (type) = 1;

    /* We need to add the type field to the die immediately so we don't
       infinitely recurse when dealing with pointers to the structure
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 9447bd9..ffaa035 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4806,6 +4806,20 @@ producer_is_realview (const char *producer)
    return 0;
  }

+int
+producer_is_icc (const char *producer)
+{
+  static const char *const icc_ident = "Intel(R) C Intel(R) 64 Compiler XE";
+
+  if (producer == NULL)
+    return 0;
+
+  if (strncmp (producer, icc_ident, strlen (icc_ident)) == 0)
+    return 1;
+
+  return 0;
+}
+
  void
  _initialize_symtab (void)
  {
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 90a6fe4..987f199 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1302,6 +1302,10 @@ extern struct symtabs_and_lines expand_line_sal (struct symtab_and_line sal);
     compiler (armcc).  */
  int producer_is_realview (const char *producer);

+/* Return 1 if the supplied producer string matches the Intel C/C++
+   compiler (icc).  */
+int producer_is_icc (const char *producer);
+
  void fixup_section (struct general_symbol_info *ginfo,
  		    CORE_ADDR addr, struct objfile *objfile);




^ permalink raw reply	[flat|nested] 37+ messages in thread
* [patch] PR symtab/13277: Resolving opaque structures in ICC generated binaries.
@ 2011-10-16  7:58 John Steele Scott
  0 siblings, 0 replies; 37+ messages in thread
From: John Steele Scott @ 2011-10-16  7:58 UTC (permalink / raw)
  To: gdb-patches

ICC does not set DW_AT_declaration on opaque structure declarations, so 
gdb will show such structures as "<no data fields>" unless executing 
code within the compilation unit which contains the complete declaration.

However, ICC does set DW_AT_byte_size to zero on opaque declarations.

This patch adds a check for DW_AT_byte_size == 0 with producer == ICC to 
allow gdb to resolve opaque structures in binaries which were built with 
ICC.

See http://sourceware.org/bugzilla/show_bug.cgi?id=13277 for more 
details, including an example.

Changelog:

2011-10-16  John Steele Scott <toojays@toojays.net>

     PR symtab/13277: Resolving opaque structures in ICC generated binaries.
     * symtab.c (producer_is_icc): New function.
     * symtab.h (producer_is_icc): Declare.
     * dwarf2read.c (read_structure_type): Set TYPE_STUB on structures
     with a byte size of zero, if the binary was produced by ICC.

--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7636,6 +7636,11 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
      /* RealView does not output the required DW_AT_declaration
         on incomplete types.  */
      TYPE_STUB (type) = 1;
+  else if (attr != NULL&&  die->child == NULL&&  TYPE_LENGTH (type) == 0
+	&&  producer_is_icc (cu->producer))
+    /* ICC does not output the required DW_AT_declaration
+       on incomplete types, but gives them a size of zero.  */
+    TYPE_STUB (type) = 1;

    /* We need to add the type field to the die immediately so we don't
       infinitely recurse when dealing with pointers to the structure
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 9447bd9..ffaa035 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4806,6 +4806,20 @@ producer_is_realview (const char *producer)
    return 0;
  }

+int
+producer_is_icc (const char *producer)
+{
+  static const char *const icc_ident = "Intel(R) C Intel(R) 64 Compiler XE";
+
+  if (producer == NULL)
+    return 0;
+
+  if (strncmp (producer, icc_ident, strlen (icc_ident)) == 0)
+    return 1;
+
+  return 0;
+}
+
  void
  _initialize_symtab (void)
  {
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 90a6fe4..987f199 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1302,6 +1302,10 @@ extern struct symtabs_and_lines expand_line_sal (struct symtab_and_line sal);
     compiler (armcc).  */
  int producer_is_realview (const char *producer);

+/* Return 1 if the supplied producer string matches the Intel C/C++
+   compiler (icc).  */
+int producer_is_icc (const char *producer);
+
  void fixup_section (struct general_symbol_info *ginfo,
  		    CORE_ADDR addr, struct objfile *objfile);




^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2012-05-24 23:06 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-16  8:03 [patch] PR symtab/13277: Resolving opaque structures in ICC generated binaries John Steele Scott
2011-10-19  9:01 ` Jan Kratochvil
2011-10-19 13:54   ` Jan Kratochvil
2011-10-23 18:29     ` John Steele Scott
2011-10-24  0:13       ` Joel Brobecker
2011-10-27 19:57       ` Tom Tromey
2011-10-23 10:26   ` John Steele Scott
2011-10-26 23:09     ` Jan Kratochvil
2011-11-13 11:38       ` [patch] PR symtab/13277: Resolving opaque structures in ICC generated binaries. (testcase) John Steele Scott
2011-11-15 17:04         ` Tom Tromey
2012-05-05  2:40           ` John Steele Scott
2012-05-05 15:16             ` Joel Brobecker
2012-05-05 15:36               ` Jan Kratochvil
2012-05-12  9:00               ` John Steele Scott
2012-05-12 18:38                 ` Jan Kratochvil
2012-05-12 19:09                   ` Joel Brobecker
2012-05-21 12:05                   ` John Steele Scott
2012-05-21 12:08                     ` John Steele Scott
2012-05-24 23:06                       ` [commit] " Jan Kratochvil
2012-05-21 12:17                     ` Jan Kratochvil
2011-11-13 12:13       ` [patch] PR symtab/13277: Resolving opaque structures in ICC generated binaries John Steele Scott
2011-11-15 17:19         ` Tom Tromey
2011-11-15 23:58           ` Jan Kratochvil
2012-05-05  2:32           ` John Steele Scott
2012-05-12 18:37             ` Jan Kratochvil
2012-05-14 13:55               ` John Steele Scott
     [not found]                 ` <20120518144642.GA19690@host2.jankratochvil.net>
2012-05-20 12:34                   ` John Steele Scott
     [not found]                     ` <20120520130919.GA6990@host2.jankratochvil.net>
2012-05-20 13:17                       ` Jan Kratochvil
2012-05-20 13:44                         ` John Steele Scott
2012-05-23 23:29                         ` John Steele Scott
2012-05-24 15:16                           ` Pedro Alves
2012-05-24 22:13                           ` [commit] " Jan Kratochvil
2012-05-24 23:05                             ` John Steele Scott
2012-05-24 22:16                         ` [commit TYPE_OPAQUE] " Jan Kratochvil
2012-05-21  0:12                     ` Doug Evans
2012-05-20 13:17                   ` Jan Kratochvil
  -- strict thread matches above, loose matches on Subject: below --
2011-10-16  7:58 John Steele Scott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox