From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52245 invoked by alias); 31 Jan 2017 12:59:47 -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 51576 invoked by uid 89); 31 Jan 2017 12:59:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.8 required=5.0 tests=BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=Metzger, metzger, UD:gdb.btrace, gdbbtrace 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 ESMTP; Tue, 31 Jan 2017 12:59:45 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16B4E635C5; Tue, 31 Jan 2017 12:59:45 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0VCxhh8018431; Tue, 31 Jan 2017 07:59:44 -0500 Subject: Re: [PATCH v3 2/5] btrace: allow recording to be started (and stopped) for running threads To: Markus Metzger , gdb-patches@sourceware.org References: <1485770743-6603-1-git-send-email-markus.t.metzger@intel.com> <1485770743-6603-3-git-send-email-markus.t.metzger@intel.com> Cc: Simon Marchi From: Pedro Alves Message-ID: Date: Tue, 31 Jan 2017 12:59:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1485770743-6603-3-git-send-email-markus.t.metzger@intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-01/txt/msg00653.txt.bz2 On 01/30/2017 10:05 AM, Markus Metzger wrote: > --- > gdb/btrace.c | 46 ++++++++++++++-- > gdb/testsuite/gdb.btrace/enable-running.c | 47 ++++++++++++++++ > gdb/testsuite/gdb.btrace/enable-running.exp | 85 +++++++++++++++++++++++++++++ > 3 files changed, 174 insertions(+), 4 deletions(-) > create mode 100644 gdb/testsuite/gdb.btrace/enable-running.c > create mode 100644 gdb/testsuite/gdb.btrace/enable-running.exp > > diff --git a/gdb/btrace.c b/gdb/btrace.c > index d266af7..fec2cce 100644 > --- a/gdb/btrace.c > +++ b/gdb/btrace.c > @@ -141,6 +141,18 @@ ftrace_debug (const struct btrace_function *bfun, const char *prefix) > prefix, fun, file, level, ibegin, iend); > } > > +/* Validate that we can read PTID's registers. */ > + > +static void > +validate_registers_access_ptid (ptid_t ptid) > +{ > + struct cleanup *cleanup = save_inferior_ptid (); > + > + inferior_ptid = ptid; > + validate_registers_access (); > + do_cleanups (cleanup); > +} > + Please let's refactor things a bit to avoid the need to frob inferior_ptid and restore with a cleanup. Change the existing validate_registers_access like: static void -validate_registers_access () +validate_registers_access_ptid (ptid_t ptid) { /* No selected thread, no registers. */ -if (ptid_equal (inferior_ptid, null_ptid)) +if (ptid_equal (ptid, null_ptid)) error (_("No thread selected.")); [etc.] and then reimplement it back on top of validate_registers_access_ptid: validate_registers_access () { return validate_registers_access_ptid (inferior_ptid); } > + > +#include > + > +#define NTHREADS 3 > + > +static void * > +test (void *arg) > +{ > + /* Let's hope this is long enough for GDB to enable tracing and check that > + everything is working as expected. */ > + sleep (10); Need to include for sleep. I got: ..../src/gdb/testsuite/gdb.btrace/enable-running.c: In function 'test': ..../src/gdb/testsuite/gdb.btrace/enable-running.c:27:3: warning: implicit declaration of function 'sleep' [-Wimplicit-function-declaration] sleep (10); ^ Otherwise LGTM. Thanks, Pedro Alves