how to figure if a struct symbol is incomplete

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I’m toying around with a new sparse-based program, trying to check for certain things in C structs definitions.

I’ve looked around at examples and ctags was the most useful as it’s using ‘file_scope’ as the symbol entry point instead of the sparse() return value, which allowed me to see the AST of the types.
After some trial and error, I've figured that I had to call examine_symbol_type() on each symbol before I dive into them to fully compute the bit_size & offset of all the struct members.

While doing that, I've noticed that I cannot tell an empty structure from an incompletely defined one.
I'd like to err out instead of silently using a size=0 struct when I see an undefined type.

struct empty {};
struct foo {
    int a;
    struct unknown b;
};

The symbol for 'struct empty' and the member 'b' both have a sym->size == 0, an empty sym->symbol_list and a sym->ctype.base_type == NULL.
How can you tell those 2 cases apart?

Thanks





[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux