This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Speed up single stepping
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Fri, 18 Aug 2006 23:22:39 -0400
- Subject: [commit] Speed up single stepping
While working on some changes to frame handling, I set a breakpoint on every
occurance of get_prev_frame_1 for this_frame->level >= 0; everything but
finding the current frame. We were doing it once per stop during the
"step" command. That's not necessary; with the simple change below,
we do this only in rare cases (like stepping into a subroutine, or
out of a function), but not while stepping within a single source line.
The change is safe because no two frames in the backtrace will have the
same ID. If the current frame ID matches step_frame_id, then the unwound
frame ID won't match it.
This simple change improves single-stepping performance by about 8% in
my tests!
Regression tests on x86_64-pc-linux-gnu, and checked in.
--
Daniel Jacobowitz
CodeSourcery
2006-08-18 Daniel Jacobowitz <dan@codesourcery.com>
* infrun.c (handle_inferior_event): Check the current frame ID
before unwinding to the previous frame.
---
gdb/infrun.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c 2006-08-18 21:08:48.000000000 -0400
+++ src/gdb/infrun.c 2006-08-18 21:10:55.000000000 -0400
@@ -2368,12 +2368,16 @@ process_event_stop_test:
return;
}
- /* Check for subroutine calls.
+ /* Check for subroutine calls. The check for the current frame
+ equalling the step ID is not necessary - the check of the
+ previous frame's ID is sufficient - but it is a common case and
+ cheaper than checking the previous frame's ID.
NOTE: frame_id_eq will never report two invalid frame IDs as
being equal, so to get into this block, both the current and
previous frame must have valid frame IDs. */
- if (frame_id_eq (frame_unwind_id (get_current_frame ()), step_frame_id))
+ if (!frame_id_eq (get_frame_id (get_current_frame ()), step_frame_id)
+ && frame_id_eq (frame_unwind_id (get_current_frame ()), step_frame_id))
{
CORE_ADDR real_stop_pc;