From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id A17DB3858C5E for ; Mon, 10 Apr 2023 20:42:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A17DB3858C5E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4PwLWN3vzYz44ZP; Mon, 10 Apr 2023 20:42:24 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PwLWM4gYNz4H2s; Mon, 10 Apr 2023 20:42:23 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681159343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xV5blEvsf9H5vwbkka1uH/tDTsLdBCi86f4dzcTghs0=; b=R9QiYk5Cd/AaahXFh/yjGpOEg5luCugg084QVqeGuTQegaOmw+ohzslg+2DWq+8vKI1zWk ViIo5b7h5p+teQeRPBqCWZb6tWULTmiHdo2yk97/C5O6EdH2PqrdOSxeEVVynNvouUC/jf TGV7/0EGe4tv7f0r5Z7IpZpiNFS7GZGtsWTt5KS1VqSX+hvWqGmfy8tP0qyI6NF9lxo6tg Hc4uLWpUB3BGFhB6JWoe11T6N3NJdO2PTC7kurXVVCG5HnUUcTtjKloTfcXLbhf6/9KCq1 wvEzzpteggl+w/Z/gz1pQf7U1Sk8S28aPQSqWR51QnuxJXJgv0Zwb8JjO6XH/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681159343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xV5blEvsf9H5vwbkka1uH/tDTsLdBCi86f4dzcTghs0=; b=AT4dPN3pYFxM4XvxOTbcLh1qdVxvWGohdpUw4/qyb/xGIdIXdUf+Lpe3kNGXAlZ3yznI/v kAJVXToIfl3DyHfsZP4DM1hYiWzFNMz8hmO0wQ1CFOF6AQQ1F4UWWnBQi4vCx9mEOwrmkb 6n1i49IEOpDxFFQxiT775B+1Y7V+n3ubgLlfDvyVRw3dVHe5P4Xa2BjePnWPDlsfKiocOO XlafPNE1zR5QoMXk3U6rd/b15MADtnjbKQ+hQex69pmf0bedmUxnd2fKTXyZwJ/UPfWW+t dzlzv5cTJXlY5F0EpVmDgMcLpW4JoIM4aEKW9RDbwzV8hMOGsGcv72XiDPfc1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681159343; a=rsa-sha256; cv=none; b=mlU4x9TJsCufCYcmoursnwrSwZW7gmK6BW4AiND0sddgPZHpJ/RzFyb3ZZf+A/CqNJ5kfu pAy34Cvr5pmISP+qOEGBtuOe90UxQBhWp2q62xa0NAdjenon4ULGU3VOLi8ZooSNup5qlH odShla9kC0f14CR/bREte8tV33ZmIJf3Owqjc80CIHJyR71FX4nMl2HMVXxM3NCLfYPYEm cG9bmmlGG0Iltgwz1sRL792OTWWrpEYl65kjGCfPg4BYbsB2Jv2S+Xp+wU5ZAhaL7QQyBt VxJYKJqBLGI8U2rIWxJl45b1k8mKPhL9cPlFoYuT3kgGQ/N9lQBoC5pK27pBgQ== Received: from [IPV6:2601:648:8680:16b0:4564:3328:dee2:f08a] (unknown [IPv6:2601:648:8680:16b0:4564:3328:dee2:f08a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4PwLWL6jKfzf74; Mon, 10 Apr 2023 20:42:22 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <7678c952-45bc-2085-ff12-1c36622839fa@FreeBSD.org> Date: Mon, 10 Apr 2023 13:42:20 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Content-Language: en-US To: Simon Marchi , gdb-patches@sourceware.org References: <20230318010905.14294-1-jhb@FreeBSD.org> <20230318010905.14294-3-jhb@FreeBSD.org> <775a2e6b-93fe-507a-b78a-991c7683c77a@simark.ca> From: John Baldwin Subject: Re: [PATCH v4 02/13] core: Support fetching TARGET_OBJECT_X86_XSAVE_LAYOUT from architectures. In-Reply-To: <775a2e6b-93fe-507a-b78a-991c7683c77a@simark.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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 4/6/23 12:28 PM, Simon Marchi wrote: > 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. Humm, the reason I added it here is that it is part of OS-independent infrastructure that will later be used by OS-specific ABIs. Adding this function (or other infrastructure) as part of the commit adding FreeBSD amd64/i386 support seemed a bit odd to me. I wanted it to be clear which parts are OS-specific vs not in the history in part so it is easier for other OS's to add XSAVE support in the future. > 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. Hmm, passing down the readbuf, offset, len fields is consistent with other gdbarch methods called from core_target::xfer_partial such as gdbarch_core_xfer_shared_libraries and gdbarch_core_xfer_siginfo. That said, it would simplify the implementation in the architectures if core_target::xfer_partial handled the partial reads and always read the full thing from the gdbarch. In particular unlike the other above methods, the thing being read is a fixed size. I'll make that change as I think it will be nicer, thanks. >> 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). Fixed. -- John Baldwin