Reputation: 13
I have a core file and I have the binary(C++). The question is, while using gdb to analyze the core file, if I tried to print a pointer, it will print out the memory address. Once I tried to print the orignial context of that pointer, it says:
You can't do that without a process to debug.
Here is an example:
(gdb) p objPtr
(gdb) $1 = {px = 0x12345678}
(gdb) p *objPtr
(gdb) You can't do this without a process to debug.
In fact, this makes sense because the core file is not a process of that binary. But the core file is supposed to store the state when the binary crash, I think there should be a way to get the original context from, we say, a pointer.
I have done some research on writing a Python script to deal with this. But at the first place, if we are not able to do such p *ptr
in gdb, how could my Python script get the object from that memory address?
Any reference or github project would help.
Update:
I discovered that I could do a:
(gdb) p *ptr.px
to fix the problem I have above.
But now my question becomes how to get the .px
thing in Python script if I wish to write a script helping debug in GDB.
Upvotes: 0
Views: 1160
Reputation: 13
Actually find the answer by myself.
Since the objPtr is a pointer in my example, calling something like *objPtr
is considered calling a function/method of that pointer. The correct way is to p *objPtr.px
.
Upvotes: 1