Skip to content
Advertisement

How to view the internal data of a smart pointer inside gdb?

I’ve got test program like below:

JavaScript

Debug it:

JavaScript

It only prints out the pointer type information of si, but how to get the value stored in it (in this case 5)? How can I check the internal content of si during debugging?

Advertisement

Answer

Try the following:

JavaScript

Now, this assumes that you’re using libstdc++.so, given the output for p si.

Alternatively, you could use the value 0x614c20 directly (from your output):

JavaScript

Both should display the value 5.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement