From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 1CFAA3858D38 for ; Tue, 11 Apr 2023 01:19:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1CFAA3858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [10.0.0.11] (unknown [167.248.160.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 161951E0D2; Mon, 10 Apr 2023 21:19:26 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1681175966; bh=4aqEVeKji6jof4GT+efXjlJ6GSpVW0pCuonB2RxT2vg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=eM2RVzfB6RwsByhpHk8dDgwKIyFwaE43+cCBrJjz5KcoIpEiMW/5j4N6T7O2Ru2fx v2JksydmUZozh0968UW9Z99drtype1lUNcKBpZuKbg85LCVOJtxM2A2umlPmCM2p3H uxLs6GnvcqXUOq5+2Bk7s7x1Fffbn7m9lBqgjn5g= Message-ID: Date: Mon, 10 Apr 2023 21:19:25 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v4 01/13] x86: Add an x86_xsave_layout structure to handle variable XSAVE layouts. To: John Baldwin , gdb-patches@sourceware.org Cc: Aleksandar Paunovic References: <20230318010905.14294-1-jhb@FreeBSD.org> <20230318010905.14294-2-jhb@FreeBSD.org> <113146d6-48af-f0a3-0e87-4495a4529ca0@FreeBSD.org> Content-Language: en-US From: Simon Marchi In-Reply-To: <113146d6-48af-f0a3-0e87-4495a4529ca0@FreeBSD.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>> +i386_fetch_xsave_layout () >>> +{ >>> + struct x86_xsave_layout layout; >>> + LONGEST len = target_read (current_inferior ()->top_target (), >>> + TARGET_OBJECT_X86_XSAVE_LAYOUT, nullptr, >>> + (gdb_byte *) &layout, 0, sizeof (layout)); >>> + if (len != sizeof (layout)) >>> + return {}; >> >> Do you have an idea of which conditions can make it so `len != sizeof >> (layout)`? If I understand correctly, the contract for >> TARGET_OBJECT_X86_XSAVE_LAYOUT is that the caller passes a pointer to an >> x86_xsave_layout object and the callee fills it. This is all internal >> to GDB. I don't imagine how a target could return something else than >> ;`sizeof (layout)` (indicating success) or TARGET_XFER_E_IO (indicating >> failure), other than being buggy. >> >> All of this to say, should it be an assert? > > Hmm, in the case of TARGET_XFER_E_IO this function needs to return an > empty object (e.g. for native targets that don't support XSAVE at all). > > I should perhaps make it check for an error explicitly and then assert > that otherwise they are equal? That sounds good. My thinking is that if a target mistakenly returns a wrong length, I think we want to know about it, and not silently presume the target doesn't support the xsave layout query. Simon