Message ID | 1427926454-16431-4-git-send-email-palves@redhat.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 95886 invoked by alias); 1 Apr 2015 22:14:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 95638 invoked by uid 89); 1 Apr 2015 22:14:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 01 Apr 2015 22:14:20 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t31MEJcF023873 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for <gdb-patches@sourceware.org>; Wed, 1 Apr 2015 18:14:19 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t31MEEtm009701 for <gdb-patches@sourceware.org>; Wed, 1 Apr 2015 18:14:18 -0400 From: Pedro Alves <palves@redhat.com> To: gdb-patches@sourceware.org Subject: [PATCH 03/17] Displaced stepping debug: fetch the right regcache Date: Wed, 1 Apr 2015 23:14:00 +0100 Message-Id: <1427926454-16431-4-git-send-email-palves@redhat.com> In-Reply-To: <1427926454-16431-1-git-send-email-palves@redhat.com> References: <1427926454-16431-1-git-send-email-palves@redhat.com> |
Commit Message
Pedro Alves
April 1, 2015, 10:14 p.m. UTC
Although not currently possible in practice when we get here, 'resume_ptid' can also be a wildcard throughout this function. It's clearer to fetch the regcache using the thread's ptid. gdb/ChangeLog: 2015-04-01 Pedro Alves <pedro@codesourcery.com> * infrun.c (resume) <displaced stepping debug output>: Get the leader thread's regcache, not resume_ptid's. --- gdb/infrun.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 04/01/2015 11:14 PM, Pedro Alves wrote: > Although not currently possible in practice when we get here, > 'resume_ptid' can also be a wildcard throughout this function. It's > clearer to fetch the regcache using the thread's ptid. > > gdb/ChangeLog: > 2015-04-01 Pedro Alves <pedro@codesourcery.com> > > * infrun.c (resume) <displaced stepping debug output>: Get the > leader thread's regcache, not resume_ptid's. Not much point in carrying this one around. I pushed it in. Thanks, Pedro Alves
Pedro Alves <palves@redhat.com> writes: > gdb/ChangeLog: > 2015-04-01 Pedro Alves <pedro@codesourcery.com> > > * infrun.c (resume) <displaced stepping debug output>: Get the > leader thread's regcache, not resume_ptid's. Hi Pedro, From your change, I don't see why TP is the leader thread. > --- > gdb/infrun.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gdb/infrun.c b/gdb/infrun.c > index cf0ef32..f23e76e 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -2374,7 +2374,7 @@ resume (enum gdb_signal sig) > && tp->control.trap_expected > && use_displaced_stepping_now_p (gdbarch, sig)) > { > - struct regcache *resume_regcache = get_thread_regcache (resume_ptid); > + struct regcache *resume_regcache = get_thread_regcache (tp->ptid); > struct gdbarch *resume_gdbarch = get_regcache_arch (resume_regcache); > CORE_ADDR actual_pc = regcache_read_pc (resume_regcache); If we get recache from TP, can we remove local variables resume_regcache, resume_gdbarch, actual_pc, and use regcache, gdbarch and pc we've got at the beginning of function resume instead?
On 04/07/2015 02:55 PM, Yao Qi wrote: > Pedro Alves <palves@redhat.com> writes: > >> gdb/ChangeLog: >> 2015-04-01 Pedro Alves <pedro@codesourcery.com> >> >> * infrun.c (resume) <displaced stepping debug output>: Get the >> leader thread's regcache, not resume_ptid's. > > Hi Pedro, > From your change, I don't see why TP is the leader thread. 'resume' and 'target_resume' assume inferior_ptid is the "leader" thread we want resumed -- TP is just the current thread initialized at the top: struct thread_info *tp = inferior_thread (); But e.g., if we're resuming with "set scheduler-locking off", this: resume_ptid = user_visible_resume_ptid (user_step); makes resume_ptid be a whole-process ptid, or minus_one_ptid (all-threads). In that case, the target_resume backend implementation knows the thread that is the "leader" is inferior_ptid, not the one passed as argument. (though when we start a displaced step, resume_ptid is always pointing at the current thread, never a wildcard ptid.) >> @@ -2374,7 +2374,7 @@ resume (enum gdb_signal sig) >> && tp->control.trap_expected >> && use_displaced_stepping_now_p (gdbarch, sig)) >> { >> - struct regcache *resume_regcache = get_thread_regcache (resume_ptid); >> + struct regcache *resume_regcache = get_thread_regcache (tp->ptid); >> struct gdbarch *resume_gdbarch = get_regcache_arch (resume_regcache); >> CORE_ADDR actual_pc = regcache_read_pc (resume_regcache); > > If we get recache from TP, can we remove local variables > resume_regcache, resume_gdbarch, actual_pc, and use regcache, gdbarch > and pc we've got at the beginning of function resume instead? Good point. Indeed we should be able to. The PC we got at the top would be incorrect, given the thread's PC now points at the scratch pad, but we already do: /* Update pc to reflect the new address from which we will execute instructions due to displaced stepping. */ pc = regcache_read_pc (get_thread_regcache (inferior_ptid)); so the current PC's contents should work. And that line could be: pc = regcache_read_pc (regcache); too. Thanks, Pedro Alves
diff --git a/gdb/infrun.c b/gdb/infrun.c index cf0ef32..f23e76e 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2374,7 +2374,7 @@ resume (enum gdb_signal sig) && tp->control.trap_expected && use_displaced_stepping_now_p (gdbarch, sig)) { - struct regcache *resume_regcache = get_thread_regcache (resume_ptid); + struct regcache *resume_regcache = get_thread_regcache (tp->ptid); struct gdbarch *resume_gdbarch = get_regcache_arch (resume_regcache); CORE_ADDR actual_pc = regcache_read_pc (resume_regcache); gdb_byte buf[4];