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

General questions regarding the usage of CodeLite
rdlatimer
CodeLite Curious
Posts: 2
Joined: Thu Aug 07, 2014 5:14 pm
Genuine User: Yes
IDE Question: c++
Contact:

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

Post 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
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

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

Post 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
Make sure you have read the HOW TO POST thread
rdlatimer
CodeLite Curious
Posts: 2
Joined: Thu Aug 07, 2014 5:14 pm
Genuine User: Yes
IDE Question: c++
Contact:

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

Post by rdlatimer »

Great! thank you
User avatar
Jarod42
CodeLite Expert
Posts: 240
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

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

Post 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.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

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

Post 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
You do not have the required permissions to view the files attached to this post.
Make sure you have read the HOW TO POST thread
petah
CodeLite Expert
Posts: 231
Joined: Sat Nov 24, 2012 8:04 pm
Genuine User: Yes
IDE Question: c++
Location: Los Angeles
Contact:

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

Post 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
main: Debian Jessie x64 + custom wxTrunk
Post Reply