From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2038 invoked by alias); 7 Jun 2007 21:01:04 -0000 Received: (qmail 2026 invoked by uid 22791); 7 Jun 2007 21:01:03 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate8.de.ibm.com (HELO mtagate8.de.ibm.com) (195.212.29.157) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 07 Jun 2007 21:01:00 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate8.de.ibm.com (8.13.8/8.13.8) with ESMTP id l57L0vvg414414 for ; Thu, 7 Jun 2007 21:00:57 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v8.3) with ESMTP id l57L0vrS4141126 for ; Thu, 7 Jun 2007 23:00:57 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l57L0vSv021186 for ; Thu, 7 Jun 2007 23:00:57 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id l57L0vOW021183 for ; Thu, 7 Jun 2007 23:00:57 +0200 Message-Id: <200706072100.l57L0vOW021183@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Thu, 7 Jun 2007 23:00:57 +0200 Subject: [rfc][11/13] Eliminate read_register: Uses in push_dummy_code callbacks To: gdb-patches@sourceware.org Date: Thu, 07 Jun 2007 21:01:00 -0000 From: "Ulrich Weigand" X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-06/txt/msg00090.txt.bz2 Hello, the hppa_hpux_push_dummy_code routine manipulates gobal register state using current_regcache, as the callback doesn't receive a REGCACHE argument (like the push_dummy_call callback does). There doesn't appear to be a reason why the push_dummy_code callback shouldn't also get a REGCACHE argument, just like push_dummy_call, so this is was this patch does. (The patch doesn't actually eliminate any read_register call strictly speaking, but it does eliminate instances of accessing global register state.) Bye, Ulrich ChangeLog: * gdbarch.sh (push_dummy_code): Add REGCACHE argument. * gdbarch.c, gdbarch.h: Regenerate. * infcall.c (generic_push_dummy_code): Add REGCACHE argument. (push_dummy_code): Likewise. Pass it to callee. (call_function_by_hand): Pass current regcache to push_dummy_code. * hppa-hpux-tdep.c (hppa_hpux_push_dummy_code): Add REGCACHE argument. Use it instead of current_regcache. * cris-tdep.c (cris_push_dummy_code): Add REGCACHE argument. * sparc-tdep.c (sparc32_push_dummy_code): Likewise. diff -urNp gdb-orig/gdb/cris-tdep.c gdb-head/gdb/cris-tdep.c --- gdb-orig/gdb/cris-tdep.c 2007-06-06 19:00:38.612871735 +0200 +++ gdb-head/gdb/cris-tdep.c 2007-06-06 19:46:40.824870968 +0200 @@ -868,7 +868,8 @@ cris_push_dummy_code (struct gdbarch *gd CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, - CORE_ADDR *real_pc, CORE_ADDR *bp_addr) + CORE_ADDR *real_pc, CORE_ADDR *bp_addr, + struct regcache *regcache) { /* Allocate space sufficient for a breakpoint. */ sp = (sp - 4) & ~3; diff -urNp gdb-orig/gdb/gdbarch.c gdb-head/gdb/gdbarch.c --- gdb-orig/gdb/gdbarch.c 2007-06-06 19:46:31.156802148 +0200 +++ gdb-head/gdb/gdbarch.c 2007-06-06 19:46:40.882862623 +0200 @@ -2160,13 +2160,13 @@ gdbarch_push_dummy_code_p (struct gdbarc } CORE_ADDR -gdbarch_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr) +gdbarch_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->push_dummy_code != NULL); if (gdbarch_debug >= 2) fprintf_unfiltered (gdb_stdlog, "gdbarch_push_dummy_code called\n"); - return gdbarch->push_dummy_code (gdbarch, sp, funaddr, using_gcc, args, nargs, value_type, real_pc, bp_addr); + return gdbarch->push_dummy_code (gdbarch, sp, funaddr, using_gcc, args, nargs, value_type, real_pc, bp_addr, regcache); } void diff -urNp gdb-orig/gdb/gdbarch.h gdb-head/gdb/gdbarch.h --- gdb-orig/gdb/gdbarch.h 2007-06-06 19:46:31.200795817 +0200 +++ gdb-head/gdb/gdbarch.h 2007-06-06 19:46:40.939854422 +0200 @@ -470,8 +470,8 @@ extern void set_gdbarch_call_dummy_locat extern int gdbarch_push_dummy_code_p (struct gdbarch *gdbarch); -typedef CORE_ADDR (gdbarch_push_dummy_code_ftype) (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr); -extern CORE_ADDR gdbarch_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr); +typedef CORE_ADDR (gdbarch_push_dummy_code_ftype) (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache); +extern CORE_ADDR gdbarch_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache); extern void set_gdbarch_push_dummy_code (struct gdbarch *gdbarch, gdbarch_push_dummy_code_ftype *push_dummy_code); typedef void (gdbarch_print_registers_info_ftype) (struct gdbarch *gdbarch, struct ui_file *file, struct frame_info *frame, int regnum, int all); diff -urNp gdb-orig/gdb/gdbarch.sh gdb-head/gdb/gdbarch.sh --- gdb-orig/gdb/gdbarch.sh 2007-06-06 19:46:31.208794666 +0200 +++ gdb-head/gdb/gdbarch.sh 2007-06-06 19:46:40.996846221 +0200 @@ -472,7 +472,7 @@ M::CORE_ADDR:push_dummy_call:struct valu # DEPRECATED_REGISTER_SIZE can be deleted. v:=:int:deprecated_register_size v::int:call_dummy_location::::AT_ENTRY_POINT::0 -M::CORE_ADDR:push_dummy_code:CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr:sp, funaddr, using_gcc, args, nargs, value_type, real_pc, bp_addr +M::CORE_ADDR:push_dummy_code:CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache:sp, funaddr, using_gcc, args, nargs, value_type, real_pc, bp_addr, regcache m::void:print_registers_info:struct ui_file *file, struct frame_info *frame, int regnum, int all:file, frame, regnum, all::default_print_registers_info::0 M::void:print_float_info:struct ui_file *file, struct frame_info *frame, const char *args:file, frame, args diff -urNp gdb-orig/gdb/hppa-hpux-tdep.c gdb-head/gdb/hppa-hpux-tdep.c --- gdb-orig/gdb/hppa-hpux-tdep.c 2007-06-06 19:41:42.658582118 +0200 +++ gdb-head/gdb/hppa-hpux-tdep.c 2007-06-06 19:46:41.051838308 +0200 @@ -1095,7 +1095,8 @@ hppa_hpux_push_dummy_code (struct gdbarc CORE_ADDR funcaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, - CORE_ADDR *real_pc, CORE_ADDR *bp_addr) + CORE_ADDR *real_pc, CORE_ADDR *bp_addr, + struct regcache *regcache) { CORE_ADDR pc, stubaddr; int argreg = 0; @@ -1113,7 +1114,7 @@ hppa_hpux_push_dummy_code (struct gdbarc /* Intraspace call. */ *bp_addr = hppa_hpux_find_dummy_bpaddr (pc); *real_pc = funcaddr; - regcache_cooked_write_unsigned (current_regcache, HPPA_RP_REGNUM, *bp_addr); + regcache_cooked_write_unsigned (regcache, HPPA_RP_REGNUM, *bp_addr); return sp; } @@ -1191,18 +1192,18 @@ hppa_hpux_push_dummy_code (struct gdbarc if (stubaddr == 0) error (_("Cannot call external function not referenced by application " "(no import stub).\n")); - regcache_cooked_write_unsigned (current_regcache, 22, stubaddr); + regcache_cooked_write_unsigned (regcache, 22, stubaddr); write_memory (sp, (char *)&hppa32_tramp, sizeof (hppa32_tramp)); *bp_addr = hppa_hpux_find_dummy_bpaddr (pc); - regcache_cooked_write_unsigned (current_regcache, 31, *bp_addr); + regcache_cooked_write_unsigned (regcache, 31, *bp_addr); *real_pc = hppa32_hpux_search_dummy_call_sequence (gdbarch, pc, &argreg); if (*real_pc == 0) error (_("Cannot make interspace call from here.")); - regcache_cooked_write_unsigned (current_regcache, argreg, sp); + regcache_cooked_write_unsigned (regcache, argreg, sp); sp += sizeof (hppa32_tramp); } @@ -1218,17 +1219,17 @@ hppa_hpux_push_dummy_code (struct gdbarc /* for hppa64, we don't need to call through a stub; all functions return via a bve. */ - regcache_cooked_write_unsigned (current_regcache, 22, funcaddr); + regcache_cooked_write_unsigned (regcache, 22, funcaddr); write_memory (sp, (char *)&hppa64_tramp, sizeof (hppa64_tramp)); *bp_addr = pc - 4; - regcache_cooked_write_unsigned (current_regcache, 31, *bp_addr); + regcache_cooked_write_unsigned (regcache, 31, *bp_addr); *real_pc = hppa64_hpux_search_dummy_call_sequence (gdbarch, pc, &argreg); if (*real_pc == 0) error (_("Cannot make interspace call from here.")); - regcache_cooked_write_unsigned (current_regcache, argreg, sp); + regcache_cooked_write_unsigned (regcache, argreg, sp); sp += sizeof (hppa64_tramp); } diff -urNp gdb-orig/gdb/infcall.c gdb-head/gdb/infcall.c --- gdb-orig/gdb/infcall.c 2007-06-06 17:25:20.298615000 +0200 +++ gdb-head/gdb/infcall.c 2007-06-06 19:46:41.068835862 +0200 @@ -249,7 +249,8 @@ generic_push_dummy_code (struct gdbarch CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, - CORE_ADDR *real_pc, CORE_ADDR *bp_addr) + CORE_ADDR *real_pc, CORE_ADDR *bp_addr, + struct regcache *regcache) { /* Something here to findout the size of a breakpoint and then allocate space for it on the stack. */ @@ -288,14 +289,17 @@ push_dummy_code (struct gdbarch *gdbarch CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, - CORE_ADDR *real_pc, CORE_ADDR *bp_addr) + CORE_ADDR *real_pc, CORE_ADDR *bp_addr, + struct regcache *regcache) { if (gdbarch_push_dummy_code_p (gdbarch)) return gdbarch_push_dummy_code (gdbarch, sp, funaddr, using_gcc, - args, nargs, value_type, real_pc, bp_addr); + args, nargs, value_type, real_pc, bp_addr, + regcache); else return generic_push_dummy_code (gdbarch, sp, funaddr, using_gcc, - args, nargs, value_type, real_pc, bp_addr); + args, nargs, value_type, real_pc, bp_addr, + regcache); } /* All this stuff with a dummy frame may seem unnecessarily complicated @@ -465,7 +469,7 @@ call_function_by_hand (struct value *fun { sp = push_dummy_code (current_gdbarch, sp, funaddr, using_gcc, args, nargs, values_type, - &real_pc, &bp_addr); + &real_pc, &bp_addr, current_regcache); dummy_addr = sp; } else @@ -473,7 +477,7 @@ call_function_by_hand (struct value *fun dummy_addr = sp; sp = push_dummy_code (current_gdbarch, sp, funaddr, using_gcc, args, nargs, values_type, - &real_pc, &bp_addr); + &real_pc, &bp_addr, current_regcache); } break; case AT_ENTRY_POINT: diff -urNp gdb-orig/gdb/sparc-tdep.c gdb-head/gdb/sparc-tdep.c --- gdb-orig/gdb/sparc-tdep.c 2007-06-06 19:00:38.743852886 +0200 +++ gdb-head/gdb/sparc-tdep.c 2007-06-06 19:46:41.075834855 +0200 @@ -383,7 +383,8 @@ sparc32_push_dummy_code (struct gdbarch CORE_ADDR funcaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, - CORE_ADDR *real_pc, CORE_ADDR *bp_addr) + CORE_ADDR *real_pc, CORE_ADDR *bp_addr, + struct regcache *regcache) { *bp_addr = sp - 4; *real_pc = funcaddr; -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com