* Debugging 64-bit programs using 32-bit GDB
@ 2013-07-09 10:02 Nikita Karetnikov
2013-07-24 14:33 ` Pedro Alves
0 siblings, 1 reply; 6+ messages in thread
From: Nikita Karetnikov @ 2013-07-09 10:02 UTC (permalink / raw)
To: gdb
[-- Attachment #1: Type: text/plain, Size: 412 bytes --]
Is it possible to debug a 64-bit executable ('bin/guile' [1]) using
32-bit GDB? (I use GNU/Linux.)
I've tried to configure GDB 7.6 with '--enable-64-bit-bfd' (see [2]),
but it still shows "mips-tdep.c:709: internal-error: bad register
size".
[1] http://www.fdn.fr/~lcourtes/tmp/guile-static-stripped-2.0.9-mips64el-linux-gnuabi64.tar.xz
[2] http://www.linux-mips.org/archives/linux-mips/2010-10/msg00336.html
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Debugging 64-bit programs using 32-bit GDB 2013-07-09 10:02 Debugging 64-bit programs using 32-bit GDB Nikita Karetnikov @ 2013-07-24 14:33 ` Pedro Alves 2013-07-24 16:09 ` Doug Evans 2013-07-24 21:21 ` Maciej W. Rozycki 0 siblings, 2 replies; 6+ messages in thread From: Pedro Alves @ 2013-07-24 14:33 UTC (permalink / raw) To: Nikita Karetnikov; +Cc: gdb On 07/09/2013 11:06 AM, Nikita Karetnikov wrote: > Is it possible to debug a 64-bit executable ('bin/guile' [1]) using > 32-bit GDB? (I use GNU/Linux.) I don't think so. The ptrace registers interfaces allow retrieving the right register sets (at least the modern interfaces), but things like breakpoints, etc. won't work, as the 32-bit GDB won't be able to handle the inferior's 64-bit addresses (due to how ptrace works). Last I checked, Power had extra ptrace interfaces for that. Don't know about MIPS. (you can however connect a 32-bit GDB to a 64-bit GDBserver, and use that to debug a 64-bit program, though that's more trouble than just using a 64-bit GDB.). > > I've tried to configure GDB 7.6 with '--enable-64-bit-bfd' (see [2]), > but it still shows "mips-tdep.c:709: internal-error: bad register > size". The x86_64 port catches the case early and bails out (amd64_linux_read_description): if (sizeof (void *) == 4 && is_64bit && !is_x32) error (_("Can't debug 64-bit process with 32-bit GDB")); It'd be obviously better if MIPS native target did the same, instead of tripping on assertions. > [1] http://www.fdn.fr/~lcourtes/tmp/guile-static-stripped-2.0.9-mips64el-linux-gnuabi64.tar.xz > [2] http://www.linux-mips.org/archives/linux-mips/2010-10/msg00336.html -- Pedro Alves ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Debugging 64-bit programs using 32-bit GDB 2013-07-24 14:33 ` Pedro Alves @ 2013-07-24 16:09 ` Doug Evans 2013-07-24 16:25 ` Pedro Alves 2013-07-24 21:21 ` Maciej W. Rozycki 1 sibling, 1 reply; 6+ messages in thread From: Doug Evans @ 2013-07-24 16:09 UTC (permalink / raw) To: Pedro Alves; +Cc: Nikita Karetnikov, gdb On Wed, Jul 24, 2013 at 7:33 AM, Pedro Alves <palves@redhat.com> wrote: > On 07/09/2013 11:06 AM, Nikita Karetnikov wrote: >> Is it possible to debug a 64-bit executable ('bin/guile' [1]) using >> 32-bit GDB? (I use GNU/Linux.) > > I don't think so. The ptrace registers interfaces allow retrieving > the right register sets (at least the modern interfaces), but > things like breakpoints, etc. won't work, as the 32-bit GDB won't > be able to handle the inferior's 64-bit addresses (due to how ptrace > works). Last I checked, Power had extra ptrace interfaces for that. > Don't know about MIPS. > > (you can however connect a 32-bit GDB to a 64-bit GDBserver, and use > that to debug a 64-bit program, though that's more trouble > than just using a 64-bit GDB.). > >> >> I've tried to configure GDB 7.6 with '--enable-64-bit-bfd' (see [2]), >> but it still shows "mips-tdep.c:709: internal-error: bad register >> size". > > The x86_64 port catches the case early and bails out (amd64_linux_read_description): > > if (sizeof (void *) == 4 && is_64bit && !is_x32) > error (_("Can't debug 64-bit process with 32-bit GDB")); [filed for reference sake] Alas basic 32-bit linux builds of gdb don't compile amd64-linux-nat.c. It would be really nice to print a better error message than the following for 32-bit gdb debugging 64-bit executable: "/tmp/hello.x64": not in executable format: File format not recognized It's a not uncommon failure mode. Hmmm, amd64-linux-nat.c is not compiled even if I do --enable-targets=all --enable-64-bit-bfd. When does the above error get triggered? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Debugging 64-bit programs using 32-bit GDB 2013-07-24 16:09 ` Doug Evans @ 2013-07-24 16:25 ` Pedro Alves 2013-07-24 17:14 ` Pedro Alves 0 siblings, 1 reply; 6+ messages in thread From: Pedro Alves @ 2013-07-24 16:25 UTC (permalink / raw) To: Doug Evans; +Cc: Nikita Karetnikov, gdb On 07/24/2013 05:09 PM, Doug Evans wrote: > On Wed, Jul 24, 2013 at 7:33 AM, Pedro Alves <palves@redhat.com> wrote: >> On 07/09/2013 11:06 AM, Nikita Karetnikov wrote: >>> Is it possible to debug a 64-bit executable ('bin/guile' [1]) using >>> 32-bit GDB? (I use GNU/Linux.) >> >> I don't think so. The ptrace registers interfaces allow retrieving >> the right register sets (at least the modern interfaces), but >> things like breakpoints, etc. won't work, as the 32-bit GDB won't >> be able to handle the inferior's 64-bit addresses (due to how ptrace >> works). Last I checked, Power had extra ptrace interfaces for that. >> Don't know about MIPS. >> >> (you can however connect a 32-bit GDB to a 64-bit GDBserver, and use >> that to debug a 64-bit program, though that's more trouble >> than just using a 64-bit GDB.). >> >>> >>> I've tried to configure GDB 7.6 with '--enable-64-bit-bfd' (see [2]), >>> but it still shows "mips-tdep.c:709: internal-error: bad register >>> size". >> >> The x86_64 port catches the case early and bails out (amd64_linux_read_description): >> >> if (sizeof (void *) == 4 && is_64bit && !is_x32) >> error (_("Can't debug 64-bit process with 32-bit GDB")); > > [filed for reference sake] > > Alas basic 32-bit linux builds of gdb don't compile amd64-linux-nat.c. > It would be really nice to print a better error message than the > following for 32-bit gdb debugging 64-bit executable: > > "/tmp/hello.x64": not in executable format: File format not recognized > > It's a not uncommon failure mode. Agree, but not sure how much clearer can it get. Maybe: "/tmp/hello.x64": not in recognized executable file format. ? I'd just suggest building 32-bit GDB with 64-bit support. Even if it can't debug 64-bit programs natively, it can remote debug them, and debug 64-bit cores, in addition to getting rid of that failure mode. > Hmmm, amd64-linux-nat.c is not compiled even if I do > --enable-targets=all --enable-64-bit-bfd. Oh, you're right, of course. Guess I was thinking of gdbserver, where linux-x86.c is shared between 32-bit and 64-bit, and it has the similar handling: if (sizeof (void *) == 4) { if (is_elf64 > 0) error (_("Can't debug 64-bit process with 32-bit GDBserver")); #ifndef __x86_64__ else if (machine == EM_X86_64) error (_("Can't debug x86-64 process with 32-bit GDBserver")); #endif } Two weeks vacation can swap out a lot of context. :-) > When does the above error get triggered? Looks like it doesn't. -- Pedro Alves ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Debugging 64-bit programs using 32-bit GDB 2013-07-24 16:25 ` Pedro Alves @ 2013-07-24 17:14 ` Pedro Alves 0 siblings, 0 replies; 6+ messages in thread From: Pedro Alves @ 2013-07-24 17:14 UTC (permalink / raw) To: Doug Evans; +Cc: Nikita Karetnikov, gdb On 07/24/2013 05:24 PM, Pedro Alves wrote: >> When does the above error get triggered? > > Looks like it doesn't. I realized I might have replied to the wrong question. I was saying that for 32-bit x86 GDB, that error isn't triggered, because the code isn't reached. That error in amd64-linux-nat.c is triggered when you try to debug a 64-bit process with an x32 (not 32-bit x86) GDB. -- Pedro Alves ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Debugging 64-bit programs using 32-bit GDB 2013-07-24 14:33 ` Pedro Alves 2013-07-24 16:09 ` Doug Evans @ 2013-07-24 21:21 ` Maciej W. Rozycki 1 sibling, 0 replies; 6+ messages in thread From: Maciej W. Rozycki @ 2013-07-24 21:21 UTC (permalink / raw) To: Pedro Alves; +Cc: Nikita Karetnikov, gdb On Wed, 24 Jul 2013, Pedro Alves wrote: > > Is it possible to debug a 64-bit executable ('bin/guile' [1]) using > > 32-bit GDB? (I use GNU/Linux.) > > I don't think so. The ptrace registers interfaces allow retrieving > the right register sets (at least the modern interfaces), but > things like breakpoints, etc. won't work, as the 32-bit GDB won't > be able to handle the inferior's 64-bit addresses (due to how ptrace > works). Last I checked, Power had extra ptrace interfaces for that. > Don't know about MIPS. This is apparently supported -- <asm/ptrace.h> on MIPS/Linux has this: /* Calls to trace a 64bit program from a 32bit program. */ #define PTRACE_PEEKTEXT_3264 0xc0 #define PTRACE_PEEKDATA_3264 0xc1 #define PTRACE_POKETEXT_3264 0xc2 #define PTRACE_POKEDATA_3264 0xc3 #define PTRACE_GET_THREAD_AREA_3264 0xc4 and arch/mips/kernel/ptrace32.c in the kernel tree has corresponding code. So it looks like we could support it. Maciej ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-07-24 21:21 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-07-09 10:02 Debugging 64-bit programs using 32-bit GDB Nikita Karetnikov 2013-07-24 14:33 ` Pedro Alves 2013-07-24 16:09 ` Doug Evans 2013-07-24 16:25 ` Pedro Alves 2013-07-24 17:14 ` Pedro Alves 2013-07-24 21:21 ` Maciej W. Rozycki
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox