This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 4/7] range stepping: gdb
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Thu, 11 Apr 2013 10:43:39 +0800
- Subject: [PATCH 4/7] range stepping: gdb
- References: <1363006291-13334-1-git-send-email-yao at codesourcery dot com> <1365648222-12540-1-git-send-email-yao at codesourcery dot com>
This patch teaches GDB to send 'vCont;r' packet when appropriate.
GDB has to check whether the target understand 'r' action of 'vCont'
packet. We also make use of fields 'step_range_start' and
'step_range_end' of 'struct thread_control_state' to compose the range
of the stepping.
In V2, there are several changes:
- Use phex_nz instead of hexnumstr to get the address.
- Define an internalvar range_stepping_counter and increment it each
time GDB does range-stepping.
gdb:
2013-04-10 Yao Qi <yao@codesourcery.com>
* remote.c (struct support_v_cont) <r>: New field.
(remote_vcont_probe): Handle 'r' action of 'vCont' packet.
(append_resumption): Send 'vCont;r' for range stepping and
increment internalvar range_stepping_counter.
---
gdb/remote.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index f6a3f4c..a063698 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -256,6 +256,8 @@ struct support_v_cont
{
/* True if the stub reports support for vCont;t. */
int t;
+ /* True if the stub reports support for vCont;r. */
+ int r;
};
/* Description of the remote protocol state for the currently
@@ -4649,6 +4651,7 @@ remote_vcont_probe (struct remote_state *rs)
support_c = 0;
support_C = 0;
rs->support_vCont.t = 0;
+ rs->support_vCont.r = 0;
while (p && *p == ';')
{
p++;
@@ -4662,6 +4665,8 @@ remote_vcont_probe (struct remote_state *rs)
support_C = 1;
else if (*p == 't' && (*(p + 1) == ';' || *(p + 1) == 0))
rs->support_vCont.t = 1;
+ else if (*p == 'r' && (*(p + 1) == ';' || *(p + 1) == 0))
+ rs->support_vCont.r = 1;
p = strchr (p, ';');
}
@@ -4694,7 +4699,47 @@ append_resumption (char *p, char *endp,
if (step && siggnal != GDB_SIGNAL_0)
p += xsnprintf (p, endp - p, ";S%02x", siggnal);
else if (step)
- p += xsnprintf (p, endp - p, ";s");
+ {
+ struct thread_info *tp = NULL;
+ CORE_ADDR pc;
+
+ gdb_assert (!ptid_equal (ptid, minus_one_ptid));
+
+ if (ptid_is_pid (ptid))
+ tp = find_thread_ptid (inferior_ptid);
+ else
+ tp = find_thread_ptid (ptid);
+ gdb_assert (tp != NULL);
+
+ pc = regcache_read_pc (get_thread_regcache (ptid));
+ if (rs->support_vCont.r /* Target supports step range. */
+ /* Can't do range stepping for all threads of a process
+ 'pPID.-1'. */
+ && !(remote_multi_process_p (rs) && ptid_is_pid (ptid))
+ /* Not step over a breakpoint. */
+ && !tp->control.trap_expected
+ /* We have a range to single step. */
+ && THREAD_WITHIN_SINGLE_STEP_RANGE (tp, pc))
+ {
+ int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8;
+ struct internalvar *range_stepping_counter
+ = lookup_internalvar ("range_stepping_counter");
+ LONGEST result = 0;
+
+ p += xsnprintf (p, endp - p, ";r%s,%s",
+ phex_nz (tp->control.step_range_start,
+ addr_size),
+ phex_nz (tp->control.step_range_end,
+ addr_size));
+
+ get_internalvar_integer (range_stepping_counter, &result);
+ set_internalvar_integer (range_stepping_counter,
+ result + 1);
+
+ }
+ else
+ p += xsnprintf (p, endp - p, ";s");
+ }
else if (siggnal != GDB_SIGNAL_0)
p += xsnprintf (p, endp - p, ";C%02x", siggnal);
else
--
1.7.7.6