public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/13277] New: gdb does not resolve opaque structures in binaries compiled with ICC.
@ 2011-10-09 10:27 toojays at toojays dot net
  2011-10-09 10:32 ` [Bug symtab/13277] " toojays at toojays dot net
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: toojays at toojays dot net @ 2011-10-09 10:27 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13277

             Bug #: 13277
           Summary: gdb does not resolve opaque structures in binaries
                    compiled with ICC.
           Product: gdb
           Version: 7.3
            Status: NEW
          Severity: normal
          Priority: P2
         Component: symtab
        AssignedTo: unassigned@sourceware.org
        ReportedBy: toojays@toojays.net
    Classification: Unclassified


gdb does not resolve opaque structures in binaries compiled with ICC.

An example program using a pointer to an opaque structure looks like:

$ cat opaque.c
#include <stdio.h>
#include <stdlib.h>

struct opaque_t
  {
   int wrapped_value;
  };

struct opaque_t *opaque_create (int initializer)
{
 struct opaque_t *opaque = malloc(sizeof(struct opaque_t));

 if (opaque != NULL)
    opaque->wrapped_value = initializer;

 return opaque;
}

void opaque_print (struct opaque_t *p_opaque)
{
 printf("value is %d.\n", p_opaque->wrapped_value);
}

void opaque_destroy (struct opaque_t *p_opaque)
{
 free(p_opaque);
}

$ cat main.c 
#include <stdlib.h>

#include "opaque.h"

int main ()
{
 struct opaque_t *p_opaque = opaque_create(1234);

 if (p_opaque == NULL)
    return 1;

 opaque_print(p_opaque);
 opaque_destroy(p_opaque);

 return 0;
}

If I break this program at line 12 of main.c, and try to print p_opaque, gdb
complains "no data fields":

Breakpoint 1, main () at main.c:12
12     opaque_print(p_opaque);
(gdb) print *p_opaque
$1 = {<No data fields>}

But if I step into a function in opaque.c, gdb *can* see into the structure:

(gdb) step
opaque_print (p_opaque=0xc51e010) at opaque.c:21
21     printf("value is %d.\n", p_opaque->wrapped_value);
(gdb) print *p_opaque
$2 = {wrapped_value = 1234}

This case works fine when the program is compiled with GCC. Does not work with
ICC, even when compiled with "-debug extended".

The problem seems to be that ICC does not set the DW_AT_declaration attribute
on the opaque pointer in main.c.

dwarfdumps of binaries produced with GCC and ICC follow.

This binary was produced with 'CC="gcc -g" make':
jscott@saaz:~/src/random/gdb-icc-opaque$ dwarfdump -S match=opaque_t
opaque-demo

COMPILE_UNIT<header overall offset = 0>:
<0><   11>    DW_TAG_compile_unit
        DW_AT_producer              GNU C 4.4.5
        DW_AT_language              DW_LANG_C89
        DW_AT_name                  main.c
        DW_AT_comp_dir              /home/jscott/src/random/gdb-icc-opaque
        DW_AT_low_pc                0x400584
        DW_AT_high_pc               0x4005c7
        DW_AT_stmt_list             0

LOCAL_SYMBOLS:
<1><  125>    DW_TAG_subprogram
        DW_AT_external              yes(1)
        DW_AT_name                  main
        DW_AT_decl_file             1
/home/jscott/src/random/gdb-icc-opaque/main.c
        DW_AT_decl_line             5
        DW_AT_type                  <52>
        DW_AT_low_pc                0x400584
        DW_AT_high_pc               0x4005c7
        DW_AT_frame_base            <loclist with 3 entries follows>
            [ 0]<lowpc=0x0><highpc=0x1>DW_OP_breg7+8
            [ 1]<lowpc=0x1><highpc=0x4>DW_OP_breg7+16
            [ 2]<lowpc=0x4><highpc=0x43>DW_OP_breg6+16
        DW_AT_sibling               <182>
<2><  161>    DW_TAG_structure_type
        DW_AT_name                  opaque_t
        DW_AT_declaration           yes(1)

COMPILE_UNIT<header overall offset = 189>:
<0><   11>    DW_TAG_compile_unit
        DW_AT_producer              GNU C 4.4.5
        DW_AT_language              DW_LANG_C89
        DW_AT_name                  opaque.c
        DW_AT_comp_dir              /home/jscott/src/random/gdb-icc-opaque
        DW_AT_low_pc                0x4005c8
        DW_AT_high_pc               0x400639
        DW_AT_stmt_list             63

LOCAL_SYMBOLS:
<1><  125>    DW_TAG_structure_type
        DW_AT_name                  opaque_t
        DW_AT_byte_size             4
        DW_AT_decl_file             1
/home/jscott/src/random/gdb-icc-opaque/opaque.c
        DW_AT_decl_line             5
        DW_AT_sibling               <152>



This binary was produced with 'CC="icc -debug extended" make':

jscott@saaz:~/src/random/gdb-icc-opaque$ dwarfdump -S match=opaque_t
opaque-demo-icc-12.0.4 

COMPILE_UNIT<header overall offset = 0>:
<0><   11>    DW_TAG_compile_unit
        DW_AT_comp_dir              /root/gdb-icc-opaque
        DW_AT_low_pc                0x40059c
        DW_AT_language              DW_LANG_C89
        DW_AT_name                  main.c
        DW_AT_producer              Intel(R) C Intel(R) 64 Compiler XE for
applications running on Intel(R) 64, Version 12.0.4.191 Build 20110427
 Fixes SameLinkageName MemberPointers

        DW_AT_stmt_list             0

LOCAL_SYMBOLS:
<1><  275>    DW_TAG_structure_type
        DW_AT_decl_line             1
        DW_AT_decl_column           8
        DW_AT_decl_file             2 /root/gdb-icc-opaque/opaque.h
        DW_AT_accessibility         DW_ACCESS_public
        DW_AT_byte_size             0
        DW_AT_name                  opaque_t

COMPILE_UNIT<header overall offset = 294>:
<0><   11>    DW_TAG_compile_unit
        DW_AT_comp_dir              /root/gdb-icc-opaque
        DW_AT_low_pc                0x4005ec
        DW_AT_language              DW_LANG_C89
        DW_AT_name                  opaque.c
        DW_AT_producer              Intel(R) C Intel(R) 64 Compiler XE for
applications running on Intel(R) 64, Version 12.0.4.191 Build 20110427
 Fixes SameLinkageName MemberPointers

        DW_AT_stmt_list             121

LOCAL_SYMBOLS:
<1><  209>    DW_TAG_structure_type
        DW_AT_decl_line             4
        DW_AT_decl_column           8
        DW_AT_decl_file             1 /root/gdb-icc-opaque/opaque.c
        DW_AT_accessibility         DW_ACCESS_public
        DW_AT_byte_size             4
        DW_AT_name                  opaque_t

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-09 10:27 [Bug symtab/13277] New: gdb does not resolve opaque structures in binaries compiled with ICC toojays at toojays dot net
2011-10-09 10:32 ` [Bug symtab/13277] " toojays at toojays dot net
2011-10-09 10:40 ` toojays at toojays dot net
2011-10-10 19:04 ` tromey at redhat dot com
2011-10-16 21:48 ` toojays at toojays dot net
2011-11-13  9:18 ` toojays at toojays dot net
2012-05-24 22:09 ` cvs-commit at gcc dot gnu.org
2012-05-24 22:28 ` jan.kratochvil at redhat dot com

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).