c++ - Read debugging information at runtime from an application -


i have questions regarding debugging symbols , can done them, besides, well, debugging. i'm interested in answers regarding gcc, i'd happy know how looks under other compilers, including msvc.

first of all:

  • what common formats/types of debugging symbols?
  • how relate compilers , platforms? same format on gcc , mingw among platforms?
  • can check in runtime whether build has them , format in?

and more practical questions... how can i:

  • check current file , line number?
  • obtain (qualified) function name being executed?
  • obtain full current stack trace?

let me emphasize i'm talking run-time checks. of can read , pretty-printed gdb, don't know how info comes debugging symbols , how source code gdb has access to.

maybe there's library able parse debugging symbols , yield such information?

are debugging symbols standardised enough can expect degree of portability such solutions?

what common formats/types of debugging symbols?

dwarf , stabs (those embedded inside executable, in special sections), program database (pdb; external file, used msvc).

how relate compilers , platforms? same format on gcc , mingw among platforms?

gcc uses dwarf/stabs (i think it's gcc compile-time option) both on linux (elf) , windows (pe), don't know others. msvc uses pdb.

can check in runtime whether build has them , format in?

you can parse executable image , see if there sections debugging info (see stabs documentation , dwarf specs). pdb files distributed either executables or via symbol servers (so if don't want go online, check if there x.pdb x.exe/x.dll).

about how read , use symbols — don't know dwarf/stabs (there's around gnu binutils can locate , extract those), pdb best bet use dbghelp — usage pretty documented , there lot of examples available on net. there's dia sdk can used query pdb files.

are debugging symbols standardised enough can expect degree of portability such solutions?

dwarf has formal specification, , it's complicated hell. pdb afaik not documented, dbghelp/dia are, , recommended way.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -