How do you extract local variable information (address and type) from a Delphi program or the compiler-generated debug info?

Solution 1:

Check if any debugging symbols weren't in binary. Also possible is using GDB (on Windows a port of it). It would be great if you found a .dbg or .dSYM file. They contain source code, eg.

gdb> list foo
56 void foo()
57 {
58  bar();
59  sighandler_t fnc = signal(SIGHUP, SIG_IGN);
60  raise(SIGHUP);
61  signal(SIGHUP, fnc);
62  baz(fnc);
63 }

If you don't have any debugging files, you may try to get MinGW or Cygwin, and use nm(1) (man page). It will read symbol names from binary. They may contain some types, like C++ ones:

int abc::def::Ghi::jkl(const std::string, int, const void*)

Don't forget to add --demangle option then or you'll get something like:

__ZN11MRasterFont21getRasterForCharacterEh

instead of:

MRasterFont::getRasterForCharacter(unsigned char)