Re: [PATCH] i386_stab_reg_to_regnum (4 <-> 5, ebp <-> esp)

Mark Kettenis
2004-04-06T23:23:15Z

From: Jim Blandy <jimb@redhat.com>
Date: 05 Apr 2004 17:44:14 -0500

I'm getting a bit lost, so let me try to sum up the discussion, for my
own sake. There are two distinct questions at hand:

- Should GDB's i386_stab_reg_to_regnum be changed?

For the first question: I think your original patch is correct.

Yup. I agree. I wonder whether I introduced the bug or that it has
always been wrong...

The bit-twiddling is correct, but I'd rather see something more
direct, like:

Index: gdb/i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.182
diff -c -c -F'^(' -r1.182 i386-tdep.c
*** gdb/i386-tdep.c 1 Apr 2004 18:14:03 -0000 1.182
--- gdb/i386-tdep.c 5 Apr 2004 22:15:01 -0000
***************
*** 211,218 ****
/* This implements what GCC calls the "default" register map. */
if (reg >= 0 && reg <= 7)
{
! /* General-purpose registers. */
! return reg;
}
else if (reg >= 12 && reg <= 19)
{
--- 211,223 ----
/* This implements what GCC calls the "default" register map. */
if (reg >= 0 && reg <= 7)
{
! /* General-purpose registers. The debug info calls %ebp
! register 4, and %esp register 5. */
! if (reg == 4)
! return 5;
! else if (reg == 5)
! return 4;
! else return reg;
}
else if (reg >= 12 && reg <= 19)
{

Jim, please apply this patch, with the proper ChangeLog of course.

Mark