-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Debugger Option to View Pointer as Array. #172
Comments
@sprinkle131313 with our 0.9.3 release, we updated to enable gdb's pretty-printing in launch.json as a default. This should resolve this issue. Please comment/reopen with more information if it doesn't |
It would make a HUGE difference if I could type "some_pointer,x" in the watch window to view some_pointer as an array with x elements. As it stands I have to use LLDB's memory read syntax, which I constantly have to google and sometimes doesn't seem to work. I've actually resorted to printf debugging for large arrays the last few days. Could we please reopen this issue or can I open another to look into something like that being implemented? It's my number 1 gripe with VSCode debugging at the moment (one of my only gripes). |
@kevinmoran We have updated our version of the shipped LLDB to allow lldb's python pretty printer to work. Your other option is to look at our Natvis visualizer option. The commands you are putting in the watch window are sent to the underlying debugger to evaluate. |
Thanks for getting back to me, have a decent solution now. For anyone who found themselves here Googling this same problem, you can put this in the watch window: Would still argue that having a simpler solution is a basic debugger feature that should be added, this is way too much syntax/thinking/remembering to do something basic. Debuggers should get out of your way, not challenge you when you're trying to think about your actual code. |
I agree with kevinmoran, that retyping the pointer is too complicated by hand and should be done by debugger. |
@salda We will take it as a feature request but the underlying debugger is lldb or gdb so the change would need to happen in the debugger itself and not the extension. |
#172 (comment) |
@noobling Yes, I am having trouble printing pointer to pointers as well |
or, even simpler: |
If you do what @giuscri suggests and put a breakpoint in the function that computes the pointer, the watch will stall indefinitely and cannot be deleted (Windows 10) eg reloading the window after this happens seems to fix it. |
If you have the array length in a variable (e.g., length) you can do this: *some_pointer@length |
Thanks @giuscri! |
Looks like this doesn't work anymore? |
It works fine for me |
Add plumbing for AD7 evaluation / property info flags
Thank you @brunohenriquepj , what would I do without you.. I tried all the suggestions above your answers, none of them worked on my linux machine. But You helped alot.. Will remember this
BTW I have just started coding with C. |
For MSVC (i.e. when using cppvsdbg instead of cppdbg) substitute the @ symbol with a comma, and omit the dereferencing, i.e. i.e. |
@JJJohan Can I ask what is cppvsdbg? And is it available on Linux? |
@tripathics This is referring to the debugger configured in the launch.json file in VS Code. It'll be Windows specific as it's meant for using Visual Studio's toolset as the backend. It's briefly described in the launch json reference. |
Btw I am having problem with 2d or 3d array in watch.. idk how to use that pointer syntax for multidimensional arrays in watch.. can you help me? |
For 2d array use this (int pointer_2d[10][15];): |
For anyone who having issues still I found this working on my macOS if I put this on my watch window: |
The only way by far that works on my VS for mac ! |
@Ch1ldr3n What debugger are you using? I presume LLDB cause I got the same issue. |
here's what i've gathered, hope this helps general forms for expanding arrays (of any dimension, with arbitrary length):
there's also one for expanding 2 dimensions specifically:
|
What is the reference of |
I think it is because everyone use different types of debugger, it may look the same on the surface since vscode provides an unified UI, but the underlying debugger tool we are using is not the same. For example, I use LLDB as the debugger(you can search for the extension in vscode), the syntax So, take a look at the documentation of the debugger(or debugger extension) you're using, and find something like |
For dynamically allocated arrays are simply represented as a pointer, which has no other indicator that it is an array. It would be nice to have a feature to view a pointer as an array as to view more than simply the first element of the array. In the "variables" tab and also when previewing a variable by hovering over it while debugging.
The text was updated successfully, but these errors were encountered: