0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.