From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 1A6yEL7ac2KieAQAWB0awg (envelope-from ) for ; Thu, 05 May 2022 10:10:06 -0400 Received: by simark.ca (Postfix, from userid 112) id 372D21E058; Thu, 5 May 2022 10:10:06 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=MjbJgCYp; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id AF5951E00D for ; Thu, 5 May 2022 10:10:05 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EED923857365 for ; Thu, 5 May 2022 14:10:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EED923857365 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1651759805; bh=Ih5CJ16q69E1zS7ZmeVhvWqp/co+IQxNF5s6l+hs1Yw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=MjbJgCYpCQi/TnMwoz2LUKIiUAASgn9Ydb/TmjF9GCvgopCNlVL/2ghDZ/v3J7pYd ShDJ+4jhpLsx55/zXxNlDKI7ewadMbSQJIgSDeJgr5E8U/Q4eCYbCNKH0CGnWATfuK NJgm4fQ2MrFXbuBMAln8axeT+xLSERtQljnw2/ak= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id D36D93858D3C for ; Thu, 5 May 2022 14:09:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D36D93858D3C X-ASG-Debug-ID: 1651759771-0c856e06adda8060001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id YQygKrNYynLzvyGv (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 05 May 2022 10:09:31 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from smarchi-efficios.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 4880B441D64; Thu, 5 May 2022 10:09:31 -0400 (EDT) X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Subject: [PATCH] gdb: make regcache's cooked_write_test selftest work with native-extended-gdbserver board Date: Thu, 5 May 2022 10:09:30 -0400 X-ASG-Orig-Subj: [PATCH] gdb: make regcache's cooked_write_test selftest work with native-extended-gdbserver board Message-Id: <20220505140930.1087179-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1651759771 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2803 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.97806 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Running $ make check TESTS="gdb.gdb/unittest.exp" RUNTESTFLAGS="--target_board=native-extended-gdbserver" I get some failures: Running selftest regcache::cooked_write_test::i386.^M Self test failed: target already pushed^M Running selftest regcache::cooked_write_test::i386:intel.^M Self test failed: target already pushed^M Running selftest regcache::cooked_write_test::i386:x64-32.^M Self test failed: target already pushed^M Running selftest regcache::cooked_write_test::i386:x64-32:intel.^M Self test failed: target already pushed^M Running selftest regcache::cooked_write_test::i386:x86-64.^M Self test failed: target already pushed^M Running selftest regcache::cooked_write_test::i386:x86-64:intel.^M Self test failed: target already pushed^M Running selftest regcache::cooked_write_test::i8086.^M Self test failed: target already pushed^M This is because the native-extended-gdbserver automatically connects GDB to a GDBserver on startup, and therefore pushes a remote target on the initial inferior. cooked_write_test is currently written in a way that errors out if the current inferior has a process_stratum_target pushed. Rewrite it to use scoped_mock_context, so it doesn't depend on the current inferior (the current one upon entering the function). Change-Id: I0357f989eacbdecc4bf88b043754451b476052ad --- gdb/regcache.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/gdb/regcache.c b/gdb/regcache.c index a5e83da1ca41..037659ef8fae 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1944,30 +1944,9 @@ cooked_read_test (struct gdbarch *gdbarch) static void cooked_write_test (struct gdbarch *gdbarch) { - /* Error out if debugging something, because we're going to push the - test target, which would pop any existing target. */ - if (current_inferior ()->top_target ()->stratum () >= process_stratum) - error (_("target already pushed")); - /* Create a mock environment. A process_stratum target pushed. */ - - target_ops_no_register mock_target; - - /* Push the process_stratum target so we can mock accessing - registers. */ - current_inferior ()->push_target (&mock_target); - - /* Pop it again on exit (return/exception). */ - struct on_exit - { - ~on_exit () - { - pop_all_targets_at_and_above (process_stratum); - } - } pop_targets; - - readwrite_regcache readwrite (&mock_target, gdbarch); - + scoped_mock_context ctx (gdbarch); + readwrite_regcache readwrite (&ctx.mock_target, gdbarch); const int num_regs = gdbarch_num_cooked_regs (gdbarch); for (auto regnum = 0; regnum < num_regs; regnum++) -- 2.26.2