Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ',<number>' to visualize a pointer as an array #715

Closed
digittigerw opened this issue Apr 30, 2018 · 8 comments
Closed

Support ',<number>' to visualize a pointer as an array #715

digittigerw opened this issue Apr 30, 2018 · 8 comments

Comments

@digittigerw
Copy link
Contributor

Hi, with a VC++ project in VS, if I have a pointer like this:
int *myArr = new int[20];

I can watch the pointer "myArr" as an array in "Watch" windows, namely if I enter "myArr,2", it will show "myArr" as an array of int[2] like below
image

With my MIEngine debugger, that does not work. So my question it, is there a way to do that with MIEngine ? Or is there a workaround ?
Thanks !

@gregg-miskelly
Copy link
Member

CC @WardenGnaw

@gregg-miskelly
Copy link
Member

@digittigerw I believe you would evaluate something like (int[20])myArr.

@WardenGnaw do I have that right?

@digittigerw
Copy link
Contributor Author

Yeah, actually (int[20])*myArr works. Thanks for the help ! @WardenGnaw @gregg-miskelly

@gregg-miskelly gregg-miskelly changed the title how to watch a pointer as array Support ',<number>' to visualize a pointer as an array May 1, 2018
@gregg-miskelly
Copy link
Member

@digittigerw Excellent. I will leave this open to track the possible future feature of supporting ','.

@digittigerw
Copy link
Contributor Author

@gregg-miskelly Cool. I'm really curious, can we add that support in MIEngine ? is interpretation (parsing) of the watch expression done by VS debugger engine or by debugger extension like MIEngine ?
Issue #709 is my other more general question related to this.

@gregg-miskelly
Copy link
Member

The MIEngine has a tiny bit of support for format specifier today. I think the only thing we implemented was ,x and ,d. The array size format specifier could be implemented using this code: https://github.com/Microsoft/MIEngine/blob/72df3ee1ad81a9698a35ced2410016ea9910c5e0/src/MIDebugEngine/Natvis.Impl/Natvis.cs#L501

@Trass3r
Copy link
Contributor

Trass3r commented Jun 9, 2022

// array with static size
// TODO: could return '(T(*)[n])(exp)' but requires T
var m = Regex.Match(trimmed, @"^\[?(\d+)\]?$");
if (m.Success)
return exp.Substring(0, lastComma);
// array with dynamic size
if (Regex.Match(trimmed, @"^\[([a-zA-Z_][a-zA-Z_\d]*)\]$").Success)
return exp.Substring(0, lastComma);

We could actually use the *array@(len) syntax to make it work.
Though that seems to be gdb only syntax.

@WardenGnaw
Copy link
Member

Addressed with:
#1329
#1345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants