From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by sourceware.org (Postfix) with ESMTPS id B2CE83840C3D for ; Thu, 11 Jun 2020 10:41:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B2CE83840C3D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wm1-x343.google.com with SMTP id y20so4547471wmi.2 for ; Thu, 11 Jun 2020 03:41:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HuMlxkmHs/aim352tBFVuYXb1eu2l+AtEQGEQdPED3E=; b=Ez0b1wlmtyjFqAOrQRh/Hqq8QS4ZKNX1vnQQzd9acbwBMT/AaxJuYotaL7qL8l6kg+ 6bBIB7yOqaT2+MvGUsPbAUm2jKBouG1I0wwBmWxZsF2O6LV8Wka3qIESwPWI18F062Vk /0c+PLSTYWorjA6KFfa6eWhxnt4ekrRUwUatBL5fUZW5XiHaUqm4UAdv9+aQxmKGIS6x JiZBlsJTmXBZY8uGuFF/mSFqOgvFxe5tq0hNcOANg9ItSTFo9m1qiIdSD8DZEgrEOe2d HNDdvAMS4i8XTLuiIiFuhEKNaLfXCOj5QAppqypRWWtZdNPmePMclkNWasluwYxJ/0dO oI9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HuMlxkmHs/aim352tBFVuYXb1eu2l+AtEQGEQdPED3E=; b=cZGwS306Yr7dv/NjPC66zOleD3eP+F9NSFJI6wqdqtOTW8MwM7HSx3AdH0PTCRlJZO GiTj/jC5hN2iuW4yB/qOjtl+2xGrmgArd8k+epHYFz0kJtebDqrC6Tr6U2V4JRJP8TkQ t3JGxnEH7ZFRRNNNUYIae9ST95MJsWgLGt2oL4Bk7G8Ow2PNt3DgkfiOoSXQzl94LU5R mgKhlFc3wdCUli7bHifSPB1EyKX+OX3jB4ZYbnYcdDDFlyZUdU3P5Vw0KxT2P6M3B4g5 H810rrK/uMWTEqe/+18qgZt473clWE2RdO2/WowZxHXmiv+2ko+KPch6QH7y2RcWg57V 3j9w== X-Gm-Message-State: AOAM530EOTS4Y/yd25mm7815s1PEPbVWB8Vcgx6Q5TWG2WDm0N1iXsuL uHj2cPSiM6hWaTyyMyfLT2ELpH3p6rY= X-Google-Smtp-Source: ABdhPJxhwyyaBBgZZ0QNeWo5TIZb81WOkZnRKQ1OPdZOcL0iOTdLLJgpPQh/3UBSK8B4bRc6gr/lDw== X-Received: by 2002:a05:600c:2218:: with SMTP id z24mr7363267wml.24.1591872109594; Thu, 11 Jun 2020 03:41:49 -0700 (PDT) Received: from localhost (host86-128-12-16.range86-128.btcentralplus.com. [86.128.12.16]) by smtp.gmail.com with ESMTPSA id z16sm4271089wrm.70.2020.06.11.03.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2020 03:41:48 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: [PATCH 1/2] gdb: Allow target description to be dumped even when it is remote Date: Thu, 11 Jun 2020 11:41:30 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, 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 10:41:52 -0000 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")); + filename = "target.xml"; + } std::string filename_after_features (filename); auto loc = filename_after_features.rfind ("/features/"); @@ -1811,6 +1816,8 @@ void _initialize_target_descriptions (); void _initialize_target_descriptions () { + cmd_list_element *cmd; + tdesc_data = gdbarch_data_register_pre_init (tdesc_data_init); add_basic_prefix_cmd ("tdesc", class_maintenance, _("\ @@ -1842,11 +1849,10 @@ Unset the file to read for an XML target description.\n\ When unset, GDB will read the description from the target."), &tdesc_unset_cmdlist); - add_cmd ("c-tdesc", class_maintenance, maint_print_c_tdesc_cmd, _("\ + cmd = add_cmd ("c-tdesc", class_maintenance, maint_print_c_tdesc_cmd, _("\ Print the current target description as a C source file."), &maintenanceprintlist); - - cmd_list_element *cmd; + set_cmd_completer (cmd, filename_completer); cmd = add_cmd ("xml-descriptions", class_maintenance, maintenance_check_xml_descriptions, _("\ -- 2.25.4