Vscode-cpptools: Debugger shows only first element of dynamic array

Created on 4 May 2017  Â·  11Comments  Â·  Source: microsoft/vscode-cpptools

If I have a pointer to some type and give the pointer address of an array, is it possible to display all of the elements instead of the first one only?
For example:
Rectangle* baz = new Rectangle[2] { {2,5}, {3,6} };
displays
image
both via hovering over the baz variable and in VARIABLES->Locals section.

I think that issue #585 is different (I don't understand the problem of that issue).

Feature Request debugger

Most helpful comment

(int[5]) arr or arr,5 None of them works for me.

What works is *arr@5.

have a look.
ss
OS:Linux VSC Version:1.23.1

All 11 comments

@salda which OS and debugger are you using?

I'm not on the cpptools team, but, in my opinion, if this works like Visual Studio, then everything is normal.

To view the pointer as a table, you should add a new watched variable under the Debug panel like so:

(Rectangle[2]) baz

See image below.

screenshot from 2017-05-04 13-56-28

Windows 10 with GDB.

@salda Does what @AnthonyD973 suggested work for you in the watch window? I know the hover won't work. Unfortunately this would require work on gdb's side to allow visualization OR a custom visualizer (aka natvis). I'll mark it as a feature request in the meantime that we can investigate for a future release.

(int[5]) arr or arr,5 None of them works for me.

What works is *arr@5.

have a look.
ss
OS:Linux VSC Version:1.23.1

debugger PHP7 shows only first element of zend_string
image
image

sos...
how can i do display all?

image
vscode VS lldb
image
lldb can shows all

Can anyone please tell how to use watch window

@kulalsk2 While debugging, in the left pane you will see an area for Watch under Variables.
image

In there you can type any expression want to look at.
image

You can look at variables, you can try to see int variable + 1 or see array[index]

Thanks a lot sir

(int[5]) arr or arr,5 None of them works for me.

The former usually works in gdb, the latter is not implemented yet, see microsoft/MIEngine#1031.

What works is *arr@5.

Interesting.

Was this page helpful?
0 / 5 - 0 ratings