From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2454 invoked by alias); 11 Apr 2013 07:36:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 2441 invoked by uid 89); 11 Apr 2013 07:36:40 -0000 X-Spam-SWARE-Status: No, score=-4.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_XS autolearn=ham version=3.3.1 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 11 Apr 2013 07:36:39 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1UQC3i-0006ju-C1 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Thu, 11 Apr 2013 00:36:38 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 11 Apr 2013 00:36:37 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Thu, 11 Apr 2013 00:36:36 -0700 Message-ID: <51666804.6060903@codesourcery.com> Date: Thu, 11 Apr 2013 13:22:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Subject: Re: [PATCH 4/7] range stepping: gdb References: <1363006291-13334-1-git-send-email-yao@codesourcery.com> <1365648222-12540-1-git-send-email-yao@codesourcery.com> <1365648222-12540-5-git-send-email-yao@codesourcery.com> In-Reply-To: <1365648222-12540-5-git-send-email-yao@codesourcery.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-SW-Source: 2013-04/txt/msg00318.txt.bz2 On 04/11/2013 10:43 AM, Yao Qi wrote: > - Use phex_nz instead of hexnumstr to get the address. ..... > + > + 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)); It is incorrect to copy address to buffer via phex_nz here and somewhere else in remote.c. We should use remote_address_masked first to mask the CORE_ADDR and then call hexnumstr to copy address to buffer. Here is an updated one. 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: - Call remote_address_masked first before call hexnumstr to get the address. - Define an internalvar range_stepping_counter and increment it each time GDB does range-stepping. -- Yao (齐尧) gdb: 2013-04-10 Yao Qi * remote.c (struct support_v_cont) : 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 | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 48 insertions(+), 1 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index f6a3f4c..4158a09 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,49 @@ 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)) + { + struct internalvar *range_stepping_counter + = lookup_internalvar ("range_stepping_counter"); + LONGEST result = 0; + CORE_ADDR addr; + + p += xsnprintf (p, endp - p, ";r"); + + addr = tp->control.step_range_start; + p += hexnumstr (p, (ULONGEST) remote_address_masked (addr)); + p += xsnprintf (p, endp - p, ","); + addr = tp->control.step_range_end; + p += hexnumstr (p, (ULONGEST) remote_address_masked (addr)); + + 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