From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10707 invoked by alias); 13 May 2007 12:29:55 -0000 Received: (qmail 10696 invoked by uid 22791); 13 May 2007 12:29:53 -0000 X-Spam-Check-By: sourceware.org Received: from mtagate3.de.ibm.com (HELO mtagate3.de.ibm.com) (195.212.29.152) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 13 May 2007 12:29:45 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate3.de.ibm.com (8.13.8/8.13.8) with ESMTP id l4DCTgBL125110 for ; Sun, 13 May 2007 12:29:42 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 l4DCTgoY4010130 for ; Sun, 13 May 2007 14:29:42 +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 l4DCTfaM018877 for ; Sun, 13 May 2007 14:29:41 +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 l4DCTfi9018874 for ; Sun, 13 May 2007 14:29:41 +0200 Message-Id: <200705131229.l4DCTfi9018874@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Sun, 13 May 2007 14:29:41 +0200 Subject: [rfc/rft] Eliminate gdbarch_read_sp callback function To: gdb-patches@sourceware.org Date: Sun, 13 May 2007 12:29: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-05/txt/msg00223.txt.bz2 Hello, this patch moves the last remaining implementations of the gdbarch_read_sp callback over to gdbarch_unwind_sp, and removes the callback. The avr-tdep.c and score-tdep.c conversions are straightfoward; but I'm not completely sure about the mips-tdep.c. The old read_sp implementation used to read the real MIPS_SP_REGNUM, but the unwind_pc implementation unwinds the pseudo NUM_REGS + mips_regnum (gdbarch)->pc. The patch implements unwind_sp using the pseudo NUM_REGS + MIPS_SP_REGNUM as well. Dan, you've been working on mips lately -- do you think this is the correct choice? Any chance you could run a test? Thanks! Tested only by making sure the affected targets still compile. Any comments? Do you think this is OK? Bye, Ulrich ChangeLog: * gdbarch.sh (read_sp): Remove. * gdbarch.c, gdbarch.h: Regenerate. * frame.c (frame_sp_unwind): Do not call TARGET_READ_SP. * avr-tdep.c (avr_read_sp): Remove. (avr_unwind_sp): New function. (avr_gdbarch_init): Install unwind_sp instead of read_sp callback. * mips-tdep.c (mips_read_sp): Remove. (mips_unwind_sp): New function. (mips_gdbarch_init): Install unwind_sp instead of read_sp callback. * score-tdep.c (score_read_unsigned_register): Remove. (score_read_sp): Remove. (score_unwind_sp): New function. (score_gdbarch_init): Install unwind_sp instead of read_sp callback. diff -urNp gdb-orig/gdb/avr-tdep.c gdb-head/gdb/avr-tdep.c --- gdb-orig/gdb/avr-tdep.c 2007-05-06 22:28:28.000000000 +0200 +++ gdb-head/gdb/avr-tdep.c 2007-05-13 14:00:46.591916571 +0200 @@ -337,15 +337,6 @@ avr_write_pc (CORE_ADDR val, ptid_t ptid inferior_ptid = save_ptid; } -static CORE_ADDR -avr_read_sp (void) -{ - ULONGEST sp; - - regcache_cooked_read_unsigned (current_regcache, AVR_SP_REGNUM, &sp); - return (avr_make_saddr (sp)); -} - static int avr_scan_arg_moves (int vpc, unsigned char *prologue) { @@ -943,6 +934,16 @@ avr_unwind_pc (struct gdbarch *gdbarch, return avr_make_iaddr (pc); } +static CORE_ADDR +avr_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame) +{ + ULONGEST sp; + + frame_unwind_unsigned_register (next_frame, AVR_SP_REGNUM, &sp); + + return avr_make_saddr (sp); +} + /* Given a GDB frame, determine the address of the calling function's frame. This will be used to create a new GDB frame struct. */ @@ -1274,7 +1275,6 @@ avr_gdbarch_init (struct gdbarch_info in set_gdbarch_read_pc (gdbarch, avr_read_pc); set_gdbarch_write_pc (gdbarch, avr_write_pc); - set_gdbarch_read_sp (gdbarch, avr_read_sp); set_gdbarch_num_regs (gdbarch, AVR_NUM_REGS); @@ -1303,6 +1303,7 @@ avr_gdbarch_init (struct gdbarch_info in set_gdbarch_unwind_dummy_id (gdbarch, avr_unwind_dummy_id); set_gdbarch_unwind_pc (gdbarch, avr_unwind_pc); + set_gdbarch_unwind_sp (gdbarch, avr_unwind_sp); return gdbarch; } diff -urNp gdb-orig/gdb/frame.c gdb-head/gdb/frame.c --- gdb-orig/gdb/frame.c 2007-05-06 21:06:21.000000000 +0200 +++ gdb-head/gdb/frame.c 2007-05-13 13:24:13.950824660 +0200 @@ -1712,10 +1712,6 @@ frame_sp_unwind (struct frame_info *next frame inner-most address. */ if (gdbarch_unwind_sp_p (current_gdbarch)) return gdbarch_unwind_sp (current_gdbarch, next_frame); - /* Things are looking grim. If it's the inner-most frame and there - is a TARGET_READ_SP, then that can be used. */ - if (next_frame->level < 0 && TARGET_READ_SP_P ()) - return TARGET_READ_SP (); /* Now things are really are grim. Hope that the value returned by the SP_REGNUM register is meaningful. */ if (SP_REGNUM >= 0) diff -urNp gdb-orig/gdb/gdbarch.c gdb-head/gdb/gdbarch.c --- gdb-orig/gdb/gdbarch.c 2007-05-11 21:55:53.000000000 +0200 +++ gdb-head/gdb/gdbarch.c 2007-05-13 13:24:14.010816025 +0200 @@ -148,7 +148,6 @@ struct gdbarch int char_signed; gdbarch_read_pc_ftype *read_pc; gdbarch_write_pc_ftype *write_pc; - gdbarch_read_sp_ftype *read_sp; gdbarch_virtual_frame_pointer_ftype *virtual_frame_pointer; gdbarch_pseudo_register_read_ftype *pseudo_register_read; gdbarch_pseudo_register_write_ftype *pseudo_register_write; @@ -275,7 +274,6 @@ struct gdbarch startup_gdbarch = 1, /* char_signed */ 0, /* read_pc */ 0, /* write_pc */ - 0, /* read_sp */ 0, /* virtual_frame_pointer */ 0, /* pseudo_register_read */ 0, /* pseudo_register_write */ @@ -531,7 +529,6 @@ verify_gdbarch (struct gdbarch *current_ current_gdbarch->char_signed = 1; /* Skip verify of read_pc, has predicate */ /* Skip verify of write_pc, invalid_p == 0 */ - /* Skip verify of read_sp, has predicate */ /* Skip verify of virtual_frame_pointer, invalid_p == 0 */ /* Skip verify of pseudo_register_read, has predicate */ /* Skip verify of pseudo_register_write, has predicate */ @@ -1332,24 +1329,6 @@ gdbarch_dump (struct gdbarch *current_gd fprintf_unfiltered (file, "gdbarch_dump: read_pc = <0x%lx>\n", (long) current_gdbarch->read_pc); -#ifdef TARGET_READ_SP_P - fprintf_unfiltered (file, - "gdbarch_dump: %s # %s\n", - "TARGET_READ_SP_P()", - XSTRING (TARGET_READ_SP_P ())); -#endif - fprintf_unfiltered (file, - "gdbarch_dump: gdbarch_read_sp_p() = %d\n", - gdbarch_read_sp_p (current_gdbarch)); -#ifdef TARGET_READ_SP - fprintf_unfiltered (file, - "gdbarch_dump: %s # %s\n", - "TARGET_READ_SP()", - XSTRING (TARGET_READ_SP ())); -#endif - fprintf_unfiltered (file, - "gdbarch_dump: read_sp = <0x%lx>\n", - (long) current_gdbarch->read_sp); #ifdef REGISTER_BYTES_OK_P fprintf_unfiltered (file, "gdbarch_dump: %s # %s\n", @@ -1909,30 +1888,6 @@ set_gdbarch_write_pc (struct gdbarch *gd gdbarch->write_pc = write_pc; } -int -gdbarch_read_sp_p (struct gdbarch *gdbarch) -{ - gdb_assert (gdbarch != NULL); - return gdbarch->read_sp != NULL; -} - -CORE_ADDR -gdbarch_read_sp (struct gdbarch *gdbarch) -{ - gdb_assert (gdbarch != NULL); - gdb_assert (gdbarch->read_sp != NULL); - if (gdbarch_debug >= 2) - fprintf_unfiltered (gdb_stdlog, "gdbarch_read_sp called\n"); - return gdbarch->read_sp (); -} - -void -set_gdbarch_read_sp (struct gdbarch *gdbarch, - gdbarch_read_sp_ftype read_sp) -{ - gdbarch->read_sp = read_sp; -} - void gdbarch_virtual_frame_pointer (struct gdbarch *gdbarch, CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset) { diff -urNp gdb-orig/gdb/gdbarch.h gdb-head/gdb/gdbarch.h --- gdb-orig/gdb/gdbarch.h 2007-05-11 21:55:53.000000000 +0200 +++ gdb-head/gdb/gdbarch.h 2007-05-13 13:24:14.066807965 +0200 @@ -287,33 +287,6 @@ extern void set_gdbarch_write_pc (struct #define TARGET_WRITE_PC(val, ptid) (gdbarch_write_pc (current_gdbarch, val, ptid)) #endif -/* UNWIND_SP is a direct replacement for TARGET_READ_SP. */ - -#if defined (TARGET_READ_SP) -/* Legacy for systems yet to multi-arch TARGET_READ_SP */ -#if !defined (TARGET_READ_SP_P) -#define TARGET_READ_SP_P() (1) -#endif -#endif - -extern int gdbarch_read_sp_p (struct gdbarch *gdbarch); -#if !defined (GDB_TM_FILE) && defined (TARGET_READ_SP_P) -#error "Non multi-arch definition of TARGET_READ_SP" -#endif -#if !defined (TARGET_READ_SP_P) -#define TARGET_READ_SP_P() (gdbarch_read_sp_p (current_gdbarch)) -#endif - -typedef CORE_ADDR (gdbarch_read_sp_ftype) (void); -extern CORE_ADDR gdbarch_read_sp (struct gdbarch *gdbarch); -extern void set_gdbarch_read_sp (struct gdbarch *gdbarch, gdbarch_read_sp_ftype *read_sp); -#if !defined (GDB_TM_FILE) && defined (TARGET_READ_SP) -#error "Non multi-arch definition of TARGET_READ_SP" -#endif -#if !defined (TARGET_READ_SP) -#define TARGET_READ_SP() (gdbarch_read_sp (current_gdbarch)) -#endif - /* Function for getting target's idea of a frame pointer. FIXME: GDB's whole scheme for dealing with "frames" and "frame pointers" needs a serious shakedown. */ diff -urNp gdb-orig/gdb/gdbarch.sh gdb-head/gdb/gdbarch.sh --- gdb-orig/gdb/gdbarch.sh 2007-05-11 21:55:53.000000000 +0200 +++ gdb-head/gdb/gdbarch.sh 2007-05-13 13:24:14.111801489 +0200 @@ -421,8 +421,6 @@ v:TARGET_CHAR_SIGNED:int:char_signed:::1 # F:TARGET_READ_PC:CORE_ADDR:read_pc:ptid_t ptid:ptid f:TARGET_WRITE_PC:void:write_pc:CORE_ADDR val, ptid_t ptid:val, ptid:0:generic_target_write_pc::0 -# UNWIND_SP is a direct replacement for TARGET_READ_SP. -F:TARGET_READ_SP:CORE_ADDR:read_sp:void # Function for getting target's idea of a frame pointer. FIXME: GDB's # whole scheme for dealing with "frames" and "frame pointers" needs a # serious shakedown. diff -urNp gdb-orig/gdb/mips-tdep.c gdb-head/gdb/mips-tdep.c --- gdb-orig/gdb/mips-tdep.c 2007-05-09 19:42:36.000000000 +0200 +++ gdb-head/gdb/mips-tdep.c 2007-05-13 13:24:14.171792854 +0200 @@ -746,13 +746,6 @@ mips_register_type (struct gdbarch *gdba } } -/* TARGET_READ_SP -- Remove useless bits from the stack pointer. */ - -static CORE_ADDR -mips_read_sp (void) -{ - return read_signed_register (MIPS_SP_REGNUM); -} /* Should the upper word of 64-bit addresses be zeroed? */ enum auto_boolean mask_address_var = AUTO_BOOLEAN_AUTO; @@ -838,6 +831,12 @@ mips_unwind_pc (struct gdbarch *gdbarch, NUM_REGS + mips_regnum (gdbarch)->pc); } +static CORE_ADDR +mips_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame) +{ + return frame_unwind_register_signed (next_frame, NUM_REGS + MIPS_SP_REGNUM); +} + /* Assuming NEXT_FRAME->prev is a dummy, return the frame ID of that dummy frame. The frame ID's base needs to match the TOS value saved by save_dummy_frame_tos(), and the PC match the dummy frame's @@ -5104,7 +5103,6 @@ mips_gdbarch_init (struct gdbarch_info i set_gdbarch_read_pc (gdbarch, mips_read_pc); set_gdbarch_write_pc (gdbarch, mips_write_pc); - set_gdbarch_read_sp (gdbarch, mips_read_sp); /* Add/remove bits from an address. The MIPS needs be careful to ensure that all 32 bit addresses are sign extended to 64 bits. */ @@ -5112,6 +5110,7 @@ mips_gdbarch_init (struct gdbarch_info i /* Unwind the frame. */ set_gdbarch_unwind_pc (gdbarch, mips_unwind_pc); + set_gdbarch_unwind_sp (gdbarch, mips_unwind_sp); set_gdbarch_unwind_dummy_id (gdbarch, mips_unwind_dummy_id); /* Map debug register numbers onto internal register numbers. */ diff -urNp gdb-orig/gdb/score-tdep.c gdb-head/gdb/score-tdep.c --- gdb-orig/gdb/score-tdep.c 2007-05-05 00:37:10.000000000 +0200 +++ gdb-head/gdb/score-tdep.c 2007-05-13 13:24:14.213786809 +0200 @@ -190,24 +190,16 @@ score_register_type (struct gdbarch *gdb return builtin_type_uint32; } -static LONGEST -score_read_unsigned_register (int regnum) -{ - LONGEST val; - regcache_cooked_read_unsigned (current_regcache, regnum, &val); - return val; -} - static CORE_ADDR -score_read_sp (void) +score_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { - return score_read_unsigned_register (SCORE_SP_REGNUM); + return frame_unwind_register_unsigned (next_frame, SCORE_PC_REGNUM); } static CORE_ADDR -score_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) +score_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame) { - return frame_unwind_register_unsigned (next_frame, SCORE_PC_REGNUM); + return frame_unwind_register_unsigned (next_frame, SCORE_SP_REGNUM); } static const char * @@ -880,8 +872,8 @@ score_gdbarch_init (struct gdbarch_info set_gdbarch_register_type (gdbarch, score_register_type); set_gdbarch_frame_align (gdbarch, score_frame_align); set_gdbarch_inner_than (gdbarch, core_addr_lessthan); - set_gdbarch_read_sp (gdbarch, score_read_sp); set_gdbarch_unwind_pc (gdbarch, score_unwind_pc); + set_gdbarch_unwind_sp (gdbarch, score_unwind_sp); set_gdbarch_print_insn (gdbarch, score_print_insn); set_gdbarch_skip_prologue (gdbarch, score_skip_prologue); set_gdbarch_in_function_epilogue_p (gdbarch, score_in_function_epilogue_p); -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com