Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Random gdbserver question (x86)
@ 2010-03-30 23:40 Michael Snyder
  2010-03-31  1:19 ` Pedro Alves
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Snyder @ 2010-03-30 23:40 UTC (permalink / raw)
  To: gdb

Question -- is gdbserver "multi-arch" to the extent that a 32-bit
gdbserver (built with target = i386) can debug a 64-bit app?

I ask because linux-x86-low.c is full of ifdefs on the architecture.
It looks like most of the 64-bit code won't be compiled if the
build machine is 32-bit.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Random gdbserver question (x86)
  2010-03-30 23:40 Random gdbserver question (x86) Michael Snyder
@ 2010-03-31  1:19 ` Pedro Alves
  2010-03-31 17:27   ` Michael Snyder
  2010-03-31 17:35   ` Michael Snyder
  0 siblings, 2 replies; 9+ messages in thread
From: Pedro Alves @ 2010-03-31  1:19 UTC (permalink / raw)
  To: gdb; +Cc: Michael Snyder

On Wednesday 31 March 2010 00:40:34, Michael Snyder wrote:
> Question -- is gdbserver "multi-arch" to the extent that a 32-bit
> gdbserver (built with target = i386) can debug a 64-bit app?

No, only the other way around.  It's "multi-arch" to the extent
that a linux 64-bit gdbserver (built with target = x86-64) can
debug a 32-bit app.  It used to only be, only 64x64 or 32x32 was
possible; with multi-arch, 64x32 was made possible.

> I ask because linux-x86-low.c is full of ifdefs on the architecture.
> It looks like most of the 64-bit code won't be compiled if the
> build machine is 32-bit.

Correct.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Random gdbserver question (x86)
  2010-03-31  1:19 ` Pedro Alves
@ 2010-03-31 17:27   ` Michael Snyder
  2010-03-31 17:35   ` Michael Snyder
  1 sibling, 0 replies; 9+ messages in thread
From: Michael Snyder @ 2010-03-31 17:27 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb

Pedro Alves wrote:
> On Wednesday 31 March 2010 00:40:34, Michael Snyder wrote:
>> Question -- is gdbserver "multi-arch" to the extent that a 32-bit
>> gdbserver (built with target = i386) can debug a 64-bit app?
> 
> No, only the other way around.  It's "multi-arch" to the extent
> that a linux 64-bit gdbserver (built with target = x86-64) can
> debug a 32-bit app.  It used to only be, only 64x64 or 32x32 was
> possible; with multi-arch, 64x32 was made possible.
> 
>> I ask because linux-x86-low.c is full of ifdefs on the architecture.
>> It looks like most of the 64-bit code won't be compiled if the
>> build machine is 32-bit.
> 
> Correct.

Thanks for confirming.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Random gdbserver question (x86)
  2010-03-31  1:19 ` Pedro Alves
  2010-03-31 17:27   ` Michael Snyder
@ 2010-03-31 17:35   ` Michael Snyder
  2010-03-31 17:43     ` Pedro Alves
                       ` (2 more replies)
  1 sibling, 3 replies; 9+ messages in thread
From: Michael Snyder @ 2010-03-31 17:35 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb

Pedro Alves wrote:
> On Wednesday 31 March 2010 00:40:34, Michael Snyder wrote:
>> Question -- is gdbserver "multi-arch" to the extent that a 32-bit
>> gdbserver (built with target = i386) can debug a 64-bit app?
> 
> No, only the other way around.  It's "multi-arch" to the extent
> that a linux 64-bit gdbserver (built with target = x86-64) can
> debug a 32-bit app.  It used to only be, only 64x64 or 32x32 was
> possible; with multi-arch, 64x32 was made possible.
> 
>> I ask because linux-x86-low.c is full of ifdefs on the architecture.
>> It looks like most of the 64-bit code won't be compiled if the
>> build machine is 32-bit.
> 
> Correct.

And is that more-or-less true of gdb as well?  I.e., if host/target
is x86_64-linux, then gdb can debug both 32 and 64 bit apps, but if
host/target is i386-linux, then gdb can only debug 32 bit apps?

Actually, I phrase it as a question even though I am pretty sure it
is true.  My real question is "Why?".  It seems to me that if we just
included amd64-linux-nat.o and amd64-*-tdep.o in the build, then
32-bit gdb should be able to debug 64-bit native apps.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Random gdbserver question (x86)
  2010-03-31 17:35   ` Michael Snyder
@ 2010-03-31 17:43     ` Pedro Alves
  2010-03-31 17:46       ` Michael Snyder
  2010-03-31 17:48     ` Daniel Jacobowitz
  2010-03-31 17:57     ` Mark Kettenis
  2 siblings, 1 reply; 9+ messages in thread
From: Pedro Alves @ 2010-03-31 17:43 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb

On Wednesday 31 March 2010 18:35:29, Michael Snyder wrote:
> And is that more-or-less true of gdb as well?  I.e., if host/target
> is x86_64-linux, then gdb can debug both 32 and 64 bit apps, but if
> host/target is i386-linux, then gdb can only debug 32 bit apps?

Native gdb yes.  A 32-bit GDB should still be able to debug a
remote/gdbserver 64-bit inferior.

> 
> Actually, I phrase it as a question even though I am pretty sure it
> is true.  My real question is "Why?".  It seems to me that if we just
> included amd64-linux-nat.o and amd64-*-tdep.o in the build, then
> 32-bit gdb should be able to debug 64-bit native apps.

Wouldn't work.  The limitation is on ptrace.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Random gdbserver question (x86)
  2010-03-31 17:43     ` Pedro Alves
