From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id J0SKEi/9uWI3wQcAWB0awg (envelope-from ) for ; Mon, 27 Jun 2022 14:55:43 -0400 Received: by simark.ca (Postfix, from userid 112) id 318991E22B; Mon, 27 Jun 2022 14:55:43 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_DYNAMIC autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.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 75AF51E15C for ; Mon, 27 Jun 2022 14:55:42 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA159386F0C8 for ; Mon, 27 Jun 2022 18:55:40 +0000 (GMT) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by sourceware.org (Postfix) with ESMTPS id EA9AC3856DD8 for ; Mon, 27 Jun 2022 18:55:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EA9AC3856DD8 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f53.google.com with SMTP id k22so14348385wrd.6 for ; Mon, 27 Jun 2022 11:55:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=uhhwjDLM+CQRVksiNa3H74VbU+89qP2W8ylc5xEMHX4=; b=us8Cd8vczskXA40aFuCziY4jObFZGtEhhe2/TUdIY/5RIztNqnfdTMcnExSxjJJkaq 59xqF5jbWL02eM8A0/Fk04XUWigXtzBLEdRmLuXVreTQ/0+iuEXdWrW7nB5QLEuRoFge gxgzVAo6l8z56A7pKz8rynv4dM6tvqN67cZphILxStSSkQMxTcFRsXlOPKQTKeqwuRE/ IzfavDtKBGUHcsP7Qe0DMrELDYHa7tTjLYiXXJN3I1ygerkF71g2103K6g06IiKxzsKF 52+RDl4GpDwQkp/xkRPbgIDe+1ZGmb90XRBIcYdKN4zmsaBjVcUgk1fTyeOSyxZ5qX7m U7aQ== X-Gm-Message-State: AJIora+KBDyJlQQ+ARJ0SK2V5XEFsLGy+KPAIwo1WuPKadm7e04Fp4/y cAGcLKhYpy7jh4fsgFgxKumP05eK7zQ= X-Google-Smtp-Source: AGRyM1ubh+IYtw8inKo8Ts57OylJl7EIvctfPNRDfAXVnv6zbFacAPxWBpTyJnTSYd8OAgnZYpqvVA== X-Received: by 2002:a05:6000:80f:b0:21b:927a:16b1 with SMTP id bt15-20020a056000080f00b0021b927a16b1mr13311459wrb.440.1656356127891; Mon, 27 Jun 2022 11:55:27 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:5b14:8ad0:780f:bdda? ([2001:8a0:f924:2600:5b14:8ad0:780f:bdda]) by smtp.gmail.com with ESMTPSA id f17-20020a7bcd11000000b0039c811077d3sm13952921wmj.22.2022.06.27.11.55.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Jun 2022 11:55:26 -0700 (PDT) Message-ID: <1a2db7a8-5d9f-0f0e-55f0-3f82dc1adb43@palves.net> Date: Mon, 27 Jun 2022 19:55:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH 4/4] gdb: Clear tilecfg.start_row for any PC modification. Content-Language: en-US To: Felix Willgerodt , gdb-patches@sourceware.org References: <20220506121226.137608-1-felix.willgerodt@intel.com> <20220506121226.137608-5-felix.willgerodt@intel.com> From: Pedro Alves In-Reply-To: <20220506121226.137608-5-felix.willgerodt@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi Felix, The GDB change LGTM. But just to be clear, it is always OK to reset start_row, even if we didn't stop for a tile instruction fault? It won't ever lead to inferior corruption, for example? I'm thinking of how for instance, we always write to the PC after a breakpoint, to adjust it by -1, so a breakpoint on a tile insn will always lead to resetting start_row AFAICT. Some comments on the testcase below. On 2022-05-06 13:12, Felix Willgerodt via Gdb-patches wrote: > AMX tile instructions are restartable, e.g. on faults. Tilecfg.start_row > is used to restart the interrupted instructions at the right row. > On inferior calls, jumps or any other PC modification, start_row needs > to be reset. It binds to the current instruction and not to the one we > would start executing next in these cases. > --- > gdb/amd64-linux-tdep.c | 24 ++++ > gdb/testsuite/gdb.arch/amd64-amx-startrow.c | 122 ++++++++++++++++++ > gdb/testsuite/gdb.arch/amd64-amx-startrow.exp | 91 +++++++++++++ > 3 files changed, 237 insertions(+) > create mode 100644 gdb/testsuite/gdb.arch/amd64-amx-startrow.c > create mode 100755 gdb/testsuite/gdb.arch/amd64-amx-startrow.exp > > diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c > index cda90de54c6..65cce7f36ed 100644 > --- a/gdb/amd64-linux-tdep.c > +++ b/gdb/amd64-linux-tdep.c > @@ -314,6 +314,30 @@ amd64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) > within GDB. In all other cases the system call will not be > restarted. */ > regcache_cooked_write_unsigned (regcache, AMD64_LINUX_ORIG_RAX_REGNUM, -1); > + > + /* If we have interrupted a restart-able AMX instruction we should clear Odd hyphenization given "restartable" is a word. (and you used it in the commit log.) > + start_row. Any instructions we will now run should start at row 0. */ > + i386_gdbarch_tdep *tdep > + = (i386_gdbarch_tdep *) gdbarch_tdep (regcache->arch ()); > + if (tdep != nullptr && tdep->tilecfg_raw_regnum != -1) > + { > + gdb_byte tilecfg_buf[register_size (regcache->arch (), > + tdep->tilecfg_raw_regnum)]; > + > + if (regcache->raw_read (tdep->tilecfg_raw_regnum, tilecfg_buf) > + != REG_VALID) > + { > + warning (_ ("Could not reset $tilecfg.start_row.")); > + return; > + } > + > + /* start_row is the second byte. */ > + if (tilecfg_buf[1] != 0) > + { > + tilecfg_buf[1] = 0; > + regcache->raw_write (AMD64_AMX_TILECFG_RAW_REGNUM, tilecfg_buf); > + } > + } > } > > +standard_testfile > + > +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} debug] } { > + return -1 > +} I'd use build_executable instead here. See below for why. > + > +proc test_startrow {test} { > + global gdb_prompt hex decimal srcfile > + > + if { ![runto_main] } { > + untested "could not run to main" > + return -1 > + } > + > + set line1 [gdb_get_line_number "BP1"] > + set line2 [gdb_get_line_number "BP2"] > + set line_jump [gdb_get_line_number "Jump"] > + gdb_breakpoint $line1 > + gdb_breakpoint $line2 > + > + gdb_continue_to_breakpoint "line1" ".*$srcfile:$line1.*" > + > + # Set a watchpoint on the first page, which is un-protected. un-protected -> unprotected ? > + set watch_addr 0 > + gdb_test_multiple "p/x p2 - 8" "get watch_addr" { > + -re -wrap "= ($hex)" { > + set watch_addr $expect_out(1,string) > + pass $gdb_test_name > + } > + } This could be instead: set watch_addr [get_valueof "/x" "p2 - 8" 0 "get watch_addr"] > + > + # If we didn't get a watch_addr, it makes no sense to continue. > + if { $watch_addr == 0 } { > + return -1 > + } > + > + gdb_test "rwatch *(int*) $watch_addr" \ > + "atchpoint $decimal: \\*\\(int\\*\\) $watch_addr" This needs an explicit test name to avoid having addresses leak to gdb.sum results. > + > + gdb_test "continue" \ > + "Continuing.*atchpoint $decimal: \\*\\(int\\*\\) $watch_addr.*" > + > + gdb_test "p \$tilecfg.start_row" "= \[1-9\]+" "print non-zero start_row" > + > + if { $test == "jump" } { > + # Test jump. > + gdb_test "jump $line_jump" "Breakpoint $decimal, .*$srcfile:$line2.*" Likewise, better avoid line numbers in gdb.sum. Please double check other tests your adding for addresses and line numbers in gdb.sum. > + gdb_test "p \$tilecfg.start_row" "= 0" > + } else { > + # Test infcall. > + gdb_test "p square (2, 2)" "Breakpoint $decimal, .*$srcfile:$line2.*" > + gdb_test "p \$tilecfg.start_row" "= 0" > + } > +} > + > +with_test_prefix "infcall" { > + test_startrow "" > +} > + > +clean_restart $binfile > + > +with_test_prefix "jump" { > + test_startrow "jump" > +} I'd write this instead: foreach_with_prefix test {"infcall" "jump"} { clean_restart $binfile test_startrow $test } and this is the reason for using build_executable instead of prepare_for_testing at the top -- because this loop calls clean_restart itself.