Re: PING: PATCH: PR backtrace/14646: [x32] backtrace doesn't work

Mark Kettenis
2012-10-08T20:22:19Z

> Date: Mon, 8 Oct 2012 13:04:03 -0700
> From: "H.J. Lu" <hjl.tools@gmail.com>
>
> On Mon, Oct 8, 2012 at 12:48 PM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> >> Date: Thu, 4 Oct 2012 06:57:22 -0700
> >> From: "H.J. Lu" <hjl.tools@gmail.com>
> >>
> >> On Wed, Oct 3, 2012 at 11:57 PM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> >> >
> >> > Perhaps the user-regs.c mechanism can be used to establish eip -> pc
> >> > and esp -> sp mappings?
> >>
> >> It doesn't help as long as gdbarch_pc_regnum/gdbarch_sp_regnum
> >> are used for both frame pc/sp value and unwind pc/sp value. For x32,
> >> we want eip/esp for frame pc/sp value and rip/rsp for unwind pc/sp
> >> value.
> >
> > That probably means we need to set gdbarch_pc_regnum (and
> > gdbarch_sp_regnum) to -1 for x32.
>
> We can't set gdbarch_pc_regnum/gdbarch_sp_regnum to -1:
>
>
> GNU gdb (GDB) 7.5.50.20121008-cvs
> Copyright (C) 2012 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law. Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-unknown-linux-gnu".
> For bug reporting instructions, please see:
> <http://www.gnu.org/software/gdb/bugs/>...
> Reading symbols from
> /export/build/gnu/glibc-x32/build-x86_64-linux/elf/sln...done.
> (gdb) b main
> Breakpoint 1 at 0x400c20: file sln.c, line 50.
> (gdb) r
> Starting program: /export/build/gnu/glibc-x32/build-x86_64-linux/elf/sln
> /export/gnu/import/git/gdb/gdb/regcache.c:1062: internal-error:
> regcache_read_pc: Unable to find PC
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> Quit this debugging session? (y or n)

Well, obviously you'll need to implement gdbarch_read_pc() for this to
work. And probably a few more gdbarch methods.