From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id AEA5F3938C2C for ; Thu, 11 Jun 2020 11:33:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AEA5F3938C2C Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-392-3bfDU1xePI6ZMCVt__U7WQ-1; Thu, 11 Jun 2020 07:33:11 -0400 X-MC-Unique: 3bfDU1xePI6ZMCVt__U7WQ-1 Received: by mail-wr1-f72.google.com with SMTP id a4so2450745wrp.5 for ; Thu, 11 Jun 2020 04:33:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Vwrz+3BM9XUOTU3V1sagLjOOabZjdO2rElXYH5W3SRI=; b=aNo6uhQmax8bg26SN9BN41wL3Sr5UhVEXH0BtvEtDg0wmoS7lLpv3jVX5O3azzKphn 8gT3DA6faWgJAdxJ49ImeBsC5GHzp8XTb2ES+Sehur3hYa75Rgx/hhN030bDKyW7kTz+ OAE5W2Bl3HUk0wP0Uw0BCjxeYwp6qnafwBYfi8KPcVRQ42u04SCkTFnZB1Q1ek7va3aL H/DUZSCyI+by4bdtYK+C1yTYvXZX+yyOaSACBadNVFshglYsuWWkIx47iQVOY15BeztB 05nGVmx1+HSkvKLuzq81PibM4PymacVQmi9OaXWnd/hZh+335E1QFXk30NL/ZH2O3+8+ ZfnA== X-Gm-Message-State: AOAM532ZsRp4zJCTtIu/qPDwbp6bQAkTWpurj2g+Nobclr4qEuxwqtao Ni3Qo44SJNlYAePu2szvYsCkURkWRLkXvbIgml+VN/z1OkzQ3teXxW73qRBVu86kJjdf7APX+NG 4U1rPsm49Zi7fGt4IHeePdA== X-Received: by 2002:a1c:67c3:: with SMTP id b186mr7394669wmc.167.1591875190205; Thu, 11 Jun 2020 04:33:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwg++GODA8F2FtJ+YlBtMNGkNgK0Xvn4qoarcNoFbW+IeURCdZm5lm/f+J35UaBmpHotF54CA== X-Received: by 2002:a1c:67c3:: with SMTP id b186mr7394644wmc.167.1591875189914; Thu, 11 Jun 2020 04:33:09 -0700 (PDT) Received: from ?IPv6:2001:8a0:f922:c400:56ee:75ff:fe8d:232b? ([2001:8a0:f922:c400:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id j11sm4313664wru.69.2020.06.11.04.33.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Jun 2020 04:33:09 -0700 (PDT) Subject: Re: [PATCH 1/2] gdb: Allow target description to be dumped even when it is remote To: Andrew Burgess , gdb-patches@sourceware.org References: From: Pedro Alves Message-ID: <3dc13658-f2ab-a76b-ee67-e1b9f343eef1@redhat.com> Date: Thu, 11 Jun 2020 12:33:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.4 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jun 2020 11:33:14 -0000 On 6/11/20 11:41 AM, Andrew Burgess wrote: > The maintenance command 'maintenance print c-tdesc' can only print the > target description if it was loaded from a local file, or if the local > filename is passed to the maintenance command as an argument. > > Sometimes it would be nice to know what target description GDB was > given by the remote, however, if I connect to a remote target and try > this command I see this: > > (gdb) maintenance print c-tdesc > The current target description did not come from an XML file. > (gdb) > > Which is not very helpful. > > This commit changes things so that if the description came from the > remote end then GDB will use the fake filename 'target.xml' as the > filename for the description, GDB will then create the C description > of the target as if it was in a file 'target.xml'. > > I originally added this functionality so I could inspect the > description passed to GDB by the remote target. After using this for > a while I realised that actually having GDB recreate the XML would be > even better, so a later commit will add that functionality too. > > Still, given how small this patch is I thought it might be nice to > include this in GDB anyway. > > While I was working on this anyway I've added filename command > completion to this command. > > gdb/ChangeLog: > > * target-descriptions.c (maint_print_c_tdesc_cmd): Use fake > filename for target descriptions that came from the target. > (_initialize_target_descriptions): Add filename command completion > for 'maint print c-tdesc'. > --- > gdb/ChangeLog | 7 +++++++ > gdb/target-descriptions.c | 14 ++++++++++---- > 2 files changed, 17 insertions(+), 4 deletions(-) > > diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c > index 20a3a640f4f..55ea416d69a 100644 > --- a/gdb/target-descriptions.c > +++ b/gdb/target-descriptions.c > @@ -1680,7 +1680,12 @@ maint_print_c_tdesc_cmd (const char *args, int from_tty) > error (_("There is no target description to print.")); > > if (filename == NULL) > - error (_("The current target description did not come from an XML file.")); > + { > + printf_unfiltered (_("The current target description was fetched " > + "from the target, using\n'target.xml' as a fake " > + "filename.\n\n")); That "," makes it read a little bit ambiguously. Try reading the sentence without the "," to see what I mean: The current target description was fetched from the target using 'target.xml' as a fake filename. This can be read as GDB having read the remote fake 'target.xml' filename, like: fetch_available_features_from_target ("target.xml", ops); which is what it always does anyway... I'd suggest a hard period (and line break after the period) instead: The current target description was fetched from the target. Using 'target.xml' as a fake filename. But, why do we need to provide a fake name at all? Isn't the only use of that filename to print it in the comment, here: /* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: Original: target.xml */ How about just doing this: --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -1680,7 +1680,7 @@ maint_print_c_tdesc_cmd (const char *args, int from_tty) error (_("There is no target description to print.")); if (filename == NULL) - error (_("The current target description did not come from an XML file.")); + filename = "fetched from current target"; with no printf_unfiltered call, and then we get: (gdb) maint print c-tdesc /* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: Original: fetched from current target */ Thanks, Pedro Alves