This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Having trouble printing the subvars of structs, under certain conditions
- From: =?big5?b?w0OnZah8?= <ton60615 at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Sun, 7 Jun 2009 19:04:42 -0800
- Subject: Having trouble printing the subvars of structs, under certain conditions
I am using gcc 4.1.1 to do research involving gimple. For this work I need to
know the sizes of all of my variables, without running the program and calling
"sizeof".
To accomplish this, I inserted a call to:
dump_referenced_vars(dump_file_ptr);
At first, everything looked fine. The output looks something like this:
...
Variable: ibin, UID 1428, char[16], is global, call clobbered, default
def: ibin_100
Variable: ie, UID 1429, struct great, sub-vars: { SFT.124 SFT.123 SFT.122 }
Variable: itmp, UID 1430, long unsigned int
...
>From this information, I can work out the sizes of all 3 variables
(ibin, ie, and itmp).
The ie variable is a struct with 3 subbvariables (SFT.124, SFT.123,SFT.122).
To compute the size of ie, I need to recursively find the name of each
subvar, but this is not the problem that I want to ask about.
The problem is that the subvars of a struct do not always print. I
specifically see that it does not print subvars if one of the subvars
is an array or itself
a struct. For example, here is a code snippet for a struct with an
array element:
typedef struct card{ int a; char *b; float c[10];} cardtyp;
static cardtyp c1;
And here is the dump_referenced_vars output for it:
Variable: c1, UID 1916, struct cardtyp, is global, call clobbered,
default def: c1_1
Notice that it does not list the subvars, so I cannot catch the size
of cardtype.
It also does not print subvars for arrays of struct variables:
Variable: kns, UID 1272, struct great[17], is addressable, is global,
call clobbered, default def: kns_29
So how can I get this information? (By the way, I'm not particularly
concerned with referenced variables. I would be even happier to have
the information
for all variables, whether referenced or not.)
Thank you for your help,
Cheng-Yu