Hi there,
just got myself the source code of codeblocks and would like to enhance the debugger plugin a little. Basically what I need is efficient array/vector debugging. Right now the debugger already supports debugging of c-arrays and vectors, but sometimes fails for no apparent reason.
Starting with c-arrays, here are a few examples:
double arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
double * arr_ptr = arr;
Debugger shows when watching arr:
arr
|- 1
|- 2
|- 3
|- 4
|- 5
|- 6
|- 7
|- 8
|- 9
|- 10
However, it does not show the array indices (which would be very useful when inspecting large arrays). Suggested format would be
either:
arr = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
or
arr
[0] = 1
[1] = 2
[2] = 3
[3] = 4
[4] = 5
[5] = 6
[6] = 7
[7] = 8
[8] = 9
[9] = 10
It would be nice if the debugger would support both formats. When I'm debugging several arrays and I need a quick comparison on the content of two arrays, the 'single line' format is more useful. Related to that I would like to specify the output format for the doubles, e.g. scientific, precision=3, or fixed, precision=2.
When inspecting arr_ptr, the debugger fails to show the content as array, regardless if I inspect arr_ptr[0] or *arr_ptr with any number for 'count'.
However, gdb shows the content correctly for
Range indices start and count do not work with c-arrays yet.
I would like to start enhancing the debugger plugin by implementing proper support for c-arrays. Now, before hacking the source code I would like to have some feedback on my proposed changes/additions, because I'm really new to the CodeBlocks source code and may overlook some design issues.
1. for all pointer types, if count != 0, add the debugger command
output \<flag> <ptr>[start]@count
2. for array output, improve parsing debugger output and create two alternative watch outputs:
and
arr
[start+0] = ...
[start+1] = ...
[start+2] = ...
...
[start+count-1] = ...
The format can be selected as boolean from the Edit Watch dialog (becomes a new member variable in the Watch class)
3. Improve output parsing, so when debugger returns <repeats 42 times>, alter output to show
arr
[ 0] = 0
[ 1] = 1 <repeats 42 times>
[43] = 2
...
I will try to get this correctly working with c-arrays for various types first.
Would you have some suggestions on how to achieve this best?
Bye,
Andreas