> what is gdb?
The GNU debugger. As far as C++ is concerned, the poor cousin of the Visual Studio debugger.
> Can't the debug and immediate windows be used for this purpose at all?
Say we have:
1 2
|
int* pa = new int[100] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } ;
std::iota( pa, pa+100, 100 ) ; // fill with values 100, 101, 102, ... 199
|
In the immediate window:
To show all 100 values, enter:
? pa, 100
To show 10 values starting at pa[50], enter:
? pa+50, 10
In a Watch or the QuickWatch window, enter the expression to watch as:
pa, 100
or
pa+50, 10
If the number of elements in the dynamically allocated array is not known, in most cases we can use the
hv specifier (ask the debugger to try to determine the length of the array). For instance, in the immediate window:
? pa, hv
If type information has been lost (say, because of an implicit conversion to pointer to void), use a cast;
for instance
? static_cast<const int*>(pvoid), 7