aboutsummaryrefslogtreecommitdiff
path: root/gdb/infcmd.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2013-05-23 17:15:35 +0000
committerPedro Alves <palves@redhat.com>2013-05-23 17:15:35 +0000
commitc1e36e3e919994da4fa0da232b173939f3e44bb8 (patch)
tree0e355e32e09ba6192768b6ebdd20994848acbdfe /gdb/infcmd.c
parentd458bd84a8d3576fa7c2b4e3132ebe96e104e918 (diff)
downloadgdb-c1e36e3e919994da4fa0da232b173939f3e44bb8.zip
gdb-c1e36e3e919994da4fa0da232b173939f3e44bb8.tar.gz
gdb-c1e36e3e919994da4fa0da232b173939f3e44bb8.tar.bz2
range stepping: gdb
This patch teaches GDB to take advantage of target-assisted range stepping. It adds a new 'r ADDR1,ADDR2' action to vCont (vCont;r), meaning, "step once, and keep stepping as long as the thread is in the [ADDR1,ADDR2) range". Rationale: When user issues the "step" command on the following line of source, a = b + c + d * e - a; GDB single-steps every single instruction until the program reaches a new different line. E.g., on x86_64, that line compiles to: 0x08048434 <+65>: mov 0x1c(%esp),%eax 0x08048438 <+69>: mov 0x30(%esp),%edx 0x0804843c <+73>: add %eax,%edx 0x0804843e <+75>: mov 0x18(%esp),%eax 0x08048442 <+79>: imul 0x2c(%esp),%eax 0x08048447 <+84>: add %edx,%eax 0x08048449 <+86>: sub 0x34(%esp),%eax 0x0804844d <+90>: mov %eax,0x34(%esp) 0x08048451 <+94>: mov 0x1c(%esp),%eax and the following is the RSP traffic between GDB and GDBserver: --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3c840408;thread:p2e13.2e13;core:1; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:3e840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:42840408;thread:p2e13.2e13;core:2; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:47840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:49840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:4d840408;thread:p2e13.2e13;core:0; --> vCont;s:p2e13.2e13;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2e13.2e13;core:0; IOW, a lot of roundtrips between GDB and GDBserver. If we add a new command to the RSP, meaning "keep stepping and don't report a stop until the program goes out of the [0x08048434, 0x08048451) address range", then the RSP traffic can be reduced down to: --> vCont;r8048434,8048451:p2db0.2db0;c <-- T0505:68efffbf;04:30efffbf;08:51840408;thread:p2db0.2db0;core:1; As number of packets is reduced dramatically, the performance of stepping source lines is much improved. In case something is wrong with range stepping on the stub side, the debug info or even gdb, this adds a "set/show range-stepping" command to be able to turn range stepping off. gdb/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdbthread.h (struct thread_control_state) <may_range_step>: New field. * infcmd.c (step_once, until_next_command): Enable range stepping. * infrun.c (displaced_step_prepare): Disable range stepping. (resume): Disable range stepping if stepping over a breakpoint or we have software watchpoints. If range stepping is enabled, assert the thread is in the stepping range. (clear_proceed_status_thread): Clear may_range_step. (handle_inferior_event): Disable range stepping as soon as we know the thread that hit the event. Re-enable it whenever we're going to step with a step range. * remote.c (struct vCont_action_support) <r>: New field. (use_range_stepping): New global. (remote_vcont_probe): Handle 'r' action. (append_resumption): Append an 'r' action if the thread may range step. (show_range_stepping): New function. (set_range_stepping): New function. (_initialize_remote): Call add_setshow_boolean_cmd to register the 'set range-stepping' and 'show range-stepping' commands. * NEWS: Mention range stepping, the new vCont;r action, and the new "set/show range-stepping" commands. gdb/doc/ 2013-05-23 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> * gdb.texinfo (Packets): Document 'vCont;r'. (Continuing and Stepping): Document target-assisted range stepping, and the 'set range-stepping' and 'show range-stepping' commands.
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r--gdb/infcmd.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index aeb24ff..30621e4 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1046,9 +1046,14 @@ step_once (int skip_subroutines, int single_inst, int count, int thread)
&tp->control.step_range_start,
&tp->control.step_range_end);
+ tp->control.may_range_step = 1;
+
/* If we have no line info, switch to stepi mode. */
if (tp->control.step_range_end == 0 && step_stop_if_no_debug)
- tp->control.step_range_start = tp->control.step_range_end = 1;
+ {
+ tp->control.step_range_start = tp->control.step_range_end = 1;
+ tp->control.may_range_step = 0;
+ }
else if (tp->control.step_range_end == 0)
{
const char *name;
@@ -1337,6 +1342,7 @@ until_next_command (int from_tty)
tp->control.step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
tp->control.step_range_end = sal.end;
}
+ tp->control.may_range_step = 1;
tp->control.step_over_calls = STEP_OVER_ALL;