From: Aurelien Aptel <aaptel@nvidia.com>
To: "linux-sparse@vger.kernel.org" <linux-sparse@vger.kernel.org>
Subject: how to figure if a struct symbol is incomplete
Date: Thu, 17 Oct 2024 09:09:04 +0000 [thread overview]
Message-ID: <SJ2PR12MB8943C1A7AF702D739C892D8DA5472@SJ2PR12MB8943.namprd12.prod.outlook.com> (raw)
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
reply other threads:[~2024-10-17 9:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=SJ2PR12MB8943C1A7AF702D739C892D8DA5472@SJ2PR12MB8943.namprd12.prod.outlook.com \
--to=aaptel@nvidia.com \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).