This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


I noticed this while tracking down another problem with adding DWARF2
support to Cygwin.  (Jim Blandy knows which one.  Thanks again Jim :^),
and this is not necessarily related to that.)

In gcc/config/i386/i386.c, we have:

/* The "default" register map used in 32bit mode.  */

int const dbx_register_map[FIRST_PSEUDO_REGISTER] =
{
  0, 2, 1, 3, 6, 7, 4, 5,               /* general regs */
  12, 13, 14, 15, 16, 17, 18, 19,       /* fp regs */
  -1, -1, -1, -1, -1,                   /* arg, flags, fpsr, dir, frame */
  21, 22, 23, 24, 25, 26, 27, 28,       /* SSE */
  29, 30, 31, 32, 33, 34, 35, 36,       /* MMX */
  -1, -1, -1, -1, -1, -1, -1, -1,       /* extended integer registers */
  -1, -1, -1, -1, -1, -1, -1, -1,       /* extended SSE registers */
};

and:

/* Define the register numbers to be used in Dwarf debugging information. */

int const svr4_dbx_register_map[FIRST_PSEUDO_REGISTER] =
{
  0, 2, 1, 3, 6, 7, 5, 4,               /* general regs */
  11, 12, 13, 14, 15, 16, 17, 18,       /* fp regs */
  -1, 9, -1, -1, -1,                    /* arg, flags, fpsr, dir, frame */
  21, 22, 23, 24, 25, 26, 27, 28,       /* SSE registers */
  29, 30, 31, 32, 33, 34, 35, 36,       /* MMX registers */
  -1, -1, -1, -1, -1, -1, -1, -1,       /* extended integer registers */
  -1, -1, -1, -1, -1, -1, -1, -1,       /* extended SSE registers */
};

Notice that gcc regno 6 (ebp) and 7 (esp) map to regno 4 and 5
respectively in the "default" (aka dbx, stabs, sdb) table.  But, in
the svr4 (aka dwarf, dwarf2, stabs-in-elf) table, they map to regno 5 and
4 respectively.

I'm not sure if/how this should affect i386_register_names.  I also hope
that targets have not already coded around this bug so that fixing it will
break something else :-).  Please do have a look at these issues before
applying the patch.  I'm afraid they are over my head right now.

Thanks.

2004-03-31  Brian Ford  <ford@vss.fsi.com>

	* i386-tdep.c (i386_stab_reg_to_regnum): Reverse 4 and 5
	(ebp and esp respectively) to match the gdb/DWARF regnums.

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax:   314-551-8444

Attachment: i386-tdep.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]