Need a structure analyzer C

Let's say I have a file system.hin which I have the following structures

typedef struct Foo {
  int count;
  uint32 world;
  Temp id;
} Foo;

typedef struct Temp {
  uint64 id;
} Temp;

Foo bar;

Now I need a macro, something like DUMP_STRUCT(bar), which recursively prints all the elements of a bar (like Foo).

Is there any parser / script (preferably in php / python) that can parse a C file or get information from a dwarf from an executable and create a function similar to DUMP_STRUCT?

+3
source share
4 answers

There seems to be Python bindings for libclang that should be able to do what you want. There is also a pycparser project .

+2
source

C , C (, , ), C .

GCC-XML , ( "C" , ++) XML-; , . , , ( XML- /).

DMS Software Rengineering Toolkit C Front End // . GCC-XML- , DMS, AST, , . , , ( ). DMS , , , .

+1

GCCXML, C ( ) ++ XML.

+1

You can get a run from learning how pstruct works . (I think of it in perl, but it uses stab compilers to debug information to display information about the structure structure).

+1
source

All Articles