@ 2010-03-31 17:46       ` Michael Snyder
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Snyder @ 2010-03-31 17:46 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb

Pedro Alves wrote:
> On Wednesday 31 March 2010 18:35:29, Michael Snyder wrote:
>> And is that more-or-less true of gdb as well?  I.e., if host/target
>> is x86_64-linux, then gdb can debug both 32 and 64 bit apps, but if
>> host/target is i386-linux, then gdb can only debug 32 bit apps?
> 
> Native gdb yes.  A 32-bit GDB should still be able to debug a
> remote/gdbserver 64-bit inferior.
> 
>> Actually, I phrase it as a question even though I am pretty sure it
>> is true.  My real question is "Why?".  It seems to me that if we just
>> included amd64-linux-nat.o and amd64-*-tdep.o in the build, then
>> 32-bit gdb should be able to debug 64-bit native apps.
> 
> Wouldn't work.  The limitation is on ptrace.

Can it be explained relatively simply?   ;-)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Random gdbserver question (x86)
  2010-03-31 17:35   ` Michael Snyder
  2010-03-31 17:43     ` Pedro Alves
@ 2010-03-31 17:48     ` Daniel Jacobowitz
  2010-03-31 17:56       ` Michael Snyder
  2010-03-31 17:57     ` Mark Kettenis
  2 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2010-03-31 17:48 UTC (permalink / raw)
  To: Michael Snyder; +Cc: Pedro Alves, gdb

On Wed, Mar 31, 2010 at 10:35:29AM -0700, Michael Snyder wrote:
> Actually, I phrase it as a question even though I am pretty sure it
> is true.  My real question is "Why?".  It seems to me that if we just
> included amd64-linux-nat.o and amd64-*-tdep.o in the build, then
> 32-bit gdb should be able to debug 64-bit native apps.

I don't think the necessary kernel interfaces exist.  Or at least, we
aren't using them.  Compare the offsets in the two nat files.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Random gdbserver question (x86)
  2010-03-31 17:48     ` Daniel Jacobowitz
@ 2010-03-31 17:56       ` Michael Snyder
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Snyder @ 2010-03-31 17:56 UTC (permalink / raw)
  To: Michael Snyder, Pedro Alves, gdb

Daniel Jacobowitz wrote:
> On Wed, Mar 31, 2010 at 10:35:29AM -0700, Michael Snyder wrote:
>> Actually, I phrase it as a question even though I am pretty sure it
>> is true.  My real question is "Why?".  It seems to me that if we just
>> included amd64-linux-nat.o and amd64-*-tdep.o in the build, then
>> 32-bit gdb should be able to debug 64-bit native apps.
> 
> I don't think the necessary kernel interfaces exist.  Or at least, we
> aren't using them.  Compare the offsets in the two nat files.
> 

Hmmm, but both nat files get linked in when we do a 64 bit build.

Suppose I wanted to build gdb on a 32 bit host, but use it on a
64 bit host.  If I specify "target=x86_64-linux", then my gdb will
not work natively on *either* host, because it will be built as a
cross-only debugger.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Random gdbserver question (x86)
  2010-03-31 17:35   ` Michael Snyder
  2010-03-31 17:43     ` Pedro Alves
  2010-03-31 17:48     ` Daniel Jacobowitz
@ 2010-03-31 17:57     ` Mark Kettenis
  2 siblings, 0 replies; 9+ messages in thread
From: Mark Kettenis @ 2010-03-31 17:57 UTC (permalink / raw)
  To: msnyder; +Cc: pedro, gdb

> Date: Wed, 31 Mar 2010 10:35:29 -0700
> From: Michael Snyder <msnyder@vmware.com>
> 
> Pedro Alves wrote:
> > On Wednesday 31 March 2010 00:40:34, Michael Snyder wrote:
> >> Question -- is gdbserver "multi-arch" to the extent that a 32-bit
> >> gdbserver (built with target = i386) can debug a 64-bit app?
> > 
> > No, only the other way around.  It's "multi-arch" to the extent
> > that a linux 64-bit gdbserver (built with target = x86-64) can
> > debug a 32-bit app.  It used to only be, only 64x64 or 32x32 was
> > possible; with multi-arch, 64x32 was made possible.
> > 
> >> I ask because linux-x86-low.c is full of ifdefs on the architecture.
> >> It looks like most of the 64-bit code won't be compiled if the
> >> build machine is 32-bit.
> > 
> > Correct.
> 
> And is that more-or-less true of gdb as well?  I.e., if host/target
> is x86_64-linux, then gdb can debug both 32 and 64 bit apps, but if
> host/target is i386-linux, then gdb can only debug 32 bit apps?
> 
> Actually, I phrase it as a question even though I am pretty sure it
> is true.  My real question is "Why?".  It seems to me that if we just
> included amd64-linux-nat.o and amd64-*-tdep.o in the build, then
> 32-bit gdb should be able to debug 64-bit native apps.

The problem here is that ptrace(2) from a 32-bit executable only gives
you access to the 32-bit registers.  Debugging 64-bit executables
remotely should work fine though, provided you --enable-64-bit-bfd.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-03-31 17:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-30 23:40 Random gdbserver question (x86) Michael Snyder
2010-03-31  1:19 ` Pedro Alves
2010-03-31 17:27   ` Michael Snyder
2010-03-31 17:35   ` Michael Snyder
2010-03-31 17:43     ` Pedro Alves
2010-03-31 17:46       ` Michael Snyder
2010-03-31 17:48     ` Daniel Jacobowitz
2010-03-31 17:56       ` Michael Snyder
2010-03-31 17:57     ` Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox