Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View C++ shared_ptr content in debugger

Debugging C++ code in xcode, Is there a way to view the contents of std::shared_ptr ?

if I look at the 'watch' window all I can see is __ptr = (element_type *) 0xa66945c

and writing 'po myPointer' in immediate window also print only the memory address.

I also tried the 'view Memory of "__ptr_"' and 'view Memory of "*__ptr_"' but it only lets me see

raw memory and no actual readable text

Can anyone suggest a way to view the object I have a pointer for ?

like image 967
MichaelB Avatar asked Nov 10 '22 02:11

MichaelB


1 Answers

The fr command in LLDB has a --ptr-depth argument, which can help in these situations. For example, try typing this into the immediate pane:

fr var myPointer --ptr-depth=1

like image 164
prideout Avatar answered Nov 15 '22 07:11

prideout