Re: PATCH: Enable x86 XML target descriptions

H.J. Lu
2010-02-22T15:34:12Z

On Mon, Feb 22, 2010 at 6:41 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> 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 just need to know if the inferior is 32bit or 64bit. Why shouldn't
target_gdbarch be used? At this point, target_gdbarch should have
the correct bfd cpu info. Is that correct?

--
H.J.