This is an archive of the discontinued LLVM Phabricator instance.

Handle nested register definition xml files from the remote serial protocol stub
ClosedPublic

Authored by jasonmolenda on Jun 25 2019, 7:21 PM.

Details

Summary

I was looking at adding support for lldb connecting to qemu's x86_64 RSP stub. The target definition file we get back from it has a few wrinkles that complicate this, I'm thinking of handling it something like this.

First, it uses nested includes. We ask for target.xml and we get back

<target><architecture>i386:x86-64</architecture><xi:include href="i386-64bit.xml"/></target>

then we need to ask for i386-64bit.xml which gives us

<feature name="org.gnu.gdb.i386.64bit">

<xi:include href="i386-64bit-core.xml"/>
<xi:include href="i386-64bit-sse.xml"/>

</feature>

and requesting those two are going to get us the GPRs and FPRs/vector regs.

The first problem is that ProcessGDBRemote::GetGDBServerRegisterInfo does have support for one level of includes, but it assumes that the target xml file will consist of only registers.

I created a new ProcessGDBRemote::GetGDBServerRegisterInfo method which calls a method that we can call recursively to parse the XML target definitions. The one problem with THAT is that we fetch the xml file, parse it, then we find the root node -- normally <target> -- and iterate over the child elements that we normally deal with (architecture, osabi, xi:include/include, feature, groups) and for any <feature> nodes, pass the children to ParseRegisters() which looks for <reg> elements.

Now this method ("GetGDBServerRegisterInfoXMLAndProcess", whatever) needs to be prepared to get either the top-level <target> node OR a <feature> node in a child include. Which is still a bit fragile because, for instance, the <architecture> element is in the top level here but it's possible for the top level xml to just include another xml where we see an <architecture> tag, or whatever? e.g.

<target>

<xi:include href="actual-content.xml/">

</target>

{actual-content.xml}

<architecture> i386:x86-64</architecture>
<feature name="org.gnu.gdb.i386.64bit">

<xi:include href="i386-64bit-core.xml"/>
<xi:include href="i386-64bit-sse.xml"/>

</feature>

Maybe that's possible?

I have a test file here showing exactly what definitions were being sent. Also of note is that most of the registers don't get a register grouping by our logic. The floating point control registers get a group="float", and the mxcsr gets a group="vector", but none of the others do. It's also interesting to see how the flag bits are defined plus the different vector presentations for the xmm registers. We're ignoring all of that for now, obviously.

I'll look this patch over more tomorrow, but wanted to give a heads up about what I'm looking at on this one.

Diff Detail

Repository
rL LLVM

Event Timeline

jasonmolenda created this revision.Jun 25 2019, 7:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 25 2019, 7:21 PM
clayborg accepted this revision.Jun 26 2019, 7:07 AM

few nits, but looks good.

source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
4584–4585 ↗(On Diff #206575)
} else {
4655–4657 ↗(On Diff #206575)

remove {}

This revision is now accepted and ready to land.Jun 26 2019, 7:07 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2019, 3:01 PM