binutils-gdb/gdb/doc
Andrew Burgess caa7fd04f6 gdb: New maintenance command to print XML target description
This commit adds a new maintenance command that dumps the current
target description as an XML document.  This is a maintenance command
as I currently only see this being useful for GDB developers, or for
people debugging a new remote target.

By default the command will print whatever the current target
description is, whether this was delivered by the remote, loaded by
the user from a file, or if it is a built in target within GDB.

The command can also take an optional filename argument.  In this case
GDB loads a target description from the file, and then reprints it.
This could be useful for testing GDB's parsing of target descriptions,
or to check that GDB can successfully parse a particular XML
description.

It is worth noting that the XML description printed will not be an
exact copy of the document fed into GDB.  For example this minimal
input file:

  <target>
    <feature name="abc">
      <reg name="r1" bitsize="32"/>
    </feature>
  </target>

Will produce this output:

  (gdb) maint print xml-tdesc path/to/file.xml
  <?xml version="1.0"?>
  <!DOCTYPE target SYSTEM "gdb-target.dtd">
  <target>
    <feature name="abc">
      <reg name="r1" bitsize="32" type="int" regnum="0"/>
    </feature>
  </target>

Notice that GDB filled in both the 'type' and 'regnum' fields of the
<reg>.  I think this is actually a positive as it means we get to
really understand how GDB processed the document, if GDB made some
assumptions that differ to those the user expected then hopefully this
will bring those issues to the users attention.

To implement this I have tweaked the output produced by the
print_xml_feature which is defined within the gdbsupport/ directory.
The changes I have made to this class are:

  1. The <architecture>...</architecture> tags are now not produced if
  the architecture name is NULL.

  2. The <osabi>...</osabi> tags get a newline at the end.

  3. And, the whole XML document is indented using white space in a
  nested fashion (as in the example output above).

I think that these changes should be fine, the print_xml_feature class
is used:

  1. In gdbserver to generate an XML document to send as the target
  description to GDB.

  2. In GDB as part of a self-check function, a target_desc is
  converted to XML then parsed back into a target_desc.  We then check
  the before and after target_desc objects are the same.

  3. In the new 'maint print xml-tdesc' command.

In all of these use cases adding the extra white space should be fine.

gdbsupport/ChangeLog:

	* tdesc.cc (print_xml_feature::visit_pre): Use add_line to add
	output content, and call indent as needed in all overloaded
	variants.
	(print_xml_feature::visit_post): Likewise.
	(print_xml_feature::visit): Likewise.
	(print_xml_feature::add_line): Two new overloaded functions.
	* tdesc.h (print_xml_feature::indent): New member function.
	(print_xml_feature::add_line): Two new overloaded member
	functions.
	(print_xml_feature::m_depth): New member variable.

gdb/ChangeLog:

	* target-descriptions.c (tdesc_architecture_name): Protect against
	NULL pointer dereference.
	(maint_print_xml_tdesc_cmd): New function.
	(_initialize_target_descriptions): Register new 'maint print
	xml-tdesc' command and give it the filename completer.
	* NEWS: Mention new 'maint print xml-tdesc' command.

gdb/testsuite/ChangeLog:

	* gdb.xml/tdesc-reload.c: New file.
	* gdb.xml/tdesc-reload.exp: New file.
	* gdb.xml/maint-xml-dump-01.xml: New file.
	* gdb.xml/maint-xml-dump-02.xml: New file.
	* gdb.xml/maint-xml-dump.exp: New file.

gdb/doc/ChangeLog:

	* gdb.texinfo (Maintenance Commands): Document new 'maint print
	xml-desc' command.
2020-06-23 22:17:20 +01:00
..
.gitignore Update and add .gitignore's 2016-09-21 13:12:21 -04:00
ChangeLog gdb: New maintenance command to print XML target description 2020-06-23 22:17:20 +01:00
Doxyfile-base.in Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
Doxyfile-gdb-api.in Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
Doxyfile-gdb-xref.in Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
Doxyfile-gdbserver.in Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
Makefile.in Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
a4rc.sed
agentexpr.texi Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
all-cfg.texi Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
annotate.texinfo Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
doxy-index.in Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
fdl.texi
filter-for-doxygen
filter-params.pl
gdb.texinfo gdb: New maintenance command to print XML target description 2020-06-23 22:17:20 +01:00
gpl.texi
guile.texi Multi-target: NEWS and user manual 2020-01-10 20:06:15 +00:00
lpsrc.sed
psrc.sed
python.texi Allow Python commands to be in class_tui 2020-04-28 08:54:17 -06:00
refcard.tex Update copyright year in gdbarch.sh doc/gdb.texinfo and doc/refcard.tex 2020-01-01 10:37:10 +04:00
stabs.texinfo Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
stack_frame.eps
stack_frame.pdf
stack_frame.png
stack_frame.svg
stack_frame.txt