* [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
@ 2001-11-12 13:12 Elena Zannoni
2001-11-19 15:56 ` Kevin Buettner
2001-11-26 10:13 ` Elena Zannoni
0 siblings, 2 replies; 16+ messages in thread
From: Elena Zannoni @ 2001-11-12 13:12 UTC (permalink / raw)
To: gdb-patches
Use a dynamic mapping instead.
Tested on a G4 running YDL.
Elena
2001-11-26 Elena Zannoni <ezannoni@redhat.com>
* Makefile.in (ppc-linux-nat.o): Add dependency on ppc-tdep.h.
* ppc-tdep.h (PPC_GPLAST_REGNUM): Define.
* ppc-linux-nat.c: Include ppc-tdep.h.
(ppc_register_u_addr): Don't use the static array regmap[],
dynamically define the mapping instead.
(supply_gregset): Ditto.
(fill_gregset): Ditto.
(COPY_REG): Delete macro defintion.
(regmap): Delete array.
Index: Makefile.in
===================================================================
RCS file: /cvs/uberbaum/gdb/Makefile.in,v
retrieving revision 1.130
diff -u -p -r1.130 Makefile.in
--- Makefile.in 2001/11/18 05:09:26 1.130
+++ Makefile.in 2001/11/26 18:11:44
@@ -1818,7 +1818,7 @@ ppc-bdm.o: ppc-bdm.c $(defs_h) $(gdbcore
$(objfiles_h) $(gdb_stabs_h) $(serial_h) ocd.h $(regcache_h)
ppc-linux-nat.o: ppc-linux-nat.c $(defs_h) $(gdbcore_h) $(frame_h) \
- $(inferior_h) $(target_h) $(regcache_h)
+ $(inferior_h) $(target_h) $(regcache_h) ppc-tdep.h
ppc-linux-tdep.o: ppc-linux-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \
$(target_h) ppc-tdep.h $(regcache_h) $(value_h)
Index: ppc-tdep.h
===================================================================
RCS file: /cvs/uberbaum/gdb/ppc-tdep.h,v
retrieving revision 1.2
diff -u -p -r1.2 ppc-tdep.h
--- ppc-tdep.h 2001/11/01 01:07:35 1.2
+++ ppc-tdep.h 2001/11/26 18:07:25
@@ -46,6 +46,7 @@ CORE_ADDR rs6000_frame_chain (struct fra
/* Some important register numbers. */
#define PPC_GP0_REGNUM 0 /* GPR register 0 */
+#define PPC_GPLAST_REGNUM 31 /* GPR register 31 */
#define PPC_TOC_REGNUM 2 /* TOC register */
#define PPC_PS_REGNUM 65 /* Processor (or machine) status (%msr) */
#define PPC_CR_REGNUM 66 /* Condition register */
Index: ppc-linux-nat.c
===================================================================
RCS file: /cvs/uberbaum/gdb/ppc-linux-nat.c,v
retrieving revision 1.10
diff -u -p -r1.10 ppc-linux-nat.c
--- ppc-linux-nat.c 2001/11/20 16:35:24 1.10
+++ ppc-linux-nat.c 2001/11/26 18:04:34
@@ -35,6 +35,7 @@
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
+#include "ppc-tdep.h"
int
kernel_u_size (void)
@@ -42,21 +43,49 @@ kernel_u_size (void)
return (sizeof (struct user));
}
-static int regmap[] =
-{PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
- PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15,
- PT_R16, PT_R17, PT_R18, PT_R19, PT_R20, PT_R21, PT_R22, PT_R23,
- PT_R24, PT_R25, PT_R26, PT_R27, PT_R28, PT_R29, PT_R30, PT_R31,
- PT_FPR0, PT_FPR0 + 2, PT_FPR0 + 4, PT_FPR0 + 6, PT_FPR0 + 8, PT_FPR0 + 10, PT_FPR0 + 12, PT_FPR0 + 14,
- PT_FPR0 + 16, PT_FPR0 + 18, PT_FPR0 + 20, PT_FPR0 + 22, PT_FPR0 + 24, PT_FPR0 + 26, PT_FPR0 + 28, PT_FPR0 + 30,
- PT_FPR0 + 32, PT_FPR0 + 34, PT_FPR0 + 36, PT_FPR0 + 38, PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46,
- PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54, PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62,
- PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ};
+/* *INDENT-OFF* */
+/* registers layout, as presented by the ptrace interface:
+PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
+PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15,
+PT_R16, PT_R17, PT_R18, PT_R19, PT_R20, PT_R21, PT_R22, PT_R23,
+PT_R24, PT_R25, PT_R26, PT_R27, PT_R28, PT_R29, PT_R30, PT_R31,
+PT_FPR0, PT_FPR0 + 2, PT_FPR0 + 4, PT_FPR0 + 6, PT_FPR0 + 8, PT_FPR0 + 10, PT_FPR0 + 12, PT_FPR0 + 14,
+PT_FPR0 + 16, PT_FPR0 + 18, PT_FPR0 + 20, PT_FPR0 + 22, PT_FPR0 + 24, PT_FPR0 + 26, PT_FPR0 + 28, PT_FPR0 + 30,
+PT_FPR0 + 32, PT_FPR0 + 34, PT_FPR0 + 36, PT_FPR0 + 38, PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46,
+PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54, PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62,
+PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ */
+/* *INDENT_ON * */
int
-ppc_register_u_addr (int ustart, int regnum)
+ppc_register_u_addr (int ustart, int regno)
{
- return (ustart + 4 * regmap[regnum]);
+ int u_addr = -1;
+
+ /* General purpose registers occupy 1 slot each in the buffer */
+ if (regno >= PPC_GP0_REGNUM && regno <= PPC_GPLAST_REGNUM )
+ u_addr = (ustart + (PT_R0 + regno) * 4);
+
+ /* Floating point regs: 2 slots each */
+ if (regno >= FP0_REGNUM && regno <= FPLAST_REGNUM)
+ u_addr = (ustart + (PT_FPR0 + (regno - FP0_REGNUM) * 2) * 4);
+
+ /* UISA special purpose registers: 1 slot each */
+ if (regno == PC_REGNUM)
+ u_addr = ustart + PT_NIP * 4;
+ if (regno == PPC_LR_REGNUM)
+ u_addr = ustart + PT_LNK * 4;
+ if (regno == PPC_CR_REGNUM)
+ u_addr = ustart + PT_CCR * 4;
+ if (regno == PPC_XER_REGNUM)
+ u_addr = ustart + PT_XER * 4;
+ if (regno == PPC_CTR_REGNUM)
+ u_addr = ustart + PT_CTR * 4;
+ if (regno == PPC_MQ_REGNUM)
+ u_addr = ustart + PT_MQ * 4;
+ if (regno == PPC_PS_REGNUM)
+ u_addr = ustart + PT_MSR * 4;
+
+ return u_addr;
}
void
@@ -68,8 +97,13 @@ supply_gregset (gdb_gregset_t *gregsetp)
for (regi = 0; regi < 32; regi++)
supply_register (regi, (char *) (regp + regi));
- for (regi = FIRST_UISA_SP_REGNUM; regi <= LAST_UISA_SP_REGNUM; regi++)
- supply_register (regi, (char *) (regp + regmap[regi]));
+ supply_register (PC_REGNUM, (char *) (regp + PT_NIP));
+ supply_register (PPC_LR_REGNUM, (char *) (regp + PT_LNK));
+ supply_register (PPC_CR_REGNUM, (char *) (regp + PT_CCR));
+ supply_register (PPC_XER_REGNUM, (char *) (regp + PT_XER));
+ supply_register (PPC_CTR_REGNUM, (char *) (regp + PT_CTR));
+ supply_register (PPC_MQ_REGNUM, (char *) (regp + PT_MQ));
+ supply_register (PPC_PS_REGNUM, (char *) (regp + PT_MSR));
}
void
@@ -78,19 +112,26 @@ fill_gregset (gdb_gregset_t *gregsetp, i
int regi;
elf_greg_t *regp = (elf_greg_t *) gregsetp;
-#define COPY_REG(_idx_,_regi_) \
- if ((regno == -1) || regno == _regi_) \
- regcache_collect (_regi_, regp + _idx_)
-
for (regi = 0; regi < 32; regi++)
{
- COPY_REG (regmap[regi], regi);
+ if ((regno == -1) || regno == regi)
+ regcache_collect (regi, regp + PT_R0 + regi);
}
- for (regi = FIRST_UISA_SP_REGNUM; regi <= LAST_UISA_SP_REGNUM; regi++)
- {
- COPY_REG (regmap[regi], regi);
- }
+ if ((regno == -1) || regno == PC_REGNUM)
+ regcache_collect (PC_REGNUM, regp + PT_NIP);
+ if ((regno == -1) || regno == PPC_LR_REGNUM)
+ regcache_collect (PPC_LR_REGNUM, regp + PT_LNK);
+ if ((regno == -1) || regno == PPC_CR_REGNUM)
+ regcache_collect (PPC_CR_REGNUM, regp + PT_CCR);
+ if ((regno == -1) || regno == PPC_XER_REGNUM)
+ regcache_collect (PPC_XER_REGNUM, regp + PT_XER);
+ if ((regno == -1) || regno == PPC_CTR_REGNUM)
+ regcache_collect (PPC_CTR_REGNUM, regp + PT_CTR);
+ if ((regno == -1) || regno == PPC_MQ_REGNUM)
+ regcache_collect (PPC_MQ_REGNUM, regp + PT_MQ);
+ if ((regno == -1) || regno == PPC_PS_REGNUM)
+ regcache_collect (PPC_PS_REGNUM, regp + PT_MSR);
}
void
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-12 13:12 [RFA] ppc-linux-nat.c: Don't use regmap[] anymore Elena Zannoni
@ 2001-11-19 15:56 ` Kevin Buettner
2001-11-19 18:25 ` Andrew Cagney
` (2 more replies)
2001-11-26 10:13 ` Elena Zannoni
1 sibling, 3 replies; 16+ messages in thread
From: Kevin Buettner @ 2001-11-19 15:56 UTC (permalink / raw)
To: Elena Zannoni, gdb-patches
On Nov 26, 1:19pm, Elena Zannoni wrote:
> 2001-11-26 Elena Zannoni <ezannoni@redhat.com>
>
> * Makefile.in (ppc-linux-nat.o): Add dependency on ppc-tdep.h.
>
> * ppc-tdep.h (PPC_GPLAST_REGNUM): Define.
>
> * ppc-linux-nat.c: Include ppc-tdep.h.
> (ppc_register_u_addr): Don't use the static array regmap[],
> dynamically define the mapping instead.
> (supply_gregset): Ditto.
> (fill_gregset): Ditto.
> (COPY_REG): Delete macro defintion.
> (regmap): Delete array.
Now that I've seen Elena's WIP patch, I understand the reasons for doing
this.
Approved.
Kevin
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-19 15:56 ` Kevin Buettner
@ 2001-11-19 18:25 ` Andrew Cagney
2001-11-29 13:45 ` Andrew Cagney
2001-11-29 14:01 ` Kevin Buettner
2001-11-29 12:59 ` Kevin Buettner
2001-11-29 18:14 ` Elena Zannoni
2 siblings, 2 replies; 16+ messages in thread
From: Andrew Cagney @ 2001-11-19 18:25 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Elena Zannoni, gdb-patches
> On Nov 26, 1:19pm, Elena Zannoni wrote:
>
>
>> 2001-11-26 Elena Zannoni <ezannoni@redhat.com>
>>
>> * Makefile.in (ppc-linux-nat.o): Add dependency on ppc-tdep.h.
>>
>> * ppc-tdep.h (PPC_GPLAST_REGNUM): Define.
>>
>> * ppc-linux-nat.c: Include ppc-tdep.h.
>> (ppc_register_u_addr): Don't use the static array regmap[],
>> dynamically define the mapping instead.
>> (supply_gregset): Ditto.
>> (fill_gregset): Ditto.
>> (COPY_REG): Delete macro defintion.
>> (regmap): Delete array.
>
>
> Now that I've seen Elena's WIP patch, I understand the reasons for doing
> this.
I suspect a few more targets could do with the same treatment.
Eliminating that hardwired regmap[] would probably help a few more targets.
Andrew
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-19 18:25 ` Andrew Cagney
@ 2001-11-29 13:45 ` Andrew Cagney
2001-11-29 14:01 ` Kevin Buettner
1 sibling, 0 replies; 16+ messages in thread
From: Andrew Cagney @ 2001-11-29 13:45 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Elena Zannoni, gdb-patches
> On Nov 26, 1:19pm, Elena Zannoni wrote:
>
>
>> 2001-11-26 Elena Zannoni <ezannoni@redhat.com>
>>
>> * Makefile.in (ppc-linux-nat.o): Add dependency on ppc-tdep.h.
>>
>> * ppc-tdep.h (PPC_GPLAST_REGNUM): Define.
>>
>> * ppc-linux-nat.c: Include ppc-tdep.h.
>> (ppc_register_u_addr): Don't use the static array regmap[],
>> dynamically define the mapping instead.
>> (supply_gregset): Ditto.
>> (fill_gregset): Ditto.
>> (COPY_REG): Delete macro defintion.
>> (regmap): Delete array.
>
>
> Now that I've seen Elena's WIP patch, I understand the reasons for doing
> this.
I suspect a few more targets could do with the same treatment.
Eliminating that hardwired regmap[] would probably help a few more targets.
Andrew
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-19 18:25 ` Andrew Cagney
2001-11-29 13:45 ` Andrew Cagney
@ 2001-11-29 14:01 ` Kevin Buettner
2001-11-19 19:26 ` Kevin Buettner
2001-11-29 14:56 ` Andrew Cagney
1 sibling, 2 replies; 16+ messages in thread
From: Kevin Buettner @ 2001-11-29 14:01 UTC (permalink / raw)
To: Andrew Cagney, Kevin Buettner; +Cc: Elena Zannoni, gdb-patches
On Nov 29, 4:45pm, Andrew Cagney wrote:
> I suspect a few more targets could do with the same treatment.
> Eliminating that hardwired regmap[] would probably help a few more targets.
Perhaps. But, I think each target better have good reasons for doing
so before undertaking such a transformation. Replacing the hardwired
regmap[] with a function with the same constants hardwired into it
doesn't accomplish much (aside from slowing things somewhat).
Kevin
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-29 14:01 ` Kevin Buettner
@ 2001-11-19 19:26 ` Kevin Buettner
2001-11-29 14:56 ` Andrew Cagney
1 sibling, 0 replies; 16+ messages in thread
From: Kevin Buettner @ 2001-11-19 19:26 UTC (permalink / raw)
To: Andrew Cagney, Kevin Buettner; +Cc: Elena Zannoni, gdb-patches
On Nov 29, 4:45pm, Andrew Cagney wrote:
> I suspect a few more targets could do with the same treatment.
> Eliminating that hardwired regmap[] would probably help a few more targets.
Perhaps. But, I think each target better have good reasons for doing
so before undertaking such a transformation. Replacing the hardwired
regmap[] with a function with the same constants hardwired into it
doesn't accomplish much (aside from slowing things somewhat).
Kevin
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-29 14:01 ` Kevin Buettner
2001-11-19 19:26 ` Kevin Buettner
@ 2001-11-29 14:56 ` Andrew Cagney
2001-11-20 8:47 ` Andrew Cagney
2001-11-20 11:10 ` Kevin Buettner
1 sibling, 2 replies; 16+ messages in thread
From: Andrew Cagney @ 2001-11-29 14:56 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Elena Zannoni, gdb-patches
> On Nov 29, 4:45pm, Andrew Cagney wrote:
>
>
>> I suspect a few more targets could do with the same treatment.
>> Eliminating that hardwired regmap[] would probably help a few more targets.
>
>
> Perhaps. But, I think each target better have good reasons for doing
> so before undertaking such a transformation. Replacing the hardwired
> regmap[] with a function with the same constants hardwired into it
> doesn't accomplish much (aside from slowing things somewhat).
The problem is, they are not constant. Because of limitations in the
way other parts of GDB currently work, an architecture change can cause
those offsets to change :-( Check x86-64 vs i386.
I don't think performance is an issue here.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-29 14:56 ` Andrew Cagney
@ 2001-11-20 8:47 ` Andrew Cagney
2001-11-20 11:10 ` Kevin Buettner
1 sibling, 0 replies; 16+ messages in thread
From: Andrew Cagney @ 2001-11-20 8:47 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Elena Zannoni, gdb-patches
> On Nov 29, 4:45pm, Andrew Cagney wrote:
>
>
>> I suspect a few more targets could do with the same treatment.
>> Eliminating that hardwired regmap[] would probably help a few more targets.
>
>
> Perhaps. But, I think each target better have good reasons for doing
> so before undertaking such a transformation. Replacing the hardwired
> regmap[] with a function with the same constants hardwired into it
> doesn't accomplish much (aside from slowing things somewhat).
The problem is, they are not constant. Because of limitations in the
way other parts of GDB currently work, an architecture change can cause
those offsets to change :-( Check x86-64 vs i386.
I don't think performance is an issue here.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-29 14:56 ` Andrew Cagney
2001-11-20 8:47 ` Andrew Cagney
@ 2001-11-20 11:10 ` Kevin Buettner
2001-11-29 16:01 ` Kevin Buettner
2001-11-29 16:38 ` Andrew Cagney
1 sibling, 2 replies; 16+ messages in thread
From: Kevin Buettner @ 2001-11-20 11:10 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
On Nov 29, 5:56pm, Andrew Cagney wrote:
> > On Nov 29, 4:45pm, Andrew Cagney wrote:
> >
> >> I suspect a few more targets could do with the same treatment.
> >> Eliminating that hardwired regmap[] would probably help a few more targets.
> >
> > Perhaps. But, I think each target better have good reasons for doing
> > so before undertaking such a transformation. Replacing the hardwired
> > regmap[] with a function with the same constants hardwired into it
> > doesn't accomplish much (aside from slowing things somewhat).
>
> The problem is, they are not constant. Because of limitations in the
> way other parts of GDB currently work, an architecture change can cause
> those offsets to change :-( Check x86-64 vs i386.
Just to make sure we're talking about the same thing... regmap[] maps
GDB register numbers to ``struct user'' offsets. These are used when
calling ptrace() and are sometimes used for obtaining struct offsets
within a gregset.
I don't know much about Linux/x86-64, but I would imagine that its
``struct user'' is different than that used for Linux/x86. (Which, I
gather, is what you mean by these offsets not being constant.) If it's
somehow possible to debug Linux/x86 programs on Linux/x86-64, then we
would indeed need a mechanism to pick the right regmap[]. Certainly,
using a function in this case would make sense. However, it might
well be implemented something like this:
static int
regmap (int regno)
{
static int x86_regmap[] = { ... };
static int x86_64_regmap[] = { ... };
if (target_is_x86_64 ())
return x86_64_regmap[regno];
else
return x86_regmap[regno];
}
I did look at x86-64-linux-nat.c and it does appear to be amazingly
similar to i386-linux-nat.c. It would be nice if the same file could
be used for both architectures. If making a more dynamic regmap[]
is what's needed, then I'm all for it.
Kevin
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-20 11:10 ` Kevin Buettner
@ 2001-11-29 16:01 ` Kevin Buettner
2001-11-29 16:38 ` Andrew Cagney
1 sibling, 0 replies; 16+ messages in thread
From: Kevin Buettner @ 2001-11-29 16:01 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
On Nov 29, 5:56pm, Andrew Cagney wrote:
> > On Nov 29, 4:45pm, Andrew Cagney wrote:
> >
> >> I suspect a few more targets could do with the same treatment.
> >> Eliminating that hardwired regmap[] would probably help a few more targets.
> >
> > Perhaps. But, I think each target better have good reasons for doing
> > so before undertaking such a transformation. Replacing the hardwired
> > regmap[] with a function with the same constants hardwired into it
> > doesn't accomplish much (aside from slowing things somewhat).
>
> The problem is, they are not constant. Because of limitations in the
> way other parts of GDB currently work, an architecture change can cause
> those offsets to change :-( Check x86-64 vs i386.
Just to make sure we're talking about the same thing... regmap[] maps
GDB register numbers to ``struct user'' offsets. These are used when
calling ptrace() and are sometimes used for obtaining struct offsets
within a gregset.
I don't know much about Linux/x86-64, but I would imagine that its
``struct user'' is different than that used for Linux/x86. (Which, I
gather, is what you mean by these offsets not being constant.) If it's
somehow possible to debug Linux/x86 programs on Linux/x86-64, then we
would indeed need a mechanism to pick the right regmap[]. Certainly,
using a function in this case would make sense. However, it might
well be implemented something like this:
static int
regmap (int regno)
{
static int x86_regmap[] = { ... };
static int x86_64_regmap[] = { ... };
if (target_is_x86_64 ())
return x86_64_regmap[regno];
else
return x86_regmap[regno];
}
I did look at x86-64-linux-nat.c and it does appear to be amazingly
similar to i386-linux-nat.c. It would be nice if the same file could
be used for both architectures. If making a more dynamic regmap[]
is what's needed, then I'm all for it.
Kevin
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-20 11:10 ` Kevin Buettner
2001-11-29 16:01 ` Kevin Buettner
@ 2001-11-29 16:38 ` Andrew Cagney
2001-11-20 16:11 ` Andrew Cagney
1 sibling, 1 reply; 16+ messages in thread
From: Andrew Cagney @ 2001-11-29 16:38 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb-patches
>
> Just to make sure we're talking about the same thing... regmap[] maps
> GDB register numbers to ``struct user'' offsets. These are used when
> calling ptrace() and are sometimes used for obtaining struct offsets
> within a gregset.
Yes, a given nat file will use constant offsets to find a given register
in the ptrace / corefile / .... The ``regnum'' assigned to that
register, however, can change.
> I don't know much about Linux/x86-64, but I would imagine that its
> ``struct user'' is different than that used for Linux/x86. (Which, I
> gather, is what you mean by these offsets not being constant.) If it's
> somehow possible to debug Linux/x86 programs on Linux/x86-64, then we
> would indeed need a mechanism to pick the right regmap[]. Certainly,
> using a function in this case would make sense. However, it might
> well be implemented something like this:
>
> static int
> regmap (int regno)
> {
> static int x86_regmap[] = { ... };
> static int x86_64_regmap[] = { ... };
> if (target_is_x86_64 ())
> return x86_64_regmap[regno];
> else
> return x86_regmap[regno];
> }
Yes. This would handle two of the possible REGNUM -> OFFSET mappings.
I think a more robust way of doing it is:
if (regnum in I386_FP0_REGNUM to MAX)
DO SOMETHING;
else if regnum in someother register range;
do something else;
which means you're insulated from a problem such as the regnum's being
re-aranged (Hmm, lets slip MMX registers in between FP and XMM registers).
> I did look at x86-64-linux-nat.c and it does appear to be amazingly
> similar to i386-linux-nat.c. It would be nice if the same file could
> be used for both architectures. If making a more dynamic regmap[]
> is what's needed, then I'm all for it.
I suspect Mark K has thoughts of doing that :-)
There are other ways this could be handled, however, for the moment I
think the run-time test is safest. I'm getting ready to post a really
nasty regcache.[hc] patch that will hopefully illustrate one of the
problems - NUM_REGS and REGISTER_BYTES.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-29 16:38 ` Andrew Cagney
@ 2001-11-20 16:11 ` Andrew Cagney
0 siblings, 0 replies; 16+ messages in thread
From: Andrew Cagney @ 2001-11-20 16:11 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb-patches
>
> Just to make sure we're talking about the same thing... regmap[] maps
> GDB register numbers to ``struct user'' offsets. These are used when
> calling ptrace() and are sometimes used for obtaining struct offsets
> within a gregset.
Yes, a given nat file will use constant offsets to find a given register
in the ptrace / corefile / .... The ``regnum'' assigned to that
register, however, can change.
> I don't know much about Linux/x86-64, but I would imagine that its
> ``struct user'' is different than that used for Linux/x86. (Which, I
> gather, is what you mean by these offsets not being constant.) If it's
> somehow possible to debug Linux/x86 programs on Linux/x86-64, then we
> would indeed need a mechanism to pick the right regmap[]. Certainly,
> using a function in this case would make sense. However, it might
> well be implemented something like this:
>
> static int
> regmap (int regno)
> {
> static int x86_regmap[] = { ... };
> static int x86_64_regmap[] = { ... };
> if (target_is_x86_64 ())
> return x86_64_regmap[regno];
> else
> return x86_regmap[regno];
> }
Yes. This would handle two of the possible REGNUM -> OFFSET mappings.
I think a more robust way of doing it is:
if (regnum in I386_FP0_REGNUM to MAX)
DO SOMETHING;
else if regnum in someother register range;
do something else;
which means you're insulated from a problem such as the regnum's being
re-aranged (Hmm, lets slip MMX registers in between FP and XMM registers).
> I did look at x86-64-linux-nat.c and it does appear to be amazingly
> similar to i386-linux-nat.c. It would be nice if the same file could
> be used for both architectures. If making a more dynamic regmap[]
> is what's needed, then I'm all for it.
I suspect Mark K has thoughts of doing that :-)
There are other ways this could be handled, however, for the moment I
think the run-time test is safest. I'm getting ready to post a really
nasty regcache.[hc] patch that will hopefully illustrate one of the
problems - NUM_REGS and REGISTER_BYTES.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-19 15:56 ` Kevin Buettner
2001-11-19 18:25 ` Andrew Cagney
@ 2001-11-29 12:59 ` Kevin Buettner
2001-11-29 18:14 ` Elena Zannoni
2 siblings, 0 replies; 16+ messages in thread
From: Kevin Buettner @ 2001-11-29 12:59 UTC (permalink / raw)
To: Elena Zannoni, gdb-patches
On Nov 26, 1:19pm, Elena Zannoni wrote:
> 2001-11-26 Elena Zannoni <ezannoni@redhat.com>
>
> * Makefile.in (ppc-linux-nat.o): Add dependency on ppc-tdep.h.
>
> * ppc-tdep.h (PPC_GPLAST_REGNUM): Define.
>
> * ppc-linux-nat.c: Include ppc-tdep.h.
> (ppc_register_u_addr): Don't use the static array regmap[],
> dynamically define the mapping instead.
> (supply_gregset): Ditto.
> (fill_gregset): Ditto.
> (COPY_REG): Delete macro defintion.
> (regmap): Delete array.
Now that I've seen Elena's WIP patch, I understand the reasons for doing
this.
Approved.
Kevin
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-19 15:56 ` Kevin Buettner
2001-11-19 18:25 ` Andrew Cagney
2001-11-29 12:59 ` Kevin Buettner
@ 2001-11-29 18:14 ` Elena Zannoni
2001-11-21 3:54 ` Elena Zannoni
2 siblings, 1 reply; 16+ messages in thread
From: Elena Zannoni @ 2001-11-29 18:14 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Elena Zannoni, gdb-patches
Kevin Buettner writes:
> On Nov 26, 1:19pm, Elena Zannoni wrote:
>
> > 2001-11-26 Elena Zannoni <ezannoni@redhat.com>
> >
> > * Makefile.in (ppc-linux-nat.o): Add dependency on ppc-tdep.h.
> >
> > * ppc-tdep.h (PPC_GPLAST_REGNUM): Define.
> >
> > * ppc-linux-nat.c: Include ppc-tdep.h.
> > (ppc_register_u_addr): Don't use the static array regmap[],
> > dynamically define the mapping instead.
> > (supply_gregset): Ditto.
> > (fill_gregset): Ditto.
> > (COPY_REG): Delete macro defintion.
> > (regmap): Delete array.
>
> Now that I've seen Elena's WIP patch, I understand the reasons for doing
> this.
>
> Approved.
>
> Kevin
Committed.
Elena
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-29 18:14 ` Elena Zannoni
@ 2001-11-21 3:54 ` Elena Zannoni
0 siblings, 0 replies; 16+ messages in thread
From: Elena Zannoni @ 2001-11-21 3:54 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Elena Zannoni, gdb-patches
Kevin Buettner writes:
> On Nov 26, 1:19pm, Elena Zannoni wrote:
>
> > 2001-11-26 Elena Zannoni <ezannoni@redhat.com>
> >
> > * Makefile.in (ppc-linux-nat.o): Add dependency on ppc-tdep.h.
> >
> > * ppc-tdep.h (PPC_GPLAST_REGNUM): Define.
> >
> > * ppc-linux-nat.c: Include ppc-tdep.h.
> > (ppc_register_u_addr): Don't use the static array regmap[],
> > dynamically define the mapping instead.
> > (supply_gregset): Ditto.
> > (fill_gregset): Ditto.
> > (COPY_REG): Delete macro defintion.
> > (regmap): Delete array.
>
> Now that I've seen Elena's WIP patch, I understand the reasons for doing
> this.
>
> Approved.
>
> Kevin
Committed.
Elena
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFA] ppc-linux-nat.c: Don't use regmap[] anymore.
2001-11-12 13:12 [RFA] ppc-linux-nat.c: Don't use regmap[] anymore Elena Zannoni
2001-11-19 15:56 ` Kevin Buettner
@ 2001-11-26 10:13 ` Elena Zannoni
1 sibling, 0 replies; 16+ messages in thread
From: Elena Zannoni @ 2001-11-26 10:13 UTC (permalink / raw)
To: gdb-patches
Use a dynamic mapping instead.
Tested on a G4 running YDL.
Elena
2001-11-26 Elena Zannoni <ezannoni@redhat.com>
* Makefile.in (ppc-linux-nat.o): Add dependency on ppc-tdep.h.
* ppc-tdep.h (PPC_GPLAST_REGNUM): Define.
* ppc-linux-nat.c: Include ppc-tdep.h.
(ppc_register_u_addr): Don't use the static array regmap[],
dynamically define the mapping instead.
(supply_gregset): Ditto.
(fill_gregset): Ditto.
(COPY_REG): Delete macro defintion.
(regmap): Delete array.
Index: Makefile.in
===================================================================
RCS file: /cvs/uberbaum/gdb/Makefile.in,v
retrieving revision 1.130
diff -u -p -r1.130 Makefile.in
--- Makefile.in 2001/11/18 05:09:26 1.130
+++ Makefile.in 2001/11/26 18:11:44
@@ -1818,7 +1818,7 @@ ppc-bdm.o: ppc-bdm.c $(defs_h) $(gdbcore
$(objfiles_h) $(gdb_stabs_h) $(serial_h) ocd.h $(regcache_h)
ppc-linux-nat.o: ppc-linux-nat.c $(defs_h) $(gdbcore_h) $(frame_h) \
- $(inferior_h) $(target_h) $(regcache_h)
+ $(inferior_h) $(target_h) $(regcache_h) ppc-tdep.h
ppc-linux-tdep.o: ppc-linux-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \
$(target_h) ppc-tdep.h $(regcache_h) $(value_h)
Index: ppc-tdep.h
===================================================================
RCS file: /cvs/uberbaum/gdb/ppc-tdep.h,v
retrieving revision 1.2
diff -u -p -r1.2 ppc-tdep.h
--- ppc-tdep.h 2001/11/01 01:07:35 1.2
+++ ppc-tdep.h 2001/11/26 18:07:25
@@ -46,6 +46,7 @@ CORE_ADDR rs6000_frame_chain (struct fra
/* Some important register numbers. */
#define PPC_GP0_REGNUM 0 /* GPR register 0 */
+#define PPC_GPLAST_REGNUM 31 /* GPR register 31 */
#define PPC_TOC_REGNUM 2 /* TOC register */
#define PPC_PS_REGNUM 65 /* Processor (or machine) status (%msr) */
#define PPC_CR_REGNUM 66 /* Condition register */
Index: ppc-linux-nat.c
===================================================================
RCS file: /cvs/uberbaum/gdb/ppc-linux-nat.c,v
retrieving revision 1.10
diff -u -p -r1.10 ppc-linux-nat.c
--- ppc-linux-nat.c 2001/11/20 16:35:24 1.10
+++ ppc-linux-nat.c 2001/11/26 18:04:34
@@ -35,6 +35,7 @@
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
+#include "ppc-tdep.h"
int
kernel_u_size (void)
@@ -42,21 +43,49 @@ kernel_u_size (void)
return (sizeof (struct user));
}
-static int regmap[] =
-{PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
- PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15,
- PT_R16, PT_R17, PT_R18, PT_R19, PT_R20, PT_R21, PT_R22, PT_R23,
- PT_R24, PT_R25, PT_R26, PT_R27, PT_R28, PT_R29, PT_R30, PT_R31,
- PT_FPR0, PT_FPR0 + 2, PT_FPR0 + 4, PT_FPR0 + 6, PT_FPR0 + 8, PT_FPR0 + 10, PT_FPR0 + 12, PT_FPR0 + 14,
- PT_FPR0 + 16, PT_FPR0 + 18, PT_FPR0 + 20, PT_FPR0 + 22, PT_FPR0 + 24, PT_FPR0 + 26, PT_FPR0 + 28, PT_FPR0 + 30,
- PT_FPR0 + 32, PT_FPR0 + 34, PT_FPR0 + 36, PT_FPR0 + 38, PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46,
- PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54, PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62,
- PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ};
+/* *INDENT-OFF* */
+/* registers layout, as presented by the ptrace interface:
+PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
+PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15,
+PT_R16, PT_R17, PT_R18, PT_R19, PT_R20, PT_R21, PT_R22, PT_R23,
+PT_R24, PT_R25, PT_R26, PT_R27, PT_R28, PT_R29, PT_R30, PT_R31,
+PT_FPR0, PT_FPR0 + 2, PT_FPR0 + 4, PT_FPR0 + 6, PT_FPR0 + 8, PT_FPR0 + 10, PT_FPR0 + 12, PT_FPR0 + 14,
+PT_FPR0 + 16, PT_FPR0 + 18, PT_FPR0 + 20, PT_FPR0 + 22, PT_FPR0 + 24, PT_FPR0 + 26, PT_FPR0 + 28, PT_FPR0 + 30,
+PT_FPR0 + 32, PT_FPR0 + 34, PT_FPR0 + 36, PT_FPR0 + 38, PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46,
+PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54, PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62,
+PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ */
+/* *INDENT_ON * */
int
-ppc_register_u_addr (int ustart, int regnum)
+ppc_register_u_addr (int ustart, int regno)
{
- return (ustart + 4 * regmap[regnum]);
+ int u_addr = -1;
+
+ /* General purpose registers occupy 1 slot each in the buffer */
+ if (regno >= PPC_GP0_REGNUM && regno <= PPC_GPLAST_REGNUM )
+ u_addr = (ustart + (PT_R0 + regno) * 4);
+
+ /* Floating point regs: 2 slots each */
+ if (regno >= FP0_REGNUM && regno <= FPLAST_REGNUM)
+ u_addr = (ustart + (PT_FPR0 + (regno - FP0_REGNUM) * 2) * 4);
+
+ /* UISA special purpose registers: 1 slot each */
+ if (regno == PC_REGNUM)
+ u_addr = ustart + PT_NIP * 4;
+ if (regno == PPC_LR_REGNUM)
+ u_addr = ustart + PT_LNK * 4;
+ if (regno == PPC_CR_REGNUM)
+ u_addr = ustart + PT_CCR * 4;
+ if (regno == PPC_XER_REGNUM)
+ u_addr = ustart + PT_XER * 4;
+ if (regno == PPC_CTR_REGNUM)
+ u_addr = ustart + PT_CTR * 4;
+ if (regno == PPC_MQ_REGNUM)
+ u_addr = ustart + PT_MQ * 4;
+ if (regno == PPC_PS_REGNUM)
+ u_addr = ustart + PT_MSR * 4;
+
+ return u_addr;
}
void
@@ -68,8 +97,13 @@ supply_gregset (gdb_gregset_t *gregsetp)
for (regi = 0; regi < 32; regi++)
supply_register (regi, (char *) (regp + regi));
- for (regi = FIRST_UISA_SP_REGNUM; regi <= LAST_UISA_SP_REGNUM; regi++)
- supply_register (regi, (char *) (regp + regmap[regi]));
+ supply_register (PC_REGNUM, (char *) (regp + PT_NIP));
+ supply_register (PPC_LR_REGNUM, (char *) (regp + PT_LNK));
+ supply_register (PPC_CR_REGNUM, (char *) (regp + PT_CCR));
+ supply_register (PPC_XER_REGNUM, (char *) (regp + PT_XER));
+ supply_register (PPC_CTR_REGNUM, (char *) (regp + PT_CTR));
+ supply_register (PPC_MQ_REGNUM, (char *) (regp + PT_MQ));
+ supply_register (PPC_PS_REGNUM, (char *) (regp + PT_MSR));
}
void
@@ -78,19 +112,26 @@ fill_gregset (gdb_gregset_t *gregsetp, i
int regi;
elf_greg_t *regp = (elf_greg_t *) gregsetp;
-#define COPY_REG(_idx_,_regi_) \
- if ((regno == -1) || regno == _regi_) \
- regcache_collect (_regi_, regp + _idx_)
-
for (regi = 0; regi < 32; regi++)
{
- COPY_REG (regmap[regi], regi);
+ if ((regno == -1) || regno == regi)
+ regcache_collect (regi, regp + PT_R0 + regi);
}
- for (regi = FIRST_UISA_SP_REGNUM; regi <= LAST_UISA_SP_REGNUM; regi++)
- {
- COPY_REG (regmap[regi], regi);
- }
+ if ((regno == -1) || regno == PC_REGNUM)
+ regcache_collect (PC_REGNUM, regp + PT_NIP);
+ if ((regno == -1) || regno == PPC_LR_REGNUM)
+ regcache_collect (PPC_LR_REGNUM, regp + PT_LNK);
+ if ((regno == -1) || regno == PPC_CR_REGNUM)
+ regcache_collect (PPC_CR_REGNUM, regp + PT_CCR);
+ if ((regno == -1) || regno == PPC_XER_REGNUM)
+ regcache_collect (PPC_XER_REGNUM, regp + PT_XER);
+ if ((regno == -1) || regno == PPC_CTR_REGNUM)
+ regcache_collect (PPC_CTR_REGNUM, regp + PT_CTR);
+ if ((regno == -1) || regno == PPC_MQ_REGNUM)
+ regcache_collect (PPC_MQ_REGNUM, regp + PT_MQ);
+ if ((regno == -1) || regno == PPC_PS_REGNUM)
+ regcache_collect (PPC_PS_REGNUM, regp + PT_MSR);
}
void
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2001-11-30 2:14 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-12 13:12 [RFA] ppc-linux-nat.c: Don't use regmap[] anymore Elena Zannoni
2001-11-19 15:56 ` Kevin Buettner
2001-11-19 18:25 ` Andrew Cagney
2001-11-29 13:45 ` Andrew Cagney
2001-11-29 14:01 ` Kevin Buettner
2001-11-19 19:26 ` Kevin Buettner
2001-11-29 14:56 ` Andrew Cagney
2001-11-20 8:47 ` Andrew Cagney
2001-11-20 11:10 ` Kevin Buettner
2001-11-29 16:01 ` Kevin Buettner
2001-11-29 16:38 ` Andrew Cagney
2001-11-20 16:11 ` Andrew Cagney
2001-11-29 12:59 ` Kevin Buettner
2001-11-29 18:14 ` Elena Zannoni
2001-11-21 3:54 ` Elena Zannoni
2001-11-26 10:13 ` Elena Zannoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox