Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Debugging 32bit apps with 64bit target gdb
@ 2011-05-19 20:18 Paul Smith
  2011-05-22 22:25 ` Paul Smith
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Smith @ 2011-05-19 20:18 UTC (permalink / raw)
  To: gdb

Hi all;

Maybe this is a naive question.  I have an environment (x86) with both
32bit and 64bit applications running in it.  I would like to use the
same GDB binary to debug both types of applications.  Ideally, though,
GDB would be a 32bit application because sometimes I run on 32bit
systems (obviously the 64bit applications do not run and cannot be
debugged on those systems, but the 32bit ones can).

I will also be doing remote debugging (with gdbserver) from a 32bit host
to a 64bit target (at least I would like to be able to do that).

I configured GDB (7.2) with --host=i686-generic-linux-gnu and
--target=x86_64-generic-linux-gnu (and --enable-targets=all but I don't
know if GDB configure groks this flag).

This compiled just fine, but when I have a 32bit core file and I try to
access it with GDB, I get an error:

warning: Could not load shared library symbols for 8 libraries, e.g. /lib/tls/librt.so.1.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
Core was generated by `app32bit'.
Program terminated with signal 11, Segmentation fault.
#0  0x00b187a2 in ?? ()
#0  0x00b187a2 in ?? ()
#1  0x00d9c6f4 in ?? ()
#2  0x00000000 in ?? ()

and I can't get a backtrace or anything.  "info sharedlibrary" shows:

From        To          Syms Read   Shared Object Library
                        No          /lib/tls/librt.so.1
                        No          /usr/lib/libz.so.1
                        No          /lib/libdl.so.2
                        No          /lib/tls/libpthread.so.0
                        No          /lib/tls/libm.so.6
                        No          /lib/tls/libc.so.6
                        No          /lib/ld-linux.so.2
                        No          /lib/libgcc_s.so.1

which are all perfectly reasonable 32bit shared libs.

On the other hand, if I build a 32bit GDB (same version of code but
compiled on a 32bit Linux without the --target=x6_64-generic-linux-gnu
flag) then I get a perfectly usable backtrace for this identical
coredump on the same system.

Is what I want to do simply not possible?  Or am I missing some trick?
It seems to me that on the 64bit multiarch Linux systems I've used, the
GDB versions that come with them can debug 32bit applications.  Or am I
just imagining that this is possible?

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@gnu.org>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


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

* Re: Debugging 32bit apps with 64bit target gdb
  2011-05-19 20:18 Debugging 32bit apps with 64bit target gdb Paul Smith
@ 2011-05-22 22:25 ` Paul Smith
  2011-05-22 22:40   ` Mark Kettenis
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Smith @ 2011-05-22 22:25 UTC (permalink / raw)
  To: gdb

Anyone have any help for me?

A short summary, I'm trying to see if I can build one GDB executable
with all these properties:

      * Is a 32bit application so it can run on both 32bit and 64bit
        systems
      * Can debug 32bit applications
      * Can debug 64bit applications (when run on a 64bit system
        obviously)
      * If I can get it to debug a 64bit core file when running on a
        32bit system (with --sysroot pointing to a 64bit sysroot of
        course) that would be awesome.

I'm only concerned with x86 architectures (for now?)

Is such a thing possible?  Or should I just build two different GDB
binaries, one for 32bit and one for 64bit, and be satisfied?


On Thu, 2011-05-19 at 16:17 -0400, Paul Smith wrote:
> Hi all;
> 
> Maybe this is a naive question.  I have an environment (x86) with both
> 32bit and 64bit applications running in it.  I would like to use the
> same GDB binary to debug both types of applications.  Ideally, though,
> GDB would be a 32bit application because sometimes I run on 32bit
> systems (obviously the 64bit applications do not run and cannot be
> debugged on those systems, but the 32bit ones can).
> 
> I will also be doing remote debugging (with gdbserver) from a 32bit host
> to a 64bit target (at least I would like to be able to do that).
> 
> I configured GDB (7.2) with --host=i686-generic-linux-gnu and
> --target=x86_64-generic-linux-gnu (and --enable-targets=all but I don't
> know if GDB configure groks this flag).
> 
> This compiled just fine, but when I have a 32bit core file and I try to
> access it with GDB, I get an error:
> 
> warning: Could not load shared library symbols for 8 libraries, e.g. /lib/tls/librt.so.1.
> Use the "info sharedlibrary" command to see the complete listing.
> Do you need "set solib-search-path" or "set sysroot"?
> warning: Unable to find dynamic linker breakpoint function.
> GDB will be unable to debug shared library initializers
> and track explicitly loaded dynamic code.
> Core was generated by `app32bit'.
> Program terminated with signal 11, Segmentation fault.
> #0  0x00b187a2 in ?? ()
> #0  0x00b187a2 in ?? ()
> #1  0x00d9c6f4 in ?? ()
> #2  0x00000000 in ?? ()
> 
> and I can't get a backtrace or anything.  "info sharedlibrary" shows:
> 
> From        To          Syms Read   Shared Object Library
>                         No          /lib/tls/librt.so.1
>                         No          /usr/lib/libz.so.1
>                         No          /lib/libdl.so.2
>                         No          /lib/tls/libpthread.so.0
>                         No          /lib/tls/libm.so.6
>                         No          /lib/tls/libc.so.6
>                         No          /lib/ld-linux.so.2
>                         No          /lib/libgcc_s.so.1
> 
> which are all perfectly reasonable 32bit shared libs.
> 
> On the other hand, if I build a 32bit GDB (same version of code but
> compiled on a 32bit Linux without the --target=x6_64-generic-linux-gnu
> flag) then I get a perfectly usable backtrace for this identical
> coredump on the same system.
> 
> Is what I want to do simply not possible?  Or am I missing some trick?
> It seems to me that on the 64bit multiarch Linux systems I've used, the
> GDB versions that come with them can debug 32bit applications.  Or am I
> just imagining that this is possible?
> 


-- 
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@gnu.org>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


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

* Re: Debugging 32bit apps with 64bit target gdb
  2011-05-22 22:25 ` Paul Smith
