* [patch/rfc] regcache_raw_read_as_address() -> regcache_cooked_read_as_ulongest()
@ 2002-08-12 12:51 Andrew Cagney
2002-08-12 12:57 ` Andrew Cagney
2002-08-12 13:12 ` Daniel Jacobowitz
0 siblings, 2 replies; 4+ messages in thread
From: Andrew Cagney @ 2002-08-12 12:51 UTC (permalink / raw)
To: gdb-patches; +Cc: Mark Kettenis
Hello,
This patch replaces the function regcache_raw_read_as_address() with the
pair:
regcache_cooked_read_as_longest()
regcache_cooked_read_as_ulongest()
The two calls to the old ..as_address() being replaced with the ulongest
version.
I think the change is ok (i386 shows no regressions, the mips doesn't
use this code :-). I'm just wondering about the names. Perhaps:
regcache_cooked_read_signed() & regcache_cooked_read_unsigned()?
thoughts?
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch/rfc] regcache_raw_read_as_address() -> regcache_cooked_read_as_ulongest()
2002-08-12 12:51 [patch/rfc] regcache_raw_read_as_address() -> regcache_cooked_read_as_ulongest() Andrew Cagney
@ 2002-08-12 12:57 ` Andrew Cagney
2002-08-12 13:12 ` Daniel Jacobowitz
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2002-08-12 12:57 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches, Mark Kettenis
[-- Attachment #1: Type: text/plain, Size: 498 bytes --]
> Hello,
>
> This patch replaces the function regcache_raw_read_as_address() with the pair:
> regcache_cooked_read_as_longest()
> regcache_cooked_read_as_ulongest()
> The two calls to the old ..as_address() being replaced with the ulongest version.
>
> I think the change is ok (i386 shows no regressions, the mips doesn't use this code :-). I'm just wondering about the names. Perhaps: regcache_cooked_read_signed() & regcache_cooked_read_unsigned()?
>
> thoughts?
> Andrew
>
sigh,
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 5225 bytes --]
2002-08-12 Andrew Cagney <cagney@redhat.com>
* regcache.c (regcache_raw_read_as_address): Delete function.
(regcache_cooked_read_as_longest): New function.
(regcache_cooked_read_as_ulongest): New function.
* regcache.h (regcache_cooked_read_as_longest): Declare.
(regcache_cooked_read_as_ulongest): Declare.
(regcache_raw_read_as_address): Delete declaration.
* blockframe.c (generic_read_register_dummy): Use
regcache_cooked_read_as_ulongest.
* i386-tdep.c (i386_extract_struct_value_address): Use
regcache_cooked_read_as_ulongest.
Index: blockframe.c
===================================================================
RCS file: /cvs/src/src/gdb/blockframe.c,v
retrieving revision 1.35
diff -u -r1.35 blockframe.c
--- blockframe.c 9 Aug 2002 18:26:15 -0000 1.35
+++ blockframe.c 12 Aug 2002 19:43:07 -0000
@@ -1215,7 +1215,16 @@
struct regcache *dummy_regs = generic_find_dummy_frame (pc, fp);
if (dummy_regs)
- return regcache_raw_read_as_address (dummy_regs, regno);
+ /* NOTE: cagney/2002-08-12: Replaced a call to
+ regcache_raw_read_as_address() with a call to
+ regcache_cooked_read_as_ulongest(). The old, ...as_address
+ call was eventually calling extract_unsigned_integer (via
+ extract_address) to unpack the registers value. The bellow is
+ doing an unsigned extract so that it is functionally
+ equivalent. The read needs to be cooked as, otherwize, it will
+ never correctly return the value of a register in the [NUM_REGS
+ .. NUM_REGS+NUM_PSEUDO_REGS) range. */
+ return regcache_cooked_read_as_ulongest (dummy_regs, regno);
else
return 0;
}
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.74
diff -u -r1.74 i386-tdep.c
--- i386-tdep.c 12 Aug 2002 19:05:33 -0000 1.74
+++ i386-tdep.c 12 Aug 2002 19:43:07 -0000
@@ -1028,7 +1028,7 @@
static CORE_ADDR
i386_extract_struct_value_address (struct regcache *regcache)
{
- return regcache_raw_read_as_address (regcache, LOW_RETURN_REGNUM);
+ return regcache_cooked_read_as_ulongest (regcache, LOW_RETURN_REGNUM);
}
\f
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.50
diff -u -r1.50 regcache.c
--- regcache.c 10 Aug 2002 02:00:16 -0000 1.50
+++ regcache.c 12 Aug 2002 19:43:08 -0000
@@ -366,17 +366,6 @@
return regcache->raw_register_valid_p[regnum];
}
-CORE_ADDR
-regcache_raw_read_as_address (struct regcache *regcache, int regnum)
-{
- char *buf;
- gdb_assert (regcache != NULL);
- gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
- buf = alloca (regcache->descr->sizeof_register[regnum]);
- regcache_raw_read (regcache, regnum, buf);
- return extract_address (buf, regcache->descr->sizeof_register[regnum]);
-}
-
char *
deprecated_grub_regcache_for_registers (struct regcache *regcache)
{
@@ -694,6 +683,30 @@
else
gdbarch_pseudo_register_read (regcache->descr->gdbarch, regcache,
regnum, buf);
+}
+
+LONGEST
+regcache_cooked_read_as_longest (struct regcache *regcache, int regnum)
+{
+ char *buf;
+ gdb_assert (regcache != NULL);
+ gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
+ buf = alloca (regcache->descr->sizeof_register[regnum]);
+ regcache_cooked_read (regcache, regnum, buf);
+ return extract_signed_integer (buf,
+ regcache->descr->sizeof_register[regnum]);
+}
+
+ULONGEST
+regcache_cooked_read_as_ulongest (struct regcache *regcache, int regnum)
+{
+ char *buf;
+ gdb_assert (regcache != NULL);
+ gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
+ buf = alloca (regcache->descr->sizeof_register[regnum]);
+ regcache_cooked_read (regcache, regnum, buf);
+ return extract_unsigned_integer (buf,
+ regcache->descr->sizeof_register[regnum]);
}
/* Write register REGNUM at MYADDR to the target. MYADDR points at
Index: regcache.h
===================================================================
RCS file: /cvs/src/src/gdb/regcache.h,v
retrieving revision 1.12
diff -u -r1.12 regcache.h
--- regcache.h 2 Aug 2002 18:08:31 -0000 1.12
+++ regcache.h 12 Aug 2002 19:43:08 -0000
@@ -39,12 +39,18 @@
void regcache_raw_write (struct regcache *regcache, int rawnum,
const void *buf);
int regcache_valid_p (struct regcache *regcache, int regnum);
-CORE_ADDR regcache_raw_read_as_address (struct regcache *regcache, int rawnum);
/* Transfer a cooked register [0..NUM_REGS+NUM_PSEUDO_REGS). */
void regcache_cooked_read (struct regcache *regcache, int rawnum, void *buf);
void regcache_cooked_write (struct regcache *regcache, int rawnum,
const void *buf);
+
+/* Read a cooked register as a signed integer. */
+extern LONGEST regcache_cooked_read_as_longest (struct regcache *regcache,
+ int regnum);
+/* Read a cooked register as an unsigned integer. */
+extern ULONGEST regcache_cooked_read_as_ulongest (struct regcache *regcache,
+ int regnum);
/* Transfer a raw register [0..NUM_REGS) between the regcache and the
target. These functions are called by the target in response to a
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch/rfc] regcache_raw_read_as_address() -> regcache_cooked_read_as_ulongest()
2002-08-12 12:51 [patch/rfc] regcache_raw_read_as_address() -> regcache_cooked_read_as_ulongest() Andrew Cagney
2002-08-12 12:57 ` Andrew Cagney
@ 2002-08-12 13:12 ` Daniel Jacobowitz
[not found] ` <1020812202845.ZM934@localhost.localdomain>
1 sibling, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2002-08-12 13:12 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches, Mark Kettenis
On Mon, Aug 12, 2002 at 03:51:38PM -0400, Andrew Cagney wrote:
> Hello,
>
> This patch replaces the function regcache_raw_read_as_address() with the
> pair:
> regcache_cooked_read_as_longest()
> regcache_cooked_read_as_ulongest()
> The two calls to the old ..as_address() being replaced with the ulongest
> version.
>
> I think the change is ok (i386 shows no regressions, the mips doesn't
> use this code :-). I'm just wondering about the names. Perhaps:
> regcache_cooked_read_signed() & regcache_cooked_read_unsigned()?
>
> thoughts?
Hmm, I like _read_signed and _read_unsigned... the _as_longest bit is
implicit.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch/rfc] regcache_raw_read_as_address() -> regcache_cooked_read_as_ulongest()
[not found] ` <1020812202845.ZM934@localhost.localdomain>
@ 2002-08-13 6:46 ` Andrew Cagney
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2002-08-13 6:46 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Daniel Jacobowitz, Mark Kettenis, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1252 bytes --]
> On Aug 12, 4:12pm, Daniel Jacobowitz wrote:
>
>
>> > I think the change is ok (i386 shows no regressions, the mips doesn't
>> > use this code :-). I'm just wondering about the names. Perhaps:
>> > regcache_cooked_read_signed() & regcache_cooked_read_unsigned()?
>> >
>> > thoughts?
>
>>
>> Hmm, I like _read_signed and _read_unsigned... the _as_longest bit is
>> implicit.
>
>
> I agree with Daniel.
Good enough for me.
I took the liberty of revising the exact interface. It uses a reference
parameter, rather than function return, when passing back the result.
The comment:
+/* NOTE: cagney/2002-08-13: At present GDB has no reliable mechanism
+ for indicating when a ``cooked'' register was constructed from
+ invalid or unavailable ``raw'' registers. One fairly easy way of
+ adding such a mechanism would be for the cooked functions to return
+ a register valid indication. Given the possibility of such a
+ change, the extract functions below use a reference parameter,
+ rather than a function result. */
explains why. I should note that this is a somewhat pervasive problem
in GDB, there are few checks to ensure that a register is valid and
those that do, check the raw register cache :-(
enjoy,
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 6251 bytes --]
2002-08-12 Andrew Cagney <cagney@redhat.com>
* regcache.c (regcache_raw_read_as_address): Delete function.
(regcache_cooked_read_signed): New function.
(regcache_cooked_read_unsigned): New function.
* regcache.h (regcache_cooked_read_signed): Declare.
(regcache_cooked_read_unsigned): Declare.
(regcache_raw_read_as_address): Delete declaration.
* blockframe.c (generic_read_register_dummy): Use
regcache_cooked_read_unsigned.
* i386-tdep.c (i386_extract_struct_value_address): Use
regcache_cooked_read_unsigned.
Index: blockframe.c
===================================================================
RCS file: /cvs/src/src/gdb/blockframe.c,v
retrieving revision 1.35
diff -u -r1.35 blockframe.c
--- blockframe.c 9 Aug 2002 18:26:15 -0000 1.35
+++ blockframe.c 13 Aug 2002 13:39:24 -0000
@@ -1215,7 +1215,20 @@
struct regcache *dummy_regs = generic_find_dummy_frame (pc, fp);
if (dummy_regs)
- return regcache_raw_read_as_address (dummy_regs, regno);
+ {
+ /* NOTE: cagney/2002-08-12: Replaced a call to
+ regcache_raw_read_as_address() with a call to
+ regcache_cooked_read_unsigned(). The old, ...as_address
+ function was eventually calling extract_unsigned_integer (via
+ extract_address) to unpack the registers value. The below is
+ doing an unsigned extract so that it is functionally
+ equivalent. The read needs to be cooked as, otherwise, it
+ will never correctly return the value of a register in the
+ [NUM_REGS .. NUM_REGS+NUM_PSEUDO_REGS) range. */
+ ULONGEST val;
+ regcache_cooked_read_unsigned (dummy_regs, regno, &val);
+ return val;
+ }
else
return 0;
}
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.74
diff -u -r1.74 i386-tdep.c
--- i386-tdep.c 12 Aug 2002 19:05:33 -0000 1.74
+++ i386-tdep.c 13 Aug 2002 13:39:25 -0000
@@ -1028,7 +1028,18 @@
static CORE_ADDR
i386_extract_struct_value_address (struct regcache *regcache)
{
- return regcache_raw_read_as_address (regcache, LOW_RETURN_REGNUM);
+ /* NOTE: cagney/2002-08-12: Replaced a call to
+ regcache_raw_read_as_address() with a call to
+ regcache_cooked_read_unsigned(). The old, ...as_address function
+ was eventually calling extract_unsigned_integer (via
+ extract_address) to unpack the registers value. The below is
+ doing an unsigned extract so that it is functionally equivalent.
+ The read needs to be cooked as, otherwise, it will never
+ correctly return the value of a register in the [NUM_REGS
+ .. NUM_REGS+NUM_PSEUDO_REGS) range. */
+ ULONGEST val;
+ regcache_cooked_read_unsigned (regcache, LOW_RETURN_REGNUM, &val);
+ return val;
}
\f
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.50
diff -u -r1.50 regcache.c
--- regcache.c 10 Aug 2002 02:00:16 -0000 1.50
+++ regcache.c 13 Aug 2002 13:39:25 -0000
@@ -366,17 +366,6 @@
return regcache->raw_register_valid_p[regnum];
}
-CORE_ADDR
-regcache_raw_read_as_address (struct regcache *regcache, int regnum)
-{
- char *buf;
- gdb_assert (regcache != NULL);
- gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
- buf = alloca (regcache->descr->sizeof_register[regnum]);
- regcache_raw_read (regcache, regnum, buf);
- return extract_address (buf, regcache->descr->sizeof_register[regnum]);
-}
-
char *
deprecated_grub_regcache_for_registers (struct regcache *regcache)
{
@@ -694,6 +683,32 @@
else
gdbarch_pseudo_register_read (regcache->descr->gdbarch, regcache,
regnum, buf);
+}
+
+void
+regcache_cooked_read_signed (struct regcache *regcache, int regnum,
+ LONGEST *val)
+{
+ char *buf;
+ gdb_assert (regcache != NULL);
+ gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
+ buf = alloca (regcache->descr->sizeof_register[regnum]);
+ regcache_cooked_read (regcache, regnum, buf);
+ (*val) = extract_signed_integer (buf,
+ regcache->descr->sizeof_register[regnum]);
+}
+
+void
+regcache_cooked_read_unsigned (struct regcache *regcache, int regnum,
+ ULONGEST *val)
+{
+ char *buf;
+ gdb_assert (regcache != NULL);
+ gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
+ buf = alloca (regcache->descr->sizeof_register[regnum]);
+ regcache_cooked_read (regcache, regnum, buf);
+ (*val) = extract_unsigned_integer (buf,
+ regcache->descr->sizeof_register[regnum]);
}
/* Write register REGNUM at MYADDR to the target. MYADDR points at
Index: regcache.h
===================================================================
RCS file: /cvs/src/src/gdb/regcache.h,v
retrieving revision 1.12
diff -u -r1.12 regcache.h
--- regcache.h 2 Aug 2002 18:08:31 -0000 1.12
+++ regcache.h 13 Aug 2002 13:39:25 -0000
@@ -39,12 +39,25 @@
void regcache_raw_write (struct regcache *regcache, int rawnum,
const void *buf);
int regcache_valid_p (struct regcache *regcache, int regnum);
-CORE_ADDR regcache_raw_read_as_address (struct regcache *regcache, int rawnum);
/* Transfer a cooked register [0..NUM_REGS+NUM_PSEUDO_REGS). */
void regcache_cooked_read (struct regcache *regcache, int rawnum, void *buf);
void regcache_cooked_write (struct regcache *regcache, int rawnum,
const void *buf);
+
+/* NOTE: cagney/2002-08-13: At present GDB has no reliable mechanism
+ for indicating when a ``cooked'' register was constructed from
+ invalid or unavailable ``raw'' registers. One fairly easy way of
+ adding such a mechanism would be for the cooked functions to return
+ a register valid indication. Given the possibility of such a
+ change, the extract functions below use a reference parameter,
+ rather than a function result. */
+
+/* Read a register as a signed/unsigned quantity. */
+extern void regcache_cooked_read_signed (struct regcache *regcache,
+ int regnum, LONGEST *val);
+extern void regcache_cooked_read_unsigned (struct regcache *regcache,
+ int regnum, ULONGEST *val);
/* Transfer a raw register [0..NUM_REGS) between the regcache and the
target. These functions are called by the target in response to a
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-08-13 13:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-12 12:51 [patch/rfc] regcache_raw_read_as_address() -> regcache_cooked_read_as_ulongest() Andrew Cagney
2002-08-12 12:57 ` Andrew Cagney
2002-08-12 13:12 ` Daniel Jacobowitz
[not found] ` <1020812202845.ZM934@localhost.localdomain>
2002-08-13 6:46 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox