[cfe-dev] [RFC] builtin for structure pretty printing
Paul Semel via cfe-dev
cfe-dev at lists.llvm.org
Mon Mar 5 08:30:45 PST 2018
Hi devs,
I have recently posted a patch here : https://reviews.llvm.org/D44093 and I
would like to have your advices on how this feature might be useful in a
production build. (reviews are also appreciated 🙂)
This idea is to basically provide a builtin that permits to dump the content of
a structure at runtime.
Here is how I am currently using it :
struct test {
char *a;
int b;
};
int main(void)
{
struct test t = {
.a = "TEST",
.b = 1234
};
__builtin_dump_struct(&t, &printf);
}
And here is the output I am basically getting :
$ ./main
struct test {
char * a : TEST
int b : 1234
}
I started developing this feature while doing some kernel development. Indeed,
it can sometimes be really hard to get a debugger working and thus do this job
for us, and I am often in the need to write my own pretty printing functions for
each of my structures. I know this is also the case for other people doing
kernel development, that's why I started developing this.
Please feel free to give your feedback on this one, any help is appreciated ! 🙂
Thanks,
--
Paul Semel
More information about the cfe-dev
mailing list