From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19303 invoked by alias); 10 Feb 2003 21:26:37 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 19296 invoked from network); 10 Feb 2003 21:26:36 -0000 Received: from unknown (HELO kerberos.suse.cz) (195.47.106.10) by 172.16.49.205 with SMTP; 10 Feb 2003 21:26:36 -0000 Received: from chimera.suse.cz (chimera.suse.cz [10.20.0.2]) by kerberos.suse.cz (SuSE SMTP server) with ESMTP id 953BE59D350; Mon, 10 Feb 2003 22:26:35 +0100 (CET) Received: from suse.cz (naga.suse.cz [10.20.1.16]) by chimera.suse.cz (8.11.0/8.11.0/SuSE Linux 8.11.0-0.4) with ESMTP id h1ALQZ419375; Mon, 10 Feb 2003 22:26:35 +0100 X-Authentication-Warning: chimera.suse.cz: Host naga.suse.cz [10.20.1.16] claimed to be suse.cz Message-ID: <3E48190A.1090500@suse.cz> Date: Mon, 10 Feb 2003 21:26:00 -0000 From: Michal Ludvig Organization: SuSE CR User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: cs, cz, en MIME-Version: 1.0 To: Andrew Cagney Cc: gdb@sources.redhat.com, Michael Elizabeth Chastain , Mark Kettenis Subject: Re: regcache (Re: GDB respin) References: <200302031615.h13GFVP26477@duracef.shout.net> <3E3EA35D.3080300@redhat.com> <3E427169.5010702@suse.cz> <3E42A5F8.9080708@redhat.com> In-Reply-To: <3E42A5F8.9080708@redhat.com> Content-Type: multipart/mixed; boundary="------------000407000709060905060300" X-SW-Source: 2003-02/txt/msg00183.txt.bz2 This is a multi-part message in MIME format. --------------000407000709060905060300 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1118 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 --------------000407000709060905060300 Content-Type: text/plain; name="regcache-head-1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="regcache-head-1.diff" Content-length: 7058 2003-02-10 Michal Ludvig * 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 --------------000407000709060905060300--