5

I got an address such as 0x7fc9e401a02a in my log file, and I know that this address is a pointer of type Connection.

Then I start GDB, what I wanna know is: how to convert this address to a temporary variable of type Connection*, and display relevant information of Connection*?

How to do this, any hints?

2
  • 4
    Try this: print *(Connection*)0x7fc9e401a02a. This assumes that your address is from a core file that your looking at in gdb. If that address is from a run of your code, it will certainly not exist without re-running the code inside gdb. Commented Jan 9, 2013 at 3:31
  • If object still exists on stack/heap and program is still running, just attach (attach PID) to process, and you should be able to do what JaredC writes. Commented Jan 9, 2013 at 8:10

1 Answer 1

7

Because my Connection class has a namespace, so what I should do is as bellow:

print * ('MyNameSpace::Connection' *) 0x7fc9e401a02a

Thanks JaredC and dbrank0 for your answers.

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.