Accessing program information that gdb sees in C++
I remember using libbfd to get function names from object files. It's a library for reading object formats, maybe you can also read other debug information using this. (I don't know to be honest)
I have a program written in C++, on Linux, compiled with -g.
When I run it under gdb, I can
1) set breakpoints 2) at those breakpoints, print out variables 3) see the stackframe 4) given a variable that's a structure, print out parts of the structure (i.e. how ddd displays information).
Now, given that my program is compiled with "-g" -- is there anyway that I can access this power within my program itself?
I.e. given that my program is compiled with "-g", is there some
function I can call to get the current stackframe at the current point of execution?
Given a pointer to an object and it's type ... can I do
I realize the default answer is "no, C++ doesn't support that level of introspection" -- however, recall I'm on linux, my program is compiled with "-g", and gdb can do it, so clearly the inforamtion is there. Question is: is there some API for accessing it?
EDIT: PS Naysers, I'd love to see a reason for closing this question.