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.
- Use the "display" command (*display variable_name* where variable_name is to be replaced with arr, *arr, **arr depending on what you are looking for) so that when any breakpoint is hit, the contents of the variable_name will be dumped on to the screen. Note that you can add to the display list when the variabe_name is in scope so that may require you to wait for your first breakpoint.
- Create breakpoints at various locations of code where you are interested to log the value of variable_name. One such breakpoint would be at line a.
- For each breakpoint, use command (*command breakpoint_number*) and instruct your breakpoint to not halt the execution of the program. The command that you need to use is continue followed by end. See example below.
(gdb) command 1
Type commands for when breakpoint 1 is hit, one per line. End with a line saying just "end".
continue
end
- Put a breakpoint on line b.
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.