[RFC] builtin for structure pretty printing

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[RFC] builtin for structure pretty printing

Anastasia Stulova via cfe-dev
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 ! 🙂


Paul Semel
cfe-dev mailing list
[hidden email]