From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14676 invoked by alias); 24 Mar 2011 13:49:17 -0000 Received: (qmail 14657 invoked by uid 22791); 24 Mar 2011 13:49:12 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,TW_BL,TW_EG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Mar 2011 13:49:04 +0000 Received: (qmail 8547 invoked from network); 24 Mar 2011 13:49:01 -0000 Received: from unknown (HELO ?192.168.0.102?) (yao@127.0.0.2) by mail.codesourcery.com with ESMTPA; 24 Mar 2011 13:49:01 -0000 Message-ID: <4D8B4BC5.8090603@codesourcery.com> Date: Thu, 24 Mar 2011 13:58:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [try 2nd 2/8] Rename copy_* functions to arm_copy_* References: <4D15F9B8.5070705@codesourcery.com> <4D8B4947.1000000@codesourcery.com> In-Reply-To: <4D8B4947.1000000@codesourcery.com> Content-Type: multipart/mixed; boundary="------------070506000103010009020408" 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: 2011-03/txt/msg01066.txt.bz2 This is a multi-part message in MIME format. --------------070506000103010009020408 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-length: 316 The copy functions for arm and thumb instructions should be different. So some copy_* functions are renamed to arm_copy_* functions. In each copy functions, there are some arm-thumb-independent part, such as install cleanup helper, store register, etc. This part is moved to install_* functions. -- Yao (齐尧) --------------070506000103010009020408 Content-Type: text/x-patch; name="0002-refactor-rename-functions.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-refactor-rename-functions.patch" Content-length: 39517 2011-03-24 Yao Qi * gdb/arm-tdep.c (copy_unmodified): Rename to ... (arm_copy_unmodified): .. this. New. (copy_preload): Move common part to ... (install_preload): .. this. New. (arm_copy_preload): New. (copy_preload_reg): Move common part to ... (install_preload_reg): ... this. New. (arm_copy_preload_reg): New. (copy_b_bl_blx): Move common part to ... (install_b_bl_blx): .. this. New. (arm_copy_b_bl_blx): New. (copy_bx_blx_reg): Move common part to ... (install_bx_blx_reg): ... this. New. (arm_copy_bx_blx_reg): New. (copy_alu_reg): Move common part to ... (install_alu_reg): ... this. New. (arm_copy_alu_reg): New. (copy_alu_shifted_reg): Move common part to ... (install_alu_shifted_reg): ... this. New. (copy_ldr_str_ldrb_strb): Move common part to ... (install_ldr_str_ldrb_strb): ... this. New. (arm_copy_ldr_str_ldrb_strb): New. (copy_svc): Delete. (arm_copy_svc): Renamed from copy_svc. (copy_copro_load_store, copy_alu_imm): update callers. (copy_extra_ld_st, copy_block_xfer): Likewise. (decode_misc_memhint_neon, decode_unconditional): Likewise. (decode_miscellaneous, decode_dp_misc): Likewise. (decode_ld_st_word_ubyte, decode_media): Likewise. (decode_b_bl_ldmstm, decode_ext_reg_ld_st): Likewise. (decode_svc_copro): Likewise. * gdb/arm-tdep.h (struct displaced_step_closure): Add two structures `alu_reg' and `alu_shifted_reg'. --- gdb/arm-tdep.c | 495 +++++++++++++++++++++++++++++++------------------------ gdb/arm-tdep.h | 14 ++ 2 files changed, 293 insertions(+), 216 deletions(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 2ebafad..af81b1e 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -5319,7 +5319,7 @@ insn_references_pc (uint32_t insn, uint32_t bitmask) matter what address they are executed at: in those cases, use this. */ static int -copy_unmodified (struct gdbarch *gdbarch, uint32_t insn, +arm_copy_unmodified (struct gdbarch *gdbarch, uint32_t insn, const char *iname, struct displaced_step_closure *dsc) { if (debug_displaced) @@ -5343,20 +5343,11 @@ cleanup_preload (struct gdbarch *gdbarch, displaced_write_reg (regs, dsc, 1, dsc->tmp[1], CANNOT_WRITE_PC); } -static int -copy_preload (struct gdbarch *gdbarch, uint32_t insn, struct regcache *regs, - struct displaced_step_closure *dsc) +static void +install_preload (struct gdbarch *gdbarch, struct regcache *regs, + struct displaced_step_closure *dsc, unsigned int rn) { - unsigned int rn = bits (insn, 16, 19); ULONGEST rn_val; - - if (!insn_references_pc (insn, 0x000f0000ul)) - return copy_unmodified (gdbarch, insn, "preload", dsc); - - if (debug_displaced) - fprintf_unfiltered (gdb_stdlog, "displaced: copying preload insn %.8lx\n", - (unsigned long) insn); - /* Preload instructions: {pli/pld} [rn, #+/-imm] @@ -5366,34 +5357,40 @@ copy_preload (struct gdbarch *gdbarch, uint32_t insn, struct regcache *regs, dsc->tmp[0] = displaced_read_reg (regs, dsc, 0); rn_val = displaced_read_reg (regs, dsc, rn); displaced_write_reg (regs, dsc, 0, rn_val, CANNOT_WRITE_PC); - dsc->u.preload.immed = 1; - dsc->modinsn[0] = insn & 0xfff0ffff; - dsc->cleanup = &cleanup_preload; - - return 0; } -/* Preload instructions with register offset. */ - static int -copy_preload_reg (struct gdbarch *gdbarch, uint32_t insn, - struct regcache *regs, +arm_copy_preload (struct gdbarch *gdbarch, uint32_t insn, struct regcache *regs, struct displaced_step_closure *dsc) { unsigned int rn = bits (insn, 16, 19); - unsigned int rm = bits (insn, 0, 3); - ULONGEST rn_val, rm_val; - if (!insn_references_pc (insn, 0x000f000ful)) - return copy_unmodified (gdbarch, insn, "preload reg", dsc); + if (!insn_references_pc (insn, 0x000f0000ul)) + return arm_copy_unmodified (gdbarch, insn, "preload", dsc); if (debug_displaced) fprintf_unfiltered (gdb_stdlog, "displaced: copying preload insn %.8lx\n", (unsigned long) insn); + dsc->modinsn[0] = insn & 0xfff0ffff; + + install_preload (gdbarch, regs, dsc, rn); + + return 0; +} + +/* Preload instructions with register offset. */ + +static void +install_preload_reg(struct gdbarch *gdbarch, struct regcache *regs, + struct displaced_step_closure *dsc, unsigned int rn, + unsigned int rm) +{ + ULONGEST rn_val, rm_val; + /* Preload register-offset instructions: {pli/pld} [rn, rm {, shift}] @@ -5406,13 +5403,30 @@ copy_preload_reg (struct gdbarch *gdbarch, uint32_t insn, rm_val = displaced_read_reg (regs, dsc, rm); displaced_write_reg (regs, dsc, 0, rn_val, CANNOT_WRITE_PC); displaced_write_reg (regs, dsc, 1, rm_val, CANNOT_WRITE_PC); - dsc->u.preload.immed = 0; - dsc->modinsn[0] = (insn & 0xfff0fff0) | 0x1; - dsc->cleanup = &cleanup_preload; +} + +static int +arm_copy_preload_reg (struct gdbarch *gdbarch, uint32_t insn, + struct regcache *regs, + struct displaced_step_closure *dsc) +{ + unsigned int rn = bits (insn, 16, 19); + unsigned int rm = bits (insn, 0, 3); + + if (!insn_references_pc (insn, 0x000f000ful)) + return arm_copy_unmodified (gdbarch, insn, "preload reg", dsc); + + if (debug_displaced) + fprintf_unfiltered (gdb_stdlog, "displaced: copying preload insn %.8lx\n", + (unsigned long) insn); + + dsc->modinsn[0] = (insn & 0xfff0fff0) | 0x1; + + install_preload_reg (gdbarch, regs, dsc, rn, rm); return 0; } @@ -5440,7 +5454,7 @@ copy_copro_load_store (struct gdbarch *gdbarch, uint32_t insn, ULONGEST rn_val; if (!insn_references_pc (insn, 0x000f0000ul)) - return copy_unmodified (gdbarch, insn, "copro load/store", dsc); + return arm_copy_unmodified (gdbarch, insn, "copro load/store", dsc); if (debug_displaced) fprintf_unfiltered (gdb_stdlog, "displaced: copying coprocessor " @@ -5503,28 +5517,39 @@ cleanup_branch (struct gdbarch *gdbarch, struct regcache *regs, /* Copy B/BL/BLX instructions with immediate destinations. */ static int -copy_b_bl_blx (struct gdbarch *gdbarch, uint32_t insn, - struct regcache *regs, struct displaced_step_closure *dsc) +install_b_bl_blx (struct gdbarch *gdbarch, unsigned int cond, int exchange, + int link, long offset, struct regcache *regs, + struct displaced_step_closure *dsc) +{ + /* Implement "BL