From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15411 invoked by alias); 17 Oct 2007 13:36:52 -0000 Received: (qmail 15401 invoked by uid 22791); 17 Oct 2007 13:36:49 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 17 Oct 2007 13:36:44 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 8FADB981F1 for ; Wed, 17 Oct 2007 13:36:42 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 3B187980A5 for ; Wed, 17 Oct 2007 13:36:42 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.68) (envelope-from ) id 1Ii94j-0003D7-C5 for gdb-patches@sourceware.org; Wed, 17 Oct 2007 09:36:41 -0400 Date: Wed, 17 Oct 2007 14:03:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Subject: [commit] Remove one frame register unwind method Message-ID: <20071017133641.GA11954@caradoc.them.org> Mail-Followup-To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.15 (2007-04-09) X-IsSubscribed: yes 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-10/txt/msg00438.txt.bz2 There are a wide variety of register access functions and it's not always clear what the difference between them is. This patch removes the most confusing and least useful one of the bunch: -/* Use frame_unwind_register_signed. */ -extern void frame_unwind_unsigned_register (struct frame_info *frame, - int regnum, ULONGEST *val); The comment's right, except for the typo. frame_unwind_register_unsigned returns a ULONGEST instead of setting it by value and there's no reason not to use it. So I've obeyed the comment and replaced frame_unwind_unsigned_register everywhere it was used. I proofread this twice and compiled all the modified files. Amusingly the uses in the manual were wrong; further evidence the routine was not necessary. I also tested on x86_64-linux, although that was not affected. I'd have to set up new simulators to test any of the modified platforms. Checked in. -- Daniel Jacobowitz CodeSourcery 2007-10-17 Daniel Jacobowitz * frame.c (frame_unwind_unsigned_register): Delete. (frame_sp_unwind): Use frame_unwind_register_unsigned instead. * frame.h (frame_unwind_unsigned_register): Delete prototype. * alpha-linux-tdep.c, alpha-mdebug-tdep.c, alpha-tdep.c, avr-tdep.c, cris-tdep.c, frv-tdep.c, m68hc11-tdep.c, mn10300-tdep.c, mt-tdep.c: Replace frame_unwind_unsigned_register with frame_unwind_register_unsigned. * gdbint.texinfo (Target Conditionals): Use frame_unwind_register_unsigned in examples instead of frame_unwind_unsigned_register. --- gdb/alpha-linux-tdep.c | 2 +- gdb/alpha-mdebug-tdep.c | 2 +- gdb/alpha-tdep.c | 6 +++--- gdb/avr-tdep.c | 12 ++++++------ gdb/cris-tdep.c | 19 +++++++++---------- gdb/doc/gdbint.texinfo | 4 ++-- gdb/frame.c | 19 ++----------------- gdb/frame.h | 4 ---- gdb/frv-tdep.c | 4 ++-- gdb/m68hc11-tdep.c | 11 +++++------ gdb/mn10300-tdep.c | 4 ++-- gdb/mt-tdep.c | 8 ++++---- 12 files changed, 37 insertions(+), 58 deletions(-) Index: src/gdb/alpha-linux-tdep.c =================================================================== --- src.orig/gdb/alpha-linux-tdep.c 2007-10-16 14:55:44.000000000 -0400 +++ src/gdb/alpha-linux-tdep.c 2007-10-16 15:02:15.000000000 -0400 @@ -105,7 +105,7 @@ alpha_linux_sigcontext_addr (struct fram long off; pc = frame_pc_unwind (next_frame); - frame_unwind_unsigned_register (next_frame, ALPHA_SP_REGNUM, &sp); + sp = frame_unwind_register_unsigned (next_frame, ALPHA_SP_REGNUM); off = alpha_linux_sigtramp_offset (pc); gdb_assert (off >= 0); Index: src/gdb/alpha-mdebug-tdep.c =================================================================== --- src.orig/gdb/alpha-mdebug-tdep.c 2007-10-16 14:55:44.000000000 -0400 +++ src/gdb/alpha-mdebug-tdep.c 2007-10-16 15:02:04.000000000 -0400 @@ -204,7 +204,7 @@ alpha_mdebug_frame_unwind_cache (struct info->saved_regs = frame_obstack_zalloc (SIZEOF_FRAME_SAVED_REGS); /* The VFP of the frame is at FRAME_REG+FRAME_OFFSET. */ - frame_unwind_unsigned_register (next_frame, PROC_FRAME_REG (proc_desc), &vfp); + vfp = frame_unwind_register_unsigned (next_frame, PROC_FRAME_REG (proc_desc)); vfp += PROC_FRAME_OFFSET (info->proc_desc); info->vfp = vfp; Index: src/gdb/alpha-tdep.c =================================================================== --- src.orig/gdb/alpha-tdep.c 2007-10-16 14:55:44.000000000 -0400 +++ src/gdb/alpha-tdep.c 2007-10-16 15:01:52.000000000 -0400 @@ -1151,7 +1151,7 @@ alpha_heuristic_frame_unwind_cache (stru return_reg = ALPHA_RA_REGNUM; info->return_reg = return_reg; - frame_unwind_unsigned_register (next_frame, frame_reg, &val); + val = frame_unwind_register_unsigned (next_frame, frame_reg); info->vfp = val + frame_size; /* Convert offsets to absolute addresses. See above about adding @@ -1278,7 +1278,7 @@ static struct frame_id alpha_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame) { ULONGEST base; - frame_unwind_unsigned_register (next_frame, ALPHA_SP_REGNUM, &base); + base = frame_unwind_register_unsigned (next_frame, ALPHA_SP_REGNUM); return frame_id_build (base, frame_pc_unwind (next_frame)); } @@ -1286,7 +1286,7 @@ static CORE_ADDR alpha_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { ULONGEST pc; - frame_unwind_unsigned_register (next_frame, ALPHA_PC_REGNUM, &pc); + pc = frame_unwind_register_unsigned (next_frame, ALPHA_PC_REGNUM); return pc; } Index: src/gdb/avr-tdep.c =================================================================== --- src.orig/gdb/avr-tdep.c 2007-10-16 14:55:44.000000000 -0400 +++ src/gdb/avr-tdep.c 2007-10-16 15:01:24.000000000 -0400 @@ -904,8 +904,8 @@ avr_frame_unwind_cache (struct frame_inf /* The SP was moved to the FP. This indicates that a new frame was created. Get THIS frame's FP value by unwinding it from the next frame. */ - frame_unwind_unsigned_register (next_frame, AVR_FP_REGNUM, &this_base); - frame_unwind_unsigned_register (next_frame, AVR_FP_REGNUM+1, &high_base); + this_base = frame_unwind_register_unsigned (next_frame, AVR_FP_REGNUM); + high_base = frame_unwind_register_unsigned (next_frame, AVR_FP_REGNUM+1); this_base += (high_base << 8); /* The FP points at the last saved register. Adjust the FP back @@ -916,7 +916,7 @@ avr_frame_unwind_cache (struct frame_inf { /* Assume that the FP is this frame's SP but with that pushed stack space added back. */ - frame_unwind_unsigned_register (next_frame, AVR_SP_REGNUM, &this_base); + this_base = frame_unwind_register_unsigned (next_frame, AVR_SP_REGNUM); prev_sp = this_base + info->size; } @@ -954,7 +954,7 @@ avr_unwind_pc (struct gdbarch *gdbarch, { ULONGEST pc; - frame_unwind_unsigned_register (next_frame, AVR_PC_REGNUM, &pc); + pc = frame_unwind_register_unsigned (next_frame, AVR_PC_REGNUM); return avr_make_iaddr (pc); } @@ -964,7 +964,7 @@ avr_unwind_sp (struct gdbarch *gdbarch, { ULONGEST sp; - frame_unwind_unsigned_register (next_frame, AVR_SP_REGNUM, &sp); + sp = frame_unwind_register_unsigned (next_frame, AVR_SP_REGNUM); return avr_make_saddr (sp); } @@ -1095,7 +1095,7 @@ avr_unwind_dummy_id (struct gdbarch *gdb { ULONGEST base; - frame_unwind_unsigned_register (next_frame, AVR_SP_REGNUM, &base); + base = frame_unwind_register_unsigned (next_frame, AVR_SP_REGNUM); return frame_id_build (avr_make_saddr (base), frame_pc_unwind (next_frame)); } Index: src/gdb/cris-tdep.c =================================================================== --- src.orig/gdb/cris-tdep.c 2007-10-16 14:55:44.000000000 -0400 +++ src/gdb/cris-tdep.c 2007-10-16 15:00:27.000000000 -0400 @@ -1338,8 +1338,7 @@ cris_scan_prologue (CORE_ADDR pc, struct /* The SP was moved to the FP. This indicates that a new frame was created. Get THIS frame's FP value by unwinding it from the next frame. */ - frame_unwind_unsigned_register (next_frame, CRIS_FP_REGNUM, - &this_base); + this_base = frame_unwind_register_unsigned (next_frame, CRIS_FP_REGNUM); info->base = this_base; info->saved_regs[CRIS_FP_REGNUM].addr = info->base; @@ -1352,8 +1351,8 @@ cris_scan_prologue (CORE_ADDR pc, struct ULONGEST this_base; /* Assume that the FP is this frame's SP but with that pushed stack space added back. */ - frame_unwind_unsigned_register (next_frame, gdbarch_sp_regnum (gdbarch), - &this_base); + this_base = frame_unwind_register_unsigned (next_frame, + gdbarch_sp_regnum (gdbarch)); info->base = this_base; info->prev_sp = info->base + info->size; } @@ -1424,8 +1423,8 @@ crisv32_scan_prologue (CORE_ADDR pc, str } /* The SP is assumed to be unaltered. */ - frame_unwind_unsigned_register (next_frame, gdbarch_sp_regnum (gdbarch), - &this_base); + this_base = frame_unwind_register_unsigned (next_frame, + gdbarch_sp_regnum (gdbarch)); info->base = this_base; info->prev_sp = this_base; @@ -1470,8 +1469,8 @@ static CORE_ADDR cris_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { ULONGEST pc; - frame_unwind_unsigned_register (next_frame, - gdbarch_pc_regnum (gdbarch), &pc); + pc = frame_unwind_register_unsigned (next_frame, + gdbarch_pc_regnum (gdbarch)); return pc; } @@ -1479,8 +1478,8 @@ static CORE_ADDR cris_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame) { ULONGEST sp; - frame_unwind_unsigned_register (next_frame, - gdbarch_sp_regnum (gdbarch), &sp); + sp = frame_unwind_register_unsigned (next_frame, + gdbarch_sp_regnum (gdbarch)); return sp; } Index: src/gdb/doc/gdbint.texinfo =================================================================== --- src.orig/gdb/doc/gdbint.texinfo 2007-10-16 14:54:37.000000000 -0400 +++ src/gdb/doc/gdbint.texinfo 2007-10-16 14:54:56.000000000 -0400 @@ -3611,7 +3611,7 @@ is typically no more than: @smallexample ULONGEST pc; -pc = frame_unwind_unsigned_register (next_frame, S390_PC_REGNUM); +pc = frame_unwind_register_unsigned (next_frame, S390_PC_REGNUM); return gdbarch_addr_bits_remove (gdbarch, pc); @end smallexample @@ -3628,7 +3628,7 @@ is typically no more than: @smallexample ULONGEST sp; -sp = frame_unwind_unsigned_register (next_frame, S390_SP_REGNUM); +sp = frame_unwind_register_unsigned (next_frame, S390_SP_REGNUM); return gdbarch_addr_bits_remove (gdbarch, sp); @end smallexample Index: src/gdb/frame.c =================================================================== --- src.orig/gdb/frame.c 2007-10-16 14:55:44.000000000 -0400 +++ src/gdb/frame.c 2007-10-16 14:59:26.000000000 -0400 @@ -678,17 +678,6 @@ get_frame_register_unsigned (struct fram } void -frame_unwind_unsigned_register (struct frame_info *frame, int regnum, - ULONGEST *val) -{ - gdb_byte buf[MAX_REGISTER_SIZE]; - frame_unwind_register (frame, regnum, buf); - (*val) = extract_unsigned_integer (buf, - register_size (get_frame_arch (frame), - regnum)); -} - -void put_frame_register (struct frame_info *frame, int regnum, const gdb_byte *buf) { @@ -1730,12 +1719,8 @@ frame_sp_unwind (struct frame_info *next /* Now things are really are grim. Hope that the value returned by the gdbarch_sp_regnum register is meaningful. */ if (gdbarch_sp_regnum (gdbarch) >= 0) - { - ULONGEST sp; - frame_unwind_unsigned_register (next_frame, - gdbarch_sp_regnum (gdbarch), &sp); - return sp; - } + return frame_unwind_register_unsigned (next_frame, + gdbarch_sp_regnum (gdbarch)); internal_error (__FILE__, __LINE__, _("Missing unwind SP method")); } Index: src/gdb/frame.h =================================================================== --- src.orig/gdb/frame.h 2007-10-16 14:55:44.000000000 -0400 +++ src/gdb/frame.h 2007-10-16 14:58:42.000000000 -0400 @@ -476,10 +476,6 @@ extern ULONGEST get_frame_register_unsig int regnum); -/* Use frame_unwind_register_signed. */ -extern void frame_unwind_unsigned_register (struct frame_info *frame, - int regnum, ULONGEST *val); - /* Get the value of the register that belongs to this FRAME. This function is a wrapper to the call sequence ``frame_register_unwind (get_next_frame (FRAME))''. As per frame_register_unwind(), if Index: src/gdb/frv-tdep.c =================================================================== --- src.orig/gdb/frv-tdep.c 2007-10-16 14:55:44.000000000 -0400 +++ src/gdb/frv-tdep.c 2007-10-16 14:58:32.000000000 -0400 @@ -938,9 +938,9 @@ frv_analyze_prologue (CORE_ADDR pc, stru because instructions may save relative to the SP, but we need their addresses relative to the FP. */ if (fp_set) - frame_unwind_unsigned_register (next_frame, fp_regnum, &this_base); + this_base = frame_unwind_register_unsigned (next_frame, fp_regnum); else - frame_unwind_unsigned_register (next_frame, sp_regnum, &this_base); + this_base = frame_unwind_register_unsigned (next_frame, sp_regnum); for (i = 0; i < 64; i++) if (gr_saved[i]) Index: src/gdb/m68hc11-tdep.c =================================================================== --- src.orig/gdb/m68hc11-tdep.c 2007-10-16 14:55:44.000000000 -0400 +++ src/gdb/m68hc11-tdep.c 2007-10-16 14:58:12.000000000 -0400 @@ -763,8 +763,7 @@ m68hc11_unwind_pc (struct gdbarch *gdbar { ULONGEST pc; - frame_unwind_unsigned_register (next_frame, gdbarch_pc_regnum (gdbarch), - &pc); + pc = frame_unwind_register_unsigned (next_frame, gdbarch_pc_regnum (gdbarch)); return pc; } @@ -799,7 +798,7 @@ m68hc11_frame_unwind_cache (struct frame /* The SP was moved to the FP. This indicates that a new frame was created. Get THIS frame's FP value by unwinding it from the next frame. */ - frame_unwind_unsigned_register (next_frame, SOFT_FP_REGNUM, &this_base); + this_base = frame_unwind_register_unsigned (next_frame, SOFT_FP_REGNUM); if (this_base == 0) { info->base = 0; @@ -815,7 +814,7 @@ m68hc11_frame_unwind_cache (struct frame if (info->sp_offset != (CORE_ADDR) -1) { info->saved_regs[HARD_PC_REGNUM].addr = info->sp_offset; - frame_unwind_unsigned_register (next_frame, HARD_SP_REGNUM, &this_base); + this_base = frame_unwind_register_unsigned (next_frame, HARD_SP_REGNUM); prev_sp = this_base + info->sp_offset + 2; this_base += STACK_CORRECTION; } @@ -980,7 +979,7 @@ static CORE_ADDR m68hc11_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame) { ULONGEST sp; - frame_unwind_unsigned_register (next_frame, HARD_SP_REGNUM, &sp); + sp = frame_unwind_register_unsigned (next_frame, HARD_SP_REGNUM); return sp; } @@ -995,7 +994,7 @@ m68hc11_unwind_dummy_id (struct gdbarch ULONGEST tos; CORE_ADDR pc = frame_pc_unwind (next_frame); - frame_unwind_unsigned_register (next_frame, SOFT_FP_REGNUM, &tos); + tos = frame_unwind_register_unsigned (next_frame, SOFT_FP_REGNUM); tos += 2; return frame_id_build (tos, pc); } Index: src/gdb/mn10300-tdep.c =================================================================== --- src.orig/gdb/mn10300-tdep.c 2007-10-16 14:55:44.000000000 -0400 +++ src/gdb/mn10300-tdep.c 2007-10-16 14:57:14.000000000 -0400 @@ -934,7 +934,7 @@ mn10300_unwind_pc (struct gdbarch *gdbar { ULONGEST pc; - frame_unwind_unsigned_register (next_frame, E_PC_REGNUM, &pc); + pc = frame_unwind_register_unsigned (next_frame, E_PC_REGNUM); return pc; } @@ -943,7 +943,7 @@ mn10300_unwind_sp (struct gdbarch *gdbar { ULONGEST sp; - frame_unwind_unsigned_register (next_frame, E_SP_REGNUM, &sp); + sp = frame_unwind_register_unsigned (next_frame, E_SP_REGNUM); return sp; } Index: src/gdb/mt-tdep.c =================================================================== --- src.orig/gdb/mt-tdep.c 2007-10-16 14:55:23.000000000 -0400 +++ src/gdb/mt-tdep.c 2007-10-16 14:56:51.000000000 -0400 @@ -895,8 +895,8 @@ mt_frame_unwind_cache (struct frame_info /* Grab the frame-relative values of SP and FP, needed below. The frame_saved_register function will find them on the stack or in the registers as appropriate. */ - frame_unwind_unsigned_register (next_frame, MT_SP_REGNUM, &sp); - frame_unwind_unsigned_register (next_frame, MT_FP_REGNUM, &fp); + sp = frame_unwind_register_unsigned (next_frame, MT_SP_REGNUM); + fp = frame_unwind_register_unsigned (next_frame, MT_FP_REGNUM); start_addr = frame_func_unwind (next_frame, NORMAL_FRAME); @@ -1012,7 +1012,7 @@ mt_unwind_pc (struct gdbarch *gdbarch, s { ULONGEST pc; - frame_unwind_unsigned_register (next_frame, MT_PC_REGNUM, &pc); + pc = frame_unwind_register_unsigned (next_frame, MT_PC_REGNUM); return pc; } @@ -1021,7 +1021,7 @@ mt_unwind_sp (struct gdbarch *gdbarch, s { ULONGEST sp; - frame_unwind_unsigned_register (next_frame, MT_SP_REGNUM, &sp); + sp = frame_unwind_register_unsigned (next_frame, MT_SP_REGNUM); return sp; }