Page 1 of 1

How to add a watch using lldb debugger, for 2D array view

Posted: Thu Aug 07, 2014 5:26 pm
by rdlatimer
I'm using a Mac, and it seems as though Macs no longer use gdb for debugging (?) Codelite can use the lldb debugger which Macs now use. I cannot see how to add a watch as I'm using lldb as the debugger.
I'm trying to view the contents of a 2 dimensional array. In my sample code I'm creating this array with pointers and 'new'. I'll also be creating arrays with malloc() in c style too.
I think Codelite will show me the contents of a 1-D array, and a 2-D array created like...
double array[5][10];

But if my array starts as
double **myarray

I'm not sure Codelite is showing me the entire contents of the matrix.

So, I have two concerns:
- how do I add a watch, using lldb, also - can I edit a watch in the debugger window?
- how do I view contents of a 2 D array that's created with 'new' or malloc()
I haven't tried this with malloc() yet, so I'll try to view a 2D array created with malloc()

Thanks for any help

Re: How to add a watch using lldb debugger, for 2D array vie

Posted: Thu Aug 07, 2014 5:34 pm
by eranif
I am working on adding watch support for lldb as we speak ;)

So its not possible just yet to do this.
But you will be my first beta tester ;)
Eran

Re: How to add a watch using lldb debugger, for 2D array vie

Posted: Thu Aug 07, 2014 5:35 pm
by rdlatimer
Great! thank you

Re: How to add a watch using lldb debugger, for 2D array vie

Posted: Mon Aug 11, 2014 4:53 pm
by Jarod42
For

Code: Select all

double array[5][10]
compiler (and debugger) knows the memory layout.

For

Code: Select all

double** array
we don't know the size. With gdb you may use

Code: Select all

array[0][0]@10
to display element as array (you have to fix the size).

A possible hack would be to declare

Code: Select all

double (*array_view)[10] = (double (*)[10])(array[0]);
to have array_view in local variable.

Re: How to add a watch using lldb debugger, for 2D array vie

Posted: Fri Aug 22, 2014 7:41 pm
by eranif
Update:
I have added support for watches for the LLDB debugger.
So, you can basically use it to watch 2-D array allocated on the heap (using malloc) as Jarod42 suggested:

Click on the '+' button and add a watch with the following expression:

Code: Select all

(double (*)[10])(array[0])
See attached screenshot
snapshot1.png
Eran

Re: How to add a watch using lldb debugger, for 2D array vie

Posted: Tue Aug 26, 2014 7:42 am
by petah
Hi Eran,

I added the following:

Code: Select all

type category libcxx: enable
in CL's LLDB's prefs to see std::string (on Linux with libc++ and libcxxrt) and it works fine except only the "Summary" column is populated - the "Value" stays empty. I didn't find a way to populate the value based on the summary, only the other way around. What would be the solution?

Alternatively, is there a way to get LLDB's command line to experiment with formats in real-time?

Btw the LLDB prefs' ok button stays disabled unless some value is changed.

thx & cheers,

-- p