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 00EE53858D28 for ; Thu, 6 Apr 2023 19:28:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 00EE53858D28 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 [172.16.0.192] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id ABB1E1E0D3; Thu, 6 Apr 2023 15:28:44 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1680809324; bh=eCc3eQ+edRMcFNzp8xP4rsG+BmSR0UhLh/To6GAZQBI=; h=Date:Subject:To:References:From:In-Reply-To:From; b=cLucB9jRCGhLpZ0fmynl0qG78qga+NitDQSOba9s8Dz265WPSkv4yKHXT7sKPxRZh ZUI45YT523Rm49Cxy4gGALTE/TBf8IVfZRv9cuPO1RVJZJqNwjAP8PqMMh/b7rUIFo ZzPJqPhyhiZ28i8ICNaU2TwggRxurBcDHw3NrnO0= Message-ID: <775a2e6b-93fe-507a-b78a-991c7683c77a@simark.ca> Date: Thu, 6 Apr 2023 15:28:44 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH v4 02/13] core: Support fetching TARGET_OBJECT_X86_XSAVE_LAYOUT from architectures. Content-Language: fr To: John Baldwin , gdb-patches@sourceware.org References: <20230318010905.14294-1-jhb@FreeBSD.org> <20230318010905.14294-3-jhb@FreeBSD.org> From: Simon Marchi In-Reply-To: <20230318010905.14294-3-jhb@FreeBSD.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: On 3/17/23 21:08, John Baldwin wrote: > Add gdbarch_core_xfer_x86_xsave_layout to fetch the x86 XSAVE layout > structure from a core file. > > Current OS's do not export the offsets of XSAVE state components in > core dumps, so provide an i387_set_xsave_layout helper function to set > offsets based on known combinations of XCR0 masks and total state > sizes. Eventually when core dumps do contain this information this > function should only be used as a fall back for older core dumps. Not a big deal, but it's a bit odd to add the i387_set_xsave_layout function here, but not use it. I could see it being added with the first patch that uses and, and the current patch just adding the gdbarch_core_xfer_x86_xsave_layout gdbarch method + the call in corelow.c. More minor comments below. > diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py > index 92c501d2a72..0a1c5d927df 100644 > --- a/gdb/gdbarch_components.py > +++ b/gdb/gdbarch_components.py > @@ -1666,6 +1666,19 @@ of bytes read (zero indicates EOF, a negative value indicates failure). > predicate=True, > ) > > +Method( > + comment=""" > +Read offset OFFSET of TARGET_OBJECT_X86_XSAVE_LAYOUT from core file > +into buffer READBUF with length LEN. Return the number of bytes read > +(zero indicates EOF, a negative value indicates failure). > +""", > + type="LONGEST", > + name="core_xfer_x86_xsave_layout", > + params=[("gdb_byte *", "readbuf"), ("ULONGEST", "offset"), ("ULONGEST", "len")], > + predicate=True, > + invalid=True, You can remove `invalid=True`, following 564cddf8edc7 ("gdbarch: make invalid=True the default for all Components"). I have yet to see how this is going to be implemented (in subsequent patches), but I wonder if we really need to pass use readbuf / offset / len in this API. Wouldn't it be possible to pass a pointer or reference to an x86_xsave_layout object, and have the arch fill it? I understand that this matches the taret_read interface (we have to shoehorn the x86_xsave_layout through that interface), but I don't think it needs to propagate to the gdbarch method. > diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c > index df0a6058adc..7026dfed6e4 100644 > --- a/gdb/i387-tdep.c > +++ b/gdb/i387-tdep.c > @@ -898,6 +898,61 @@ static int xsave_pkeys_offset[] = > (xsave + xsave_pkeys_offset[regnum - I387_PKRU_REGNUM (tdep)]) > > > +/* See i387-tdep.h. */ > + > +bool > +i387_set_xsave_layout (uint64_t xcr0, size_t xsave_size, > + x86_xsave_layout *layout) > +{ > + if (HAS_PKRU(xcr0) && xsave_size == 2696) Space before parenthesis (a few times in this function). Simon