Is it possible in gdb to go to a line before the currently executing line. e.g:
void my_fun( somePtrType** arr,int start,int end)
{
// arr is an array of p
Short answer: No.
For workaround read below.
Though at line b it is not possible to determine the value at line a, it is possible to log the value of arr at a and b and other locations by only one breakpoint being hit.
(gdb) command 1
Type commands for when breakpoint 1 is hit, one per line. End with a line saying just "end".
continue
end
Now when all other logging breakpoints are hit, the value of arr will be dumped on the screen but the breakpoint won't wait for user interaction and will auto-continue. When you hit a breakpoint at line b, you can see the past values of arr which would be logged in gdb itself.
Depending on the situation you can also dump (and display) a lot of useful information. For example you may also want to dump a loop counter (say i) if the above function is called 10000 times in a loop. That really depends on what you are trying to achieve.