Viewing a dynamically-allocated array with the Xcode debugger?
c++, gdb, macos, xcode
Solution
You can use gdb syntax as expressions:
- Use Run/Show/Expressions... menu to show the expressions window
- Enter `'*velocity @ 100'` at the bottom of the window (Expression:)
Problem
Let's say I have an array in C++: ``` double* velocity = new double[100]; ``` Using the GDB command line, I can view this array with the command: ``` > print *velocity @ 100 ``` and it will print a nicely-formatted list of all the double values inside the array. However, when using the Xcode debugger, the most it will do is treat this as a pointer to a single double value, and display velocity[0] in the variable list. This makes it a real PITA to debug programs that contain large dynamically allocated array. There has got to be some way to tell Xcode "This is a pointer to an array of length 100", and have it display the thing as such. Anyone know what it is?