Re: PATCH: Enable x86 XML target descriptions

Daniel Jacobowitz
2010-02-22T14:41:56Z

On Mon, Feb 22, 2010 at 02:42:28PM +0100, Mark Kettenis wrote:
> > +/* Get Linux/x86 target description from running target. */
> > +
> > +static const struct target_desc *
> > +amd64_linux_read_description (struct target_ops *ops)
> > +{
> > + if (gdbarch_ptr_bit (target_gdbarch) == 64)
> > + return tdesc_amd64_linux;
> > + else
> > + return tdesc_i386_linux;
> > +}
> > +
>
> This made me wonder what happens if you attach to a process without
> loading an executable first. Currently this works, since GDB can
> figure out what executable belongs to the the process and load the
> executable automatically. But I fear a chicken & egg problem here:
> the gdbarch is derviced from the tdesc, but in order to determine the
> tdesc you need a gdbarch.

Yes, I'm not comfortable having this function respond based on the
gdbarch. It's supposed to query the target. For instance, if you had
a ptrace request that failed if the target was 32-bit, you could use
that. If that's not possible, it probably shouldn't be implemented.

> I didn't realize these functions would effectively be moved into
> target-descriptions.c. That feels wrong.

For avoidance of doubt, that's true of the flags functions and the
builtin FP type; the vector type goes into the data files. The FP
type there's no real way around. The flags types could (I think
should) be transfered to the data files too - but it would require a
new element in the XML files.

I happen to have that patch sitting around somewhere... let me find
it.

--
Daniel Jacobowitz
CodeSourcery