From: Michal Ludvig <mludvig@suse.cz>
To: Andrew Cagney <ac131313@redhat.com>
Cc: gdb@sources.redhat.com,
Michael Elizabeth Chastain <mec@shout.net>,
Mark Kettenis <kettenis@chello.nl>
Subject: Re: regcache (Re: GDB respin)
Date: Mon, 10 Feb 2003 21:26:00 -0000 [thread overview]
Message-ID: <3E48190A.1090500@suse.cz> (raw)
In-Reply-To: <3E42A5F8.9080708@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]
Michal Ludvig wrote:
>> I'm about to convert x86-64 target to use regcache, but am not sure
>> what must be done for it. Could someone please briefly explain me what
>> is regcache all about and what must be changed in order to have the
>> target regcache-compilant?
>
> Where previously the code wrote (directly or implicitly) to a global
> buffer, it how is given an explicit object (the regcache).
>
> You can use any *cooked*{read,write}* function you want in regcache.h.
> Typically the transformation is very direct: write_register() ->
> regcache_cooked_write().
>
>> As I was looking to the sources I believe, that only
>> x86_64_store_return_value() and x86_64_extract_return_value() must be
>> modified. Am I right or not?
>
> Per above, yes, I think this is correct. Thanks!
OK, here is the first attempt to use regcache on x86-64 target.
As I run the testsuite on gdb-5.3 it made no difference on the results
and I hope it will improve the mainline a little bit.
Is the patch OK to commit?
Michal Ludvig
--
* SuSE CR, s.r.o * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz
[-- Attachment #2: regcache-head-1.diff --]
[-- Type: text/plain, Size: 7058 bytes --]
2003-02-10 Michal Ludvig <mludvig@suse.cz>
* x86-64-tdep.c (x86_64_extract_return_value)
(x86_64_store_return_value): Use regcache instead of regbuf.
(x86_64_gdbarch_init): Change related set_gdbarch_* functions.
* x86-64-linux-nat.c (fill_gregset): Use regcache.
Index: x86-64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v
retrieving revision 1.47
diff -u -p -r1.47 x86-64-tdep.c
--- x86-64-tdep.c 6 Feb 2003 23:20:52 -0000 1.47
+++ x86-64-tdep.c 10 Feb 2003 21:20:20 -0000
@@ -559,7 +559,8 @@ x86_64_use_struct_convention (int gcc_p,
into VALBUF. */
void
-x86_64_extract_return_value (struct type *type, char *regbuf, char *valbuf)
+x86_64_extract_return_value (struct type *type, struct regcache *regcache,
+ void *valbuf)
{
enum x86_64_reg_class class[MAX_CLASSES];
int n = classify_argument (type, class, 0);
@@ -576,7 +577,7 @@ x86_64_extract_return_value (struct type
needed_intregs > RET_INT_REGS || needed_sseregs > RET_SSE_REGS)
{ /* memory class */
CORE_ADDR addr;
- memcpy (&addr, regbuf, REGISTER_RAW_SIZE (RAX_REGNUM));
+ regcache_raw_read (regcache, RAX_REGNUM, &addr);
read_memory (addr, valbuf, TYPE_LENGTH (type));
return;
}
@@ -590,41 +591,40 @@ x86_64_extract_return_value (struct type
case X86_64_NO_CLASS:
break;
case X86_64_INTEGER_CLASS:
- memcpy (valbuf + offset,
- regbuf + REGISTER_BYTE (ret_int_r[(intreg + 1) / 2]),
- 8);
+ regcache_cooked_read (regcache, ret_int_r[(intreg + 1) / 2],
+ (char *) valbuf + offset);
offset += 8;
intreg += 2;
break;
case X86_64_INTEGERSI_CLASS:
- memcpy (valbuf + offset,
- regbuf + REGISTER_BYTE (ret_int_r[intreg / 2]), 4);
+ regcache_cooked_read_part (regcache, ret_int_r[intreg / 2],
+ 0, 4, (char *) valbuf + offset);
offset += 8;
intreg++;
break;
case X86_64_SSEDF_CLASS:
case X86_64_SSESF_CLASS:
case X86_64_SSE_CLASS:
- memcpy (valbuf + offset,
- regbuf + REGISTER_BYTE (ret_sse_r[(ssereg + 1) / 2]),
- 8);
+ regcache_cooked_read_part (regcache,
+ ret_sse_r[(ssereg + 1) / 2], 0, 8,
+ (char *) valbuf + offset);
offset += 8;
ssereg += 2;
break;
case X86_64_SSEUP_CLASS:
- memcpy (valbuf + offset + 8,
- regbuf + REGISTER_BYTE (ret_sse_r[ssereg / 2]), 8);
+ regcache_cooked_read_part (regcache, ret_sse_r[ssereg / 2],
+ 0, 8, (char *) valbuf + offset);
offset += 8;
ssereg++;
break;
case X86_64_X87_CLASS:
- memcpy (valbuf + offset, regbuf + REGISTER_BYTE (FP0_REGNUM),
- 8);
+ regcache_cooked_read_part (regcache, FP0_REGNUM,
+ 0, 8, (char *) valbuf + offset);
offset += 8;
break;
case X86_64_X87UP_CLASS:
- memcpy (valbuf + offset,
- regbuf + REGISTER_BYTE (FP0_REGNUM) + 8, 8);
+ regcache_cooked_read_part (regcache, FP0_REGNUM,
+ 8, 2, (char *) valbuf + offset);
offset += 8;
break;
case X86_64_MEMORY_CLASS:
@@ -749,7 +749,8 @@ x86_64_push_arguments (int nargs, struct
/* Write into the appropriate registers a function return value stored
in VALBUF of type TYPE, given in virtual format. */
void
-x86_64_store_return_value (struct type *type, char *valbuf)
+x86_64_store_return_value (struct type *type, struct regcache *regcache,
+ const void *valbuf)
{
int len = TYPE_LENGTH (type);
@@ -760,8 +761,7 @@ x86_64_store_return_value (struct type *
&& TARGET_LONG_DOUBLE_FORMAT == &floatformat_i387_ext)
{
/* Copy straight over. */
- deprecated_write_register_bytes (REGISTER_BYTE (FP0_REGNUM), valbuf,
- FPU_REG_RAW_SIZE);
+ regcache_cooked_write (regcache, FP0_REGNUM, valbuf);
}
else
{
@@ -774,8 +774,8 @@ x86_64_store_return_value (struct type *
it is the best we can do. */
val = extract_floating (valbuf, TYPE_LENGTH (type));
floatformat_from_doublest (&floatformat_i387_ext, &val, buf);
- deprecated_write_register_bytes (REGISTER_BYTE (FP0_REGNUM), buf,
- FPU_REG_RAW_SIZE);
+ regcache_cooked_write_part (regcache, FP0_REGNUM,
+ 0, FPU_REG_RAW_SIZE, buf);
}
}
else
@@ -784,13 +784,13 @@ x86_64_store_return_value (struct type *
int high_size = REGISTER_RAW_SIZE (1);
if (len <= low_size)
- deprecated_write_register_bytes (REGISTER_BYTE (0), valbuf, len);
+ regcache_cooked_write_part (regcache, 0, 0, len, valbuf);
else if (len <= (low_size + high_size))
{
- deprecated_write_register_bytes (REGISTER_BYTE (0), valbuf,
- low_size);
- deprecated_write_register_bytes (REGISTER_BYTE (1),
- valbuf + low_size, len - low_size);
+ regcache_cooked_write_part (regcache, 0, 0, low_size, valbuf);
+ regcache_cooked_write_part (regcache, 1, 0,
+ len - low_size,
+ (const char *) valbuf + low_size);
}
else
internal_error (__FILE__, __LINE__,
@@ -979,18 +979,13 @@ x86_64_init_abi (struct gdbarch_info inf
/* FIXME: kettenis/20021026: Should we set parm_boundary to 64 here? */
set_gdbarch_read_fp (gdbarch, cfi_read_fp);
- /* FIXME: kettenis/20021026: Should be undeprecated. */
- set_gdbarch_extract_return_value (gdbarch, legacy_extract_return_value);
- set_gdbarch_deprecated_extract_return_value (gdbarch,
- x86_64_extract_return_value);
+ set_gdbarch_extract_return_value (gdbarch, x86_64_extract_return_value);
+
set_gdbarch_push_arguments (gdbarch, x86_64_push_arguments);
set_gdbarch_push_return_address (gdbarch, x86_64_push_return_address);
set_gdbarch_pop_frame (gdbarch, x86_64_pop_frame);
set_gdbarch_store_struct_return (gdbarch, x86_64_store_struct_return);
- /* FIXME: kettenis/20021026: Should be undeprecated. */
- set_gdbarch_store_return_value (gdbarch, legacy_store_return_value);
- set_gdbarch_deprecated_store_return_value (gdbarch,
- x86_64_store_return_value);
+ set_gdbarch_store_return_value (gdbarch, x86_64_store_return_value);
/* Override, since this is handled by x86_64_extract_return_value. */
set_gdbarch_extract_struct_value_address (gdbarch, NULL);
set_gdbarch_use_struct_convention (gdbarch, x86_64_use_struct_convention);
Index: x86-64-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-linux-nat.c,v
retrieving revision 1.20
diff -u -p -r1.20 x86-64-linux-nat.c
--- x86-64-linux-nat.c 14 Jan 2003 00:49:04 -0000 1.20
+++ x86-64-linux-nat.c 10 Feb 2003 21:20:20 -0000
@@ -158,7 +158,7 @@ fill_gregset (elf_gregset_t * gregsetp,
for (i = 0; i < x86_64_num_gregs; i++)
if ((regno == -1 || regno == i))
- deprecated_read_register_gen (i, (char *) (regp + x86_64_regmap[i]));
+ regcache_collect (i, (char *) (regp + x86_64_regmap[i]));
}
/* Fetch all general-purpose registers from process/thread TID and
next prev parent reply other threads:[~2003-02-10 21:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-03 16:15 GDB respin Michael Elizabeth Chastain
2003-02-03 17:14 ` Andrew Cagney
2003-02-03 18:08 ` Elena Zannoni
2003-02-06 14:30 ` regcache (Re: GDB respin) Michal Ludvig
2003-02-06 18:14 ` Andrew Cagney
2003-02-06 23:24 ` [PATCH] " Mark Kettenis
2003-02-07 15:46 ` Michal Ludvig
2003-02-09 10:20 ` Andrew Cagney
2003-02-10 21:26 ` Michal Ludvig [this message]
2003-02-10 22:42 ` Mark Kettenis
2003-02-11 16:31 ` Andrew Cagney
2003-02-11 23:12 ` Michal Ludvig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3E48190A.1090500@suse.cz \
--to=mludvig@suse.cz \
--cc=ac131313@redhat.com \
--cc=gdb@sources.redhat.com \
--cc=kettenis@chello.nl \
--cc=mec@shout.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox