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 D4A553858D33 for ; Thu, 6 Jul 2023 16:56:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D4A553858D33 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 4QxjNk4Vmrz3qnF; Thu, 6 Jul 2023 16:56:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 4QxjNk3bqNz3NNb; Thu, 6 Jul 2023 16:56:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688662598; 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=1WHTKYl0hABrvzgd1hMywcpBFYUcjioefcq+9r5c7Yo=; b=GAgTAj4cbr59stkBVRHdn0coNIG8raYpcutDahZjaPGwQ+5n0wYPE7fpNLh2ej/zZjk2xX BdXtkWWFZbQjyENv3vgC2xcglQTNjA4bohU5ZP7OzNFZ8TnwFoCNO5TDFrytKq6u7wLm5I z0gai1228T4NFH+gsljP9jiVMRNlNDwhBZhwU2eS5AIG/Uo4+aGYE4renByu+S8eJiaIJp wvCII/2RztQKlJQtEVuONWzIKpFHlg0p1ip32d0evMPtXwCBVvZIw27p4EDqLDyrT9HZPQ m66pt/LkUQ6XX0c/2J7jp4A8Ap/TFAQaVPk31puBYXtd7f8dz/YER5LSg40bwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1688662598; 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=1WHTKYl0hABrvzgd1hMywcpBFYUcjioefcq+9r5c7Yo=; b=IkZV/rkdCAolmuqL2Y8F6au6setKR6PG0d/uaZvQqKaG89EHj1O5w/KzALfdjbMsmnNTOY 65R0N4x8EgN2xVrDlNP+KNwISijH+MQvVxleVEi4XdFrF+IVWQzHkhrdMEccxhAxg38t/j fXVsa00BmltCP6UpfFww6uJS7jxGXf6kk7mEo/wDj2hmEYetZghMWlC96Tkup0/rV76mhM Ed0jgKK2On8KoXu+khujx/9mTugo9HOCV2BwA5L8RxCRyZsqYtDoXvw74Qj28G8Jvix/ZQ 8TC+f6fuUqjReVHQ2wMJKDihcKScXJMaJKehh6YbXQHN+srrZW7DxgN1t6cm1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1688662598; a=rsa-sha256; cv=none; b=CXGtSdJX+nOtnEFK3u2rpXMZLBxP9Iz93BoA/3d+lHqgXUkwyqEeez43wSJHTXsmog+gDp EeOKotEY5Q7jhjLMcJ6ZXO71bezYO70jwjA8I4wKc/0EnI3/8hKkvRrQpRl7dl0sK73gvk V/wz++6geL5b5vec5R4419LZN+Eze3lDNNysDCInarVcFgb7WqWpmMxNDJINRLYfEm1GxV ouXsGuNEmPcofKem9NgIedesUcuObUr+MXW8InwTDvdIrgeW5jyfZ1pD/HqlihVK5lUMiK c9j/+VqqssT9V6W6FAt5XhgC6zuiYrWF6ljgDrfJE/E6Try8U82mxF+l4e72+g== Received: from [IPV6:2601:648:8680:16b0:9018:f799:cdac:ccb1] (unknown [IPv6:2601:648:8680:16b0:9018:f799:cdac:ccb1]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4QxjNk0mCfzJxk; Thu, 6 Jul 2023 16:56:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Thu, 6 Jul 2023 09:56:36 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH 1/4] *-fbsd-nat: Handle null inferior in read_description. Content-Language: en-US To: Simon Marchi , gdb-patches@sourceware.org References: <20230526175742.66885-1-jhb@FreeBSD.org> <20230526175742.66885-2-jhb@FreeBSD.org> From: John Baldwin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.1 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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 7/6/23 9:18 AM, Simon Marchi wrote: > On 5/26/23 13:57, John Baldwin wrote: >> Don't invoke ptrace in the target read_description method if there is >> not an active inferior to query via ptrace. Instead, use the default >> register set for the architecture. >> >> Previously the native target could report an error from a failed >> ptrace operation when fetching a tdesc without an attached process. >> For example on FreeBSD/amd64: >> >> (gdb) target native >> Done. Use the "run" command to start a process. >> (gdb) unset tdesc filename >> Couldn't get registers: Operation not permitted. >> --- >> gdb/aarch64-fbsd-nat.c | 3 +++ >> gdb/amd64-fbsd-nat.c | 3 +++ >> gdb/arm-fbsd-nat.c | 3 +++ >> gdb/i386-fbsd-nat.c | 3 +++ >> 4 files changed, 12 insertions(+) >> >> diff --git a/gdb/aarch64-fbsd-nat.c b/gdb/aarch64-fbsd-nat.c >> index 709f5162ce0..29b58e5ff4a 100644 >> --- a/gdb/aarch64-fbsd-nat.c >> +++ b/gdb/aarch64-fbsd-nat.c >> @@ -120,6 +120,9 @@ aarch64_fbsd_nat_target::store_registers (struct regcache *regcache, >> const struct target_desc * >> aarch64_fbsd_nat_target::read_description () >> { >> + if (inferior_ptid == null_ptid) >> + return nullptr; >> + >> aarch64_features features; >> features.tls = have_regset (inferior_ptid, NT_ARM_TLS)? 1 : 0; >> return aarch64_read_description (features); >> diff --git a/gdb/amd64-fbsd-nat.c b/gdb/amd64-fbsd-nat.c >> index bae267f230f..adbd85571a5 100644 >> --- a/gdb/amd64-fbsd-nat.c >> +++ b/gdb/amd64-fbsd-nat.c >> @@ -310,6 +310,9 @@ amd64_fbsd_nat_target::read_description () >> struct reg regs; >> int is64; >> >> + if (inferior_ptid == null_ptid) >> + return nullptr; > > Why do you return nullptr here, instead of calling the beneath target, > as done in arm-fbsd-nat.c? Calling the beneath target seems like the > right thing to do. In practice, it will likely reach > dummy_target::read_description, which returns nullptr. I think you are right, and I will change both this and patch 2 for the Linux targets to call the beneath one. My thinking was that in general returning nullptr causes the caller code to pick a "default" tdesc, but that for arm-fbsd-nat.c I was trying to match the existing code (copied from arm-linux-nat.c) which calls the beneath target for its fallback instead of returning nullptr. -- John Baldwin