This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC 2/7] Add unit test to builtin tdesc generated by xml


Hi Yao,

On Tue, 16 May 2017 16:46:11 +0100
Yao Qi <qiyaoltc@gmail.com> wrote:

> Philipp Rudo <prudo@linux.vnet.ibm.com> writes:
> 
> Hi Philipp,
> Thanks for your comments.
> 
> > The only thing you could have done to make it better is to get rid of the
> > conversion to C altogether and create the target description directly by
> > parsing the XML file. I don't see a benefit in the conversion and removing
> > it would simplify the code even more.  But that is a long term goal and
> > your patch set definitely helps towards that goal.
> 
> As I described in the commit log, "the reason that we transform xml files
> to c files is that GDB is still able to have some target description
> without xml parsing support." so that XML parsing is not a hard
> requirement for GDB.  Nowadays, XML parsing is only used for remote
> debugging.  In native debugging, GDB just uses these pre-generated
> builtin target descriptions, without parsing any XML.

Ok, I see my mistake now.  I thought XML parsing would always be present.
Then the target descriptions could be handled similar to syscalls.  But
that was clearly focused too much on GDB on Linux.  For other systems and
GDBserver this needn't necessarily work...

Sorry for the mistake.
 
> Suppose XML parsing is always there, at least on Linux host, GDB can
> create a big buffer contains various target features in the runtime.  We
> can do this on top of patch 6/7, like this, (take i386-linux as an
> example),
> 
> /* Return a string having XML contents reflecting the right target
>    description according to XCR0.  */
> 
> std::string
> i386_linux_read_description (uint64_t xcr0)
> {
>    std::string buffer;
> 
>    buffer.append ("<?xml version="1.0"?>");
>    buffer.append ("<!DOCTYPE target SYSTEM "gdb-target.dtd">");
>    buffer.append ("<target>");
>    buffer.append ("  <architecture>i386</architecture>");
>    buffer.append ("  <osabi>GNU/Linux</osabi>");
> 
>    if (xcr0 & X86_XSTATE_X87)
>      {
>         /* Open 32bit-core.xml and copy its content here.  */
>      }
> 
>    if (xcr0 & X86_XSTATE_SSE)
>      {
>        /* Open 32bit-sse.xml and copy its content here.  */
>      }
> 
>     ....
> 
>    buffer.append ("</target>");
> 
>    return buffer;
> }
> 
> Even further, this code can be shared between GDB and GDBserver, so that
> GDBserver can compose the XML contents and send it to GDB.  Note that
> GDBserver doesn't need to parse the XML.

That would be neat!

Thanks
Philipp


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]