From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D34FC3858D1E for ; Tue, 14 Feb 2023 15:48:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D34FC3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676389718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=y0QaPnYT8hEZYfbMLomobRsc9NRl60t5gxrAyB4IYI0=; b=bnf5WiYzPUkAPZtekKtRl+SLKJ3eT1eTYNHYcatcV3+ASwxoCpXwlazbenR3iah+vzjGZe c+u+53cvh2MNGV2lDKawJ6vcDXXKHgjCScXidenVD6YWsVxgbSQRM9/lxgB4l1kFVa4H9v +EptOS7p4BqS/riGJUYLTvOqLiGKIiI= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-338-glq3_fjsMsmUHdV-0XVpFg-1; Tue, 14 Feb 2023 10:48:37 -0500 X-MC-Unique: glq3_fjsMsmUHdV-0XVpFg-1 Received: by mail-qt1-f199.google.com with SMTP id a24-20020ac87218000000b003bb7c7a82f7so9404798qtp.9 for ; Tue, 14 Feb 2023 07:48:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=y0QaPnYT8hEZYfbMLomobRsc9NRl60t5gxrAyB4IYI0=; b=HJ7haiWHuj7MF/KGXgQie6FFQP+yZBx6hkUUvjPVmHCXlN1+p8dxDBWiJRkJAgbGSn l98blx8+NetuJfnFYAWVwgko2j3AwPUYXwxE4b3ZrRFx0Fpx0gWF7CuuyPADUP/aSTpm o76aXoThjJDL3C2C3WorxfbVbnEqK7N7XmxZo+kVlfc8y03x0Ldv6WxA8Sq0B6weknaO b+8pAYH1Y6gRqeNQNFeK9e1dARPl4xVtOl8OhQXdnBxIQUtfmHzUpujEXQwC5o5QStn4 UOpPReNwfyyHQIct8xVD95zwqk98QVUrgWjAAryG2njz4/idMCLgj3cHDsoKnYPfMfrG nOEQ== X-Gm-Message-State: AO0yUKVx3ZxrdYWUYuSLGuXpR20A3gr15qNOMJ2TngjVK31FoI/oyVNc HfziY7T93sHBym9OMEHZ+QGC6yUokerB3uVz2nNgwOiA2ndpqcLG5/wtiF4/Tu41ELAX5Nu3OJ2 h8cvy587bmsammcntxZToepSdUmDq/C5j9RXMkqnOqdDoy/VhPWa7WzqY9bTz9vShjYff69t6kZ JaBYI= X-Received: by 2002:ac8:5fc4:0:b0:3b9:bd28:bb80 with SMTP id k4-20020ac85fc4000000b003b9bd28bb80mr5131159qta.15.1676389716971; Tue, 14 Feb 2023 07:48:36 -0800 (PST) X-Google-Smtp-Source: AK7set+ywc8Kx5MQcHUYLLHNNzTPmVm9xT3vrzW+stmLd+NcXkX0Gu20SbtHSBuPHR8b7pAFXVb6aA== X-Received: by 2002:ac8:5fc4:0:b0:3b9:bd28:bb80 with SMTP id k4-20020ac85fc4000000b003b9bd28bb80mr5131117qta.15.1676389716649; Tue, 14 Feb 2023 07:48:36 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id u129-20020a376087000000b007339c5114a9sm11938935qkb.103.2023.02.14.07.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Feb 2023 07:48:36 -0800 (PST) From: Andrew Burgess To: Tom Tromey via Gdb-patches , gdb-patches@sourceware.org Cc: Tom Tromey Subject: Re: [PATCH] Do not record a rejected target description In-Reply-To: <20230112193356.1133696-1-tromey@adacore.com> References: <20230112193356.1133696-1-tromey@adacore.com> Date: Tue, 14 Feb 2023 15:48:34 +0000 Message-ID: <87bklwmenh.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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: Tom Tromey via Gdb-patches writes: > When connecting to a certain target, gdb issues a warning about the > target description: > > (gdb) target remote localhost:7947 > Remote debugging using localhost:7947 > warning: Architecture rejected target-supplied description > > If you then kill the inferior and change the exec-file, this will > happen: > > (gdb) file bar > Architecture of file not recognized. > > After this, debugging doesn't work very well. > > What happens here is that, despite the warning, > target_find_description records the downloaded description in the > target_desc_info. Then the "file" command ends up calling > set_gdbarch_from_file, which uses that description. > > It seems to me that, because the architecture rejected the > description, it should not be used. That is what this patch > implements. > --- > gdb/target-descriptions.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c > index 1a451c79b82..38d0b3f8c7d 100644 > --- a/gdb/target-descriptions.c > +++ b/gdb/target-descriptions.c > @@ -565,7 +565,10 @@ target_find_description (void) > > info.target_desc = tdesc_info->tdesc; > if (!gdbarch_update_p (info)) > - warning (_("Architecture rejected target-supplied description")); > + { > + warning (_("Architecture rejected target-supplied description")); > + tdesc_info->tdesc = nullptr; > + } This seems fine, but it is possible that an exception could take us out of this function too, for example, a misbehaving remote target can cause target_read_description_xml to throw an exception. I guess that any of the issues you were originally seeing would also trigger if we throw an exception. I wonder if a better solution would be to use a RAII object to ensure that tdesc_info->tdesc is always reset to nullptr on scope exit, then at the end of target_find_description, after this line: tdesc_info->fetched = true; we would call a method on the RAII object to indicate that it should NOT clear the tdesc field. Thanks, Andrew