From patchwork Mon Jul 10 13:55:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 21496 Received: (qmail 24221 invoked by alias); 10 Jul 2017 13:55:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 23792 invoked by uid 89); 10 Jul 2017 13:55:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=validations, unnecessarily, H*r:sk:static. X-HELO: mail-it0-f46.google.com Received: from mail-it0-f46.google.com (HELO mail-it0-f46.google.com) (209.85.214.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Jul 2017 13:55:49 +0000 Received: by mail-it0-f46.google.com with SMTP id m84so39468500ita.0 for ; Mon, 10 Jul 2017 06:55:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=d/e7FLyxvIV3ozR0WsvuE+F67hNsm9qqfA5qNw5Gs2g=; b=iMDqSGfVyJfwg4Hl1vERG+6DyM6m3nJPZIedXIVTNcmCjsKpXhqSglaaSwkrW1+Yiy n0OxVlbdj0EjMRCIPwGNnlVRH4dOmjDr5Khl4mngZyeAFqi6ON47MCYIppkaUDWoXRPC MiNFHA7D0dfOEQBACvOFJo00VRDD0p1KzzzjWk1NqIzocfclBcTAN/9rb/79kWR19bws 3ILupjuasIqNDbUH3so8fOhIMaCIUBqoz9FZOE68nuf+TKwvQNh/PCknVg8pqZnjeYMK P8RX1OJ9HYHOia3oFBFeBQyB5u28V1iVOMiVOz+bCMfhhloQsHRc9HOQigtT3ol0RzSp MNHw== X-Gm-Message-State: AIVw110YtiqFDhed8Cr3mU0hUBoQ1jZFHobWPXtq/jmfoxFhxXOS+vB4 udEMdkeLB9lAXsZV X-Received: by 10.36.44.74 with SMTP id i71mr10935181iti.112.1499694947266; Mon, 10 Jul 2017 06:55:47 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id v96sm5973996ioi.50.2017.07.10.06.55.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Jul 2017 06:55:46 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 03/26] Add optional argument to command "maint prints c-tdesc" Date: Mon, 10 Jul 2017 14:55:17 +0100 Message-Id: <1499694940-23564-4-git-send-email-yao.qi@linaro.org> In-Reply-To: <1499694940-23564-1-git-send-email-yao.qi@linaro.org> References: <1499694940-23564-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes Nowadays, we need two steps to print c files for xml target description, that is, 1) read xml target description in, update the current tdesc, 2) visit the current tdesc, print the c file. It is unnecessary to involve in current tdesc, and some validations in each gdbarch are performed unnecessarily, which will reject some target descriptions if they are missing some mandatory feature. This patch adds an optional argument to "maint print c-tdesc", which is an XML file target description, so that we can combine the two steps above into one step, and don't have to involve in global current tdesc. gdb: 2017-06-30 Yao Qi * NEWS: Mention it. * features/Makefile (%.c: %.xml): Pass the xml file name to command "maint print c-tdesc". * target-descriptions.c (maint_print_c_tdesc_cmd): Get file name from 'arg'. gdb/doc: 2017-06-30 Yao Qi * gdb.texinfo (Maintenance Commands): Document optional argument of "maint print c-tdesc". --- gdb/NEWS | 3 +++ gdb/doc/gdb.texinfo | 14 +++++++++----- gdb/features/Makefile | 3 +-- gdb/target-descriptions.c | 25 ++++++++++++++++++------- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 7c8a8f6..9cd1df1 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -17,6 +17,9 @@ QStartupWithShell Indicates whether the inferior must be started with a shell or not. +* The "maintenance print c-tdesc" command now takes an optional + argument which is the file name of XML target description. + * New commands set debug separate-debug-file diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 5f55a67..08a7681 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -34687,12 +34687,16 @@ checksum. Print the entire architecture configuration. The optional argument @var{file} names the file where the output goes. -@kindex maint print c-tdesc +@kindex maint print c-tdesc @r{[}@var{file}@r{]} @item maint print c-tdesc -Print the current target description (@pxref{Target Descriptions}) as -a C source file. The created source file is built into @value{GDBN} -when @value{GDBN} is built again. This command is used by developers -after they add or modify XML target descriptions. +Print the target description (@pxref{Target Descriptions}) as +a C source file. By default, the target description is for the current +target, but if the optional argument @var{file} is provided, that file +is used to produce the description. The @var{file} should be an XML +document, of the form described in @ref{Target Description Format}. +The created source file is built into @value{GDBN} when @value{GDBN} is +built again. This command is used by developers after they add or +modify XML target descriptions. @kindex maint print dummy-frames @item maint print dummy-frames diff --git a/gdb/features/Makefile b/gdb/features/Makefile index 3bc8b5a..dd0f28a 100644 --- a/gdb/features/Makefile +++ b/gdb/features/Makefile @@ -254,8 +254,7 @@ $(outdir)/%.dat: %.xml number-regs.xsl sort-regs.xsl gdbserver-regs.xsl cfiles: $(CFILES) %.c: %.xml - $(GDB) -nx -q -batch \ - -ex "set tdesc filename $<" -ex 'maint print c-tdesc' > $@.tmp + $(GDB) -nx -q -batch -ex 'maint print c-tdesc $<' > $@.tmp sh ../../move-if-change $@.tmp $@ # Other dependencies. diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index ffabc71..e782084 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -1726,18 +1726,29 @@ maint_print_c_tdesc_cmd (char *args, int from_tty) int ix, ix2, ix3; int printed_field_type = 0; - /* Use the global target-supplied description, not the current - architecture's. This lets a GDB for one architecture generate C - for another architecture's description, even though the gdbarch - initialization code will reject the new description. */ - tdesc = current_target_desc; + if (args == NULL) + { + /* Use the global target-supplied description, not the current + architecture's. This lets a GDB for one architecture generate C + for another architecture's description, even though the gdbarch + initialization code will reject the new description. */ + tdesc = current_target_desc; + filename = target_description_filename; + } + else + { + /* Use the target description from the XML file. */ + filename = args; + tdesc = file_read_description_xml (filename); + } + if (tdesc == NULL) error (_("There is no target description to print.")); - if (target_description_filename == NULL) + if (filename == NULL) error (_("The current target description did not come from an XML file.")); - filename = lbasename (target_description_filename); + filename = lbasename (filename); function = (char *) alloca (strlen (filename) + 1); for (inp = filename, outp = function; *inp != '\0'; inp++) if (*inp == '.')