|C structure analyzer ("Reflection" in C?) firstname.lastname@example.org (1999-07-19)|
|Re: C structure analyzer ("Reflection" in C?) email@example.com (Jan Gray) (1999-07-20)|
|Re: C structure analyzer ("Reflection" in C?) firstname.lastname@example.org (1999-07-21)|
|Re: C structure analyzer ("Reflection" in C?) email@example.com (Keith Thompson) (1999-07-23)|
|Re: C structure analyzer ("Reflection" in C?) firstname.lastname@example.org (Jerry Pendergraft) (1999-07-28)|
|Re: C structure analyzer ("Reflection" in C?) email@example.com (Norbert Berzen) (1999-07-30)|
|Re: C structure analyzer ("Reflection" in C?) firstname.lastname@example.org (Keith Thompson) (1999-07-30)|
|Re: C structure analyzer ("Reflection" in C?) email@example.com (Dibyendu Majumdar) (1999-07-30)|
|[2 later articles]|
|From:||"Jan Gray" <firstname.lastname@example.org>|
|Date:||20 Jul 1999 01:14:56 -0400|
|Keywords:||C, tools, comment|
email@example.com wrote in message 99-07-063...
> Does anybody know of a tool that I could use that converts the C
>structure definitions into some other source file that has each data
>member name, byte offset, size etc so that I could make a program to
>dynamically compose these "structures"?
> The annoying thing is, I know that somewhere in VC++ it has all
>of this and more because you can browse all of the data structures in
>a program from within the debugger.
> Does anyone know of a way to get VC++ to dump this information
>into some sort of "C source" file that can be included elsewhere?
I don't know, but here's some VC++-specific background and ideas.
By default, a "debug" VC++ build compiles -Zi, which reposits the
compiland's type, symbol, address, etc. debug information in a .pdb
(program database) file, which is then used for many purposes,
including debugging. But (as far as I know) the pdb interfaces are
Instead, compile with the -Z7 flag, which emits old-fashioned MS C7.0
style CodeView debug records into your object file or executable.
Then open this COFF file, find the debug info, and read the symbol and
type records. There you'll find LF_STRUCTURE type records for your
structure definitions, including field names, type indices, and field
offsets. Then recover the types themselves by walking the type graph
using the type indices. But that's a lot of fiddly work. See
http://msdn.microsoft.com/library/specs/S664F.HTM for the CodeView
Also check out the Microsoft Research Semantics-Based Tools Group's
"The goal of the AST ToolKit project is to provide product development
groups with a public API to a C++ program's parse tree, symbol table,
and types, as well as to provide us with an infrastructure for our own
research using product groups' code bases."
See http://research.microsoft.com/sbt/ for more information.
[I suspect it'd be easier to write some perl programs that understand
just enough C to process the structure declarations in the source than
to grovel through the COFF symbols. -John]
Return to the
Search the comp.compilers archives again.