Bug 437001 - Feature request: Display as array with non constant length
Summary: Feature request: Display as array with non constant length
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug (show other bugs)
Version: Next   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: cdt-debug-inbox@eclipse.org CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-09 16:53 EDT by Simon Marchi CLA
Modified: 2020-09-04 15:17 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Marchi CLA 2014-06-09 16:53:54 EDT
The existing "Display as array" feature allows you to specify a constant legnth only. Suppose that you have this struct:

struct hello {
    int n_elements;
    element *elements;
};

where n_elements represents the number of elements in the array pointed by elements. It would be useful to be able to do display as array, and specify the length as expression instead of an integer. For example, I could add an expression "hello_pointer->elements", and use display as array with a length of "hello_pointer->n_elements".

From the MI traces, we see that CDT already uses the array@len feature of GDB. GDB already supports expression for "len".
Comment 1 Marc Khouzam CLA 2014-06-17 13:51:12 EDT
Sounds good
Comment 2 Simon Marchi CLA 2014-06-17 13:56:07 EDT
Just in case it wasn't clear, the goal would be for the length to be dynamic.

If I hit a breakpoint and n_elements is 5, then CDT would automatically show me 5 elements. If I continue, hit that breakpoint again and now the length is 10, it would automatically switch to show me 10 elements. The expression would have to be sent and evaluated every time, not just once at the beginning.
Comment 3 Marc Khouzam CLA 2014-06-18 11:47:05 EDT
(In reply to Simon Marchi from comment #2)
> Just in case it wasn't clear, the goal would be for the length to be dynamic.
> 
> If I hit a breakpoint and n_elements is 5, then CDT would automatically show
> me 5 elements. If I continue, hit that breakpoint again and now the length
> is 10, it would automatically switch to show me 10 elements. The expression
> would have to be sent and evaluated every time, not just once at the
> beginning.

I'm thinking that if the user puts in an expression in the dialog, we pass it as is to GDB.  I believe that should work based on your findings.
Comment 4 Marc-André Laperle CLA 2015-05-02 09:22:24 EDT
Simon, I think you had a prototype for this? Do you want to push it to Gerrit as a WIP patch? In case someone wants to finish it :)
Comment 5 Simon Marchi CLA 2015-05-02 22:58:48 EDT
(In reply to Marc-Andre Laperle from comment #4)
> Simon, I think you had a prototype for this? Do you want to push it to
> Gerrit as a WIP patch? In case someone wants to finish it :)

Here it is:

https://git.eclipse.org/r/#/c/40812/