From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9AmaMnywfGfjwgUAWB0awg (envelope-from ) for ; Mon, 06 Jan 2025 23:41:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1736224892; bh=OO95eBcD8hsZg90RNsxX7zF/f9/0+woSe7fHVV+PYNc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=jf/RHz/YN6i8ZuwYlU5e3QI7nDzzKOX2XyQVUUoZcZc3WVT9mYUTsEeeqPG2Dn1Aa mGt+79IkMIHd0pi+QQViRcOd8vR5qp0b8+UVG/RNxt//tK/r2wvW6QKZB6hrYmc+CW Gv+z7bDz7ehziQ9/JBX6/2tVw29DItEttfcFGwyA= Received: by simark.ca (Postfix, from userid 112) id C09F71E0BB; Mon, 6 Jan 2025 23:41:32 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.0 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=OB/5OsKX; dkim=pass (1024-bit key) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=VbNVtIxw; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 58DA11E091 for ; Mon, 6 Jan 2025 23:41:28 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3ECE385840C for ; Tue, 7 Jan 2025 04:41:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3ECE385840C Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=OB/5OsKX; dkim=pass (1024-bit key) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=VbNVtIxw Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 08B373858D29 for ; Tue, 7 Jan 2025 04:40:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 08B373858D29 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 08B373858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736224847; cv=none; b=sZyknBQ/ZuZw3mYApShP4ZYJf72ivo6MgqBhZ+thlBvHj1EBoMrat296y7uRGuQKR4MkXkyiR8snxWH1KkjdlYeoKp1xaoikauZKJLWSlo7D8FUEIxEspeQIm5aHU4j/JUZzJrNKFAbS/SbmhVWT//5rbB7zn77DnVft0IXTHzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736224847; c=relaxed/simple; bh=OO95eBcD8hsZg90RNsxX7zF/f9/0+woSe7fHVV+PYNc=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version: Subject:To:From; b=cyWWk/+cD0E1YOA6mc4UXhIFqcHyhTYsRFgD3NKuo/EkQWcVd4Usr97v5fPpn2++jcddvqnAq5mFL2YiKxhq9viWOI+iMRthk2FXsq7VuMOGI4L9v/bRa/Cr1IvG2IfcOX18toHPAEVgOYAcicwCtucyjjWRo+aTeRT9xfreoLQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08B373858D29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1736224846; bh=OO95eBcD8hsZg90RNsxX7zF/f9/0+woSe7fHVV+PYNc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=OB/5OsKXNZLO+wRJ7INZIcygR6C/c0WXblik72XXOR3cZ2LMORkpUXK5+yacZaeey jp9xll0MxfZDFBuTg01vd9wBkvKDfnScmR4kxMz/fydXXnTWDMhX33fUe7x1eFns2R CfXMp8zi7lbAklOWNkgZyQIVjNMtxARyjO52f9CU= Received: by simark.ca (Postfix, from userid 112) id 9F9531E0BB; Mon, 6 Jan 2025 23:40:46 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1736224835; bh=OO95eBcD8hsZg90RNsxX7zF/f9/0+woSe7fHVV+PYNc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=VbNVtIxwUY/hJC1MlawylpoEphpRd379P1as/vuzxIZNMA/X+/QwEtG84pGZLkv+a 1aZzCP98jIOL3JOGcYazq9hmsqw894ZD9E6UGd5jKzQ8nwGHqddf9q9u7kYSrr/XUG DBwTrwkWUdgjdVVF/R8GcjjiKAxx/kjgb4TUgns4= Received: from [10.0.0.11] (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 601291E091; Mon, 6 Jan 2025 23:40:35 -0500 (EST) Message-ID: Date: Mon, 6 Jan 2025 23:40:34 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 03/11] gdbserver: use inheritance more to define tracepoint contexts To: Tankut Baris Aktemur , gdb-patches@sourceware.org Cc: simon.marchi@efficios.com References: <20241230-upstream-gdbserver-regcache-v2-0-020a9514fcf0@intel.com> <20241230-upstream-gdbserver-regcache-v2-3-020a9514fcf0@intel.com> Content-Language: en-US From: Simon Marchi In-Reply-To: <20241230-upstream-gdbserver-regcache-v2-3-020a9514fcf0@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 2024-12-30 05:49, Tankut Baris Aktemur wrote: > This is a continuation of the previous refactoring to use inheritance > in the definition of tracepoints contexts. Again, no behavioral change > is intended. > > Different tracepoint contexts are identified by the `type` field. The > field is used only in `get_context_regcache`, where we essentially > have 3 cases, each corresponding to a tracepoint context type. Remove > the `type` field and split the `get_context_regcache` function into 3 > virtual method implementations. > > Tested by rebuilding gdbserver with '--enable-inprocess-agent=no' and > '--enable-inprocess-agent=yes'. > --- > gdbserver/tracepoint.cc | 95 +++++++++++++++++++++++++------------------------ > 1 file changed, 48 insertions(+), 47 deletions(-) > > diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc > index fc0586a5c5ace6edc1fc72d24511c6f36e97f759..1b6e9d05273ea7a709f1880473c070c59169ddd5 100644 > --- a/gdbserver/tracepoint.cc > +++ b/gdbserver/tracepoint.cc > @@ -1278,7 +1278,7 @@ static char *tracing_stop_note; > collect_data_at_tracepoint. */ > struct tracepoint_hit_ctx > { > - enum tracepoint_type type; > + virtual struct regcache *get_regcache () = 0; I would name this method just `regcache ()`, I try to push not to have the "get_" prefix for getters. Methods without a verb are implicitly getters. > }; > > #ifdef IN_PROCESS_AGENT > @@ -1290,9 +1290,10 @@ struct fast_tracepoint_ctx : public tracepoint_hit_ctx > fast_tracepoint_ctx (unsigned char *_regs) > : regcache_initted (0), regs (_regs) > { > - type = fast_tracepoint; > } > > + virtual struct regcache *get_regcache () override; I think you could move the implementation of those methods here, it's all in the same .cc file anyway. And it would help with readability, given the mess of ifdefs below. > +struct regcache * > +static_tracepoint_ctx::get_regcache () > +{ > #ifdef HAVE_UST > - if (ctx->type == static_tracepoint) > - { > - auto sctx = static_cast (ctx); > + const struct target_desc *ipa_tdesc = get_ipa_tdesc (ipa_tdesc_idx); > > - if (!sctx->regcache_initted) > - { > - sctx->regcache_initted = 1; > - init_register_cache (&sctx->regcache, ipa_tdesc, sctx->regspace); > - supply_regblock (&sctx->regcache, NULL); > - /* Pass down the tracepoint address, because REGS doesn't > - include the PC, but we know what it must have been. */ > - supply_static_tracepoint_registers (&sctx->regcache, > - (const unsigned char *) > - sctx->regs, > - sctx->tpoint->address); > - } > - regcache = &sctx->regcache; > - } > -#endif > -#else > - if (ctx->type == trap_tracepoint) > + if (!this->regcache_initted) > { > - auto tctx = static_cast (ctx); > - regcache = tctx->regcache; > + this->regcache_initted = 1; > + init_register_cache (&this->regcache, ipa_tdesc, this->regspace); > + supply_regblock (&this->regcache, nullptr); > + /* Pass down the tracepoint address, because REGS doesn't > + include the PC, but we know what it must have been. */ > + supply_static_tracepoint_registers (&this->regcache, > + (const unsigned char *) > + this->regs, > + this->tpoint->address); > } > + > + return &this->regcache; > +#else > + gdb_assert_not_reached ("static tracepoint feature requires UST"); > #endif I think that static_tracepoint_ctx (and therefore this method) could simply not exist at all if !HAVE_UST? Although if you remove UST support, the question won't matter anymore. Simon