public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Strange structure declaration in ASG
@ 2001-11-14  1:22 Guillaume
  0 siblings, 0 replies; 2+ messages in thread
From: Guillaume @ 2001-11-14  1:22 UTC (permalink / raw)
  To: gcc-help





Hello,

 I'm student and I'm trying to build a tool which use the ASG given by g++
using the option -fdump-ast-original. Actually I build a basic parser
which reads the file file.c.original and stores the ASG in memory in a
hash table where the key is the number of a node. I also build a visitor which
visits the ASG in memory and extracts a CFG for some analysis. My problem
is the following (my tool works with C files):

The information given by gcc (g++ -fdump-ast-original file.c) is strange
(I found but I'm not an expert) regarding the description of structure.
For exemple for this sample:

-----
typedef struct {
        int entier;
        char car;
} structure;
-----

it produced :

-----
...
@29     record_type      name: @32      size: @5       algn: 32
                         struct         flds: @33      fncs: @34
                         binf: @35
@30     var_decl         name: @36      type: @6       scpe: @1
                         srcp: simple3.c:17            size: @12
                         algn: 32       used: 1
@31     expr_stmt        line: 19       expr: @37      next: @38
@32     type_decl        name: @39      type: @29      srcp: simple3.c:7
@33     field_decl       name: @40      type: @6       scpe: @29
                         srcp: simple3.c:5             public
                         size: @12      algn: 32       bpos: @41
@34     function_decl    name: @42      type: @43      scpe: @29
                         srcp: simple3.c:3             artificial
                         member         public         operator
                         args: @44      undefined      static
@35     binfo            type: @29
@36     identifier_node  strg: j        lngt: 1
@37     modify_expr      type: @6       op 0: @45      op 1: @46
@38     expr_stmt        line: 20       expr: @47      next: @48
@39     identifier_node  strg: structure               lngt: 9
@40     identifier_node  strg: entier   lngt: 6
@41     integer_cst      type: @10      low : 0
@42     identifier_node  operator
@43     method_type      unql: @49      size: @5       algn: 64
                         clas: @29      retn: @50      prms: @51
@44     parm_decl        name: @52      type: @53      srcp: simple3.c:3
                         artificial     argt: @53      size: @54
                         algn: 32       used: 0        register
@45     component_ref    op 0: @23      op 1: @33
@46     integer_cst      type: @6       low : 5
@47     modify_expr      type: @6       op 0: @30      op 1: @55
@48     expr_stmt        line: 22       expr: @56      next: @57
@49     method_type      size: @5       algn: 64       clas: @29
                         retn: @50      prms: @51
@50     reference_type   size: @54      algn: 32       refd: @29
@51     tree_list        valu: @58      chan: @59
@52     identifier_node  strg: this     lngt: 4
@53     pointer_type     qual: c        unql: @58      size: @54
                         algn: 32       ptd : @29
@54     integer_cst      type: @10      low : 32
@55     integer_cst      type: @6       low : 3
@56     modify_expr      type: @6       op 0: @60      op 1: @61
@57     scope_stmt       line: 24       begn           null
                         clnp           next: @62
@58     pointer_type     size: @54      algn: 32       ptd : @29
@59     tree_list        valu: @63      chan: @7
...
-----

So, I see the structure (as a record_type), I see one field "entier"
but, there is no trace of the second field "car".

For my analysis, I need to recover this information at the beginning of
the ASG not when using it ("car" appeared in the ASG when it is used). So,
I try to look at gcc source code to see if I can modify the source to
recover  this information during the dump of the ASG. I found where
the dump is started in the code source (c-dump.c : "dump_begin()") but, I
didn't understand exactely what functions splay_tree_* do and
where it is declared?

So if someone can give me some hints on how to modify source code to dump
more information about structures declaration, and about what function
splay_tree_* do it will be nice.

Thanks for your help,
Sorry for my english,

---
Guillaume Thouvenin
Gasta - Gcc Abstract Syntax Tree Analysis
http://gasta.sf.net



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

* Strange structure declaration in ASG
@ 2001-11-13 12:08 Guillaume
  0 siblings, 0 replies; 2+ messages in thread
From: Guillaume @ 2001-11-13 12:08 UTC (permalink / raw)
  To: gcc-help

Hello,

 I'm student and I'm trying to build a tool which use the ASG given by g++
using the option -fdump-ast-original. Actually I build a basic parser
which reads the file file.c.original and stores the ASG in memory in a
hash table where the key is the number of a node. I also build a visitor which
visits the ASG in memory and extracts a CFG for some analysis. My problem
is the following (my tool works with C files):

The information given by gcc (g++ -fdump-ast-original file.c) is strange
(I found but I'm not an expert) regarding the description of structure.
For exemple for this sample:

-----
typedef struct {
        int entier;
        char car;
} structure;
-----

it produced :

-----
...
@29     record_type      name: @32      size: @5       algn: 32
                         struct         flds: @33      fncs: @34
                         binf: @35
@30     var_decl         name: @36      type: @6       scpe: @1
                         srcp: simple3.c:17            size: @12
                         algn: 32       used: 1
@31     expr_stmt        line: 19       expr: @37      next: @38
@32     type_decl        name: @39      type: @29      srcp: simple3.c:7
@33     field_decl       name: @40      type: @6       scpe: @29
                         srcp: simple3.c:5             public
                         size: @12      algn: 32       bpos: @41
@34     function_decl    name: @42      type: @43      scpe: @29
                         srcp: simple3.c:3             artificial
                         member         public         operator
                         args: @44      undefined      static
@35     binfo            type: @29
@36     identifier_node  strg: j        lngt: 1
@37     modify_expr      type: @6       op 0: @45      op 1: @46
@38     expr_stmt        line: 20       expr: @47      next: @48
@39     identifier_node  strg: structure               lngt: 9
@40     identifier_node  strg: entier   lngt: 6
@41     integer_cst      type: @10      low : 0
@42     identifier_node  operator
@43     method_type      unql: @49      size: @5       algn: 64
                         clas: @29      retn: @50      prms: @51
@44     parm_decl        name: @52      type: @53      srcp: simple3.c:3
                         artificial     argt: @53      size: @54
                         algn: 32       used: 0        register
@45     component_ref    op 0: @23      op 1: @33
@46     integer_cst      type: @6       low : 5
@47     modify_expr      type: @6       op 0: @30      op 1: @55
@48     expr_stmt        line: 22       expr: @56      next: @57
@49     method_type      size: @5       algn: 64       clas: @29
                         retn: @50      prms: @51
@50     reference_type   size: @54      algn: 32       refd: @29
@51     tree_list        valu: @58      chan: @59
@52     identifier_node  strg: this     lngt: 4
@53     pointer_type     qual: c        unql: @58      size: @54
                         algn: 32       ptd : @29
@54     integer_cst      type: @10      low : 32
@55     integer_cst      type: @6       low : 3
@56     modify_expr      type: @6       op 0: @60      op 1: @61
@57     scope_stmt       line: 24       begn           null
                         clnp           next: @62
@58     pointer_type     size: @54      algn: 32       ptd : @29
@59     tree_list        valu: @63      chan: @7
...
-----

So, I see the structure (as a record_type), I see one field "entier"
but, there is no trace of the second field "car".

For my analysis, I need to recover this information at the beginning of
the ASG not when using it ("car" appeared in the ASG when it is used). So,
I try to look at gcc source code to see if I can modify the source to
recover  this information during the dump of the ASG. I found where
the dump is started in the code source (c-dump.c : "dump_begin()") but, I
didn't understand exactely what functions splay_tree_* do and
where it is declared?

So if someone can give me some hints on how to modify source code to dump
more information about structures declaration, and about what function
splay_tree_* do it will be nice.

Thanks for your help,
Sorry for my english,

---
Guillaume Thouvenin
Gasta - Gcc Abstract Syntax Tree Analysis
http://gasta.sf.net


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

end of thread, other threads:[~2001-11-22  7:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-14  1:22 Strange structure declaration in ASG Guillaume
  -- strict thread matches above, loose matches on Subject: below --
2001-11-13 12:08 Guillaume

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