@ 2011-05-22 22:40   ` Mark Kettenis
  2011-05-22 22:55     ` Paul Smith
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2011-05-22 22:40 UTC (permalink / raw)
  To: psmith; +Cc: gdb

> From: Paul Smith <psmith@gnu.org>
> Date: Sun, 22 May 2011 18:25:10 -0400
> 
> Anyone have any help for me?
> 
> A short summary, I'm trying to see if I can build one GDB executable
> with all these properties:
> 
>       * Is a 32bit application so it can run on both 32bit and 64bit
>         systems
>       * Can debug 32bit applications
>       * Can debug 64bit applications (when run on a 64bit system
>         obviously)
>       * If I can get it to debug a 64bit core file when running on a
>         32bit system (with --sysroot pointing to a 64bit sysroot of
>         course) that would be awesome.
> 
> I'm only concerned with x86 architectures (for now?)
> 
> Is such a thing possible?

I believe this is possible on Solaris.  It is possible on powerpc
Linux.  It is *not* possible on Linux.  Not GDB's fault.  The x86
Linux kernel simply doesn't provide the necessary support.


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

* Re: Debugging 32bit apps with 64bit target gdb
  2011-05-22 22:40   ` Mark Kettenis
@ 2011-05-22 22:55     ` Paul Smith
  2011-05-22 23:10       ` Mark Kettenis
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Smith @ 2011-05-22 22:55 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb

On Mon, 2011-05-23 at 00:40 +0200, Mark Kettenis wrote:
> > From: Paul Smith <psmith@gnu.org>
> > Date: Sun, 22 May 2011 18:25:10 -0400
> > 
> > A short summary, I'm trying to see if I can build one GDB executable
> > with all these properties:
> > 
> >       * Is a 32bit application so it can run on both 32bit and 64bit
> >         systems
> >       * Can debug 32bit applications
> >       * Can debug 64bit applications (when run on a 64bit system
> >         obviously)
> >       * If I can get it to debug a 64bit core file when running on a
> >         32bit system (with --sysroot pointing to a 64bit sysroot of
> >         course) that would be awesome.
> > 
> > I'm only concerned with x86 architectures (for now?)
> > 
> > Is such a thing possible?
> 
> I believe this is possible on Solaris.  It is possible on powerpc
> Linux.  It is *not* possible on Linux.  Not GDB's fault.  The x86
> Linux kernel simply doesn't provide the necessary support.

Yes, I'm using Linux.  Sorry to forget that detail.

Interesting.  I could have sworn I've seen this work before but maybe
there was simply magic going on behind the scenes (gdb was a shell
script that invoked a correct version based on the target architecture,
or something).

So, I need to build a 32bit GDB to debug 32bit apps and a 64bit GDB to
debug 64bit apps?

Thanks!

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@gnu.org>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


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

* Re: Debugging 32bit apps with 64bit target gdb
  2011-05-22 22:55     ` Paul Smith
@ 2011-05-22 23:10       ` Mark Kettenis
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Kettenis @ 2011-05-22 23:10 UTC (permalink / raw)
  To: psmith; +Cc: gdb

> From: Paul Smith <psmith@gnu.org>
> Date: Sun, 22 May 2011 18:55:01 -0400
> 
> On Mon, 2011-05-23 at 00:40 +0200, Mark Kettenis wrote:
> > > From: Paul Smith <psmith@gnu.org>
> > > Date: Sun, 22 May 2011 18:25:10 -0400
> > > 
> > > A short summary, I'm trying to see if I can build one GDB executable
> > > with all these properties:
> > > 
> > >       * Is a 32bit application so it can run on both 32bit and 64bit
> > >         systems
> > >       * Can debug 32bit applications
> > >       * Can debug 64bit applications (when run on a 64bit system
> > >         obviously)
> > >       * If I can get it to debug a 64bit core file when running on a
> > >         32bit system (with --sysroot pointing to a 64bit sysroot of
> > >         course) that would be awesome.
> > > 
> > > I'm only concerned with x86 architectures (for now?)
> > > 
> > > Is such a thing possible?
> > 
> > I believe this is possible on Solaris.  It is possible on powerpc
> > Linux.  It is *not* possible on Linux.  Not GDB's fault.  The x86
> > Linux kernel simply doesn't provide the necessary support.
> 
> Yes, I'm using Linux.  Sorry to forget that detail.
> 
> Interesting.  I could have sworn I've seen this work before but maybe
> there was simply magic going on behind the scenes (gdb was a shell
> script that invoked a correct version based on the target architecture,
> or something).
> 
> So, I need to build a 32bit GDB to debug 32bit apps and a 64bit GDB to
> debug 64bit apps?

A 64-bit x86 Linux GDB will debug both 32-bit and 64-bit code.  A
32-bit x86 Linux GDB will only debug 32-bit code.

Cheers,

Mark


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

end of thread, other threads:[~2011-05-22 23:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-19 20:18 Debugging 32bit apps with 64bit target gdb Paul Smith
2011-05-22 22:25 ` Paul Smith
2011-05-22 22:40   ` Mark Kettenis
2011-05-22 22:55     ` Paul Smith
2011-05-22 23:10       ` Mark Kettenis

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