I am investigating a crash, based on the available core dump. The application crashing is a C++ program, built with gcc and running on RH5. The backtrace seems valid till the #1 frame. There trying to print an object I get
<invalid address>, <error reading variable>
Since I have the address of the object from the #2 frame is it a valid presumption that I can somehow 'dump' the memory in which the object is allocated and still collect some info. Furthermore, instead of trying to guess how the object is aligned, can I force gdb to print the address as if it is an object, even though it detects some error. My idea is that maybe the object has already been deleted, but just maybe the memory is still there and I can print some member variable.
Please comment on is that possible, and if so, how it should be done in gdb terms. 10x.
You can use the command x (for “examine”) to examine memory in any of several formats, independently of your program's data types. Use the x command to examine memory.
The usual way to examine data in your program is with the print command (abbreviated p ), or its synonym inspect . It evaluates and prints the value of an expression of the language your program is written in (see section Using GDB with Different Languages). exp is an expression (in the source language).
but no definition for struct foo itself, gdb will say: (gdb) ptype foo $1 = <incomplete type> “Incomplete type” is C terminology for data types that are not completely specified.
Well, if you have an address you can always do:
print *(class MyClass*)pointer_var
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With