This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: PATCH: Enable x86 XML target descriptions
> Date: Mon, 22 Feb 2010 11:10:40 -0500
> From: Daniel Jacobowitz <dan@codesourcery.com>
>
> On Mon, Feb 22, 2010 at 07:57:52AM -0800, H.J. Lu wrote:
> > On Mon, Feb 22, 2010 at 7:52 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> > > On Mon, Feb 22, 2010 at 07:34:01AM -0800, H.J. Lu wrote:
> > >> 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?
> > >
> > > Not if, for instance, we did not find the executable.
> >
> > How do you debug if you can't find executable? I am not sure if
> > you can get that far.
>
> That's not the point. You can not rely on the gdbarch here. It
> breaks the entire abstraction to circularly read the architecture
> description from the architecture. Plus it will do the wrong thing if
> the user gives the wrong executable, and this is our chance to get it
> right.
>
> Why can't you figure this out with ptrace? Isn't there a bit in
> flags, or something like that? Or a way to get at the kernel's
> TIF_IA32 flag?
I've looked at the Linux kernel sources for the kernel on my
workstation (2.6.27 in its OpenSUSE incarnation), and the only way to
distinguish between a 32-bit and a 64-bit process seems to be to
attempt to write one of the debug address registers with a value
that's larger than 0xffffffff. If that fails, you have a 32-bit
process, otherwise it's a 64-bit process.