Add optional argument to command "maint prints c-tdesc"
authorYao Qi <yao.qi@linaro.org>
Wed, 26 Jul 2017 11:03:47 +0000 (12:03 +0100)
committerYao Qi <yao.qi@linaro.org>
Wed, 26 Jul 2017 11:03:47 +0000 (12:03 +0100)
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-07-26  Yao Qi  <yao.qi@linaro.org>

* 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-07-26  Yao Qi  <yao.qi@linaro.org>

* gdb.texinfo (Maintenance Commands): Document optional
argument of "maint print c-tdesc".

gdb/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/features/Makefile
gdb/target-descriptions.c

index be39af654b78b83a85eb4689f1b2d310b4031251..05072ce93b59970da7309202eee46f1274d733a5 100644 (file)
@@ -1,3 +1,11 @@
+2017-07-26  Yao Qi  <yao.qi@linaro.org>
+
+       * 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'.
+
 2017-07-26  Yao Qi  <yao.qi@linaro.org>
 
        * target-descriptions.c (target_desc): Add ctor and dtor.  Do
index 7c8a8f63de2a5575e89099728d1ec9ae7dc414da..9cd1df1cfe204cb7f3cdab1e860d587d70312e02 100644 (file)
--- 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
index 2a4330bd7ac6b6bb4dbc91e743cee5638eec667f..e3a68d36728059f814a7ec95d3782dbc8b42f1b6 100644 (file)
@@ -1,3 +1,8 @@
+2017-07-26  Yao Qi  <yao.qi@linaro.org>
+
+       * gdb.texinfo (Maintenance Commands): Document optional
+       argument of "maint print c-tdesc".
+
 2017-07-18  Yao Qi  <yao.qi@linaro.org>
 
        * gdb.texinfo (Maintenance Commands): Improve the doc to
index 5f55a67b5d7a51f45c6bbadf288d90b1429cdc94..08a7681a4961f7083d7bb4beb4d285982f32768d 100644 (file)
@@ -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
index 75741acbe17b68602cdbff77c97fd7dc29f45dd3..7ddb5781ffe272bccae8cd8ef091b8059c14863f 100644 (file)
@@ -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.
index 9484f01c9a420e3164f5d471f30f0d2ad4cab269..4129486cd1ed3b251706dc9899d567419f62f42f 100644 (file)
@@ -1729,18 +1729,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 == '.')
This page took 0.06753 seconds and 4 git commands to generate.