From patchwork Wed Jan 13 16:53:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 10362 Received: (qmail 114137 invoked by alias); 13 Jan 2016 16:53:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 111977 invoked by uid 89); 13 Jan 2016 16:53:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=UD:xml, 173 X-HELO: mail-pf0-f170.google.com Received: from mail-pf0-f170.google.com (HELO mail-pf0-f170.google.com) (209.85.192.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 13 Jan 2016 16:53:36 +0000 Received: by mail-pf0-f170.google.com with SMTP id n128so83953131pfn.3 for ; Wed, 13 Jan 2016 08:53:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=0i1AZ5HnpsRSW55W09aT1SYjXvx5Hm+Xj2eDIjd+3BM=; b=bDo1NGZx0JIFaph9YVSbI9jXZL1bzooucXZyoL810+IEPGU19FF1YaV1EiudIuUl6d Ln8gGRTNJngM+foaRyH976xVjdHvC3TW/6cchTJOzmuty+eSCkxFZrqvJoZvry5WJum4 fD+3LADJyMgVKG/NDRwwNGPPqEWFWeEn/9LMRsWhjNwLVYI1pI6V/zifll8mAMfVfzwv tNe5GWiwPppDZ12eALKXRors1lh6oz4uaRi3REr0WhLlBw/mwy5OqNW+WctwXqrNzr0W /ZBQhpG8lwQYzRAdXqqs5VSuUxkWpjqKDkyUt13OFNyraw6i9hoEJ/hKuaXxJ9iCcour FJjw== X-Gm-Message-State: ALoCoQmv2//QWSWFQSYfuIAQcv8/9YqrFNv2qcTrAYMF+0u4mMepR+OYW1YCsWpzgtbD1kK/2fqsy2gd1oT21T7XhbuYb2PRBA== X-Received: by 10.98.31.84 with SMTP id f81mr43939905pff.98.1452704014637; Wed, 13 Jan 2016 08:53:34 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id qj8sm3726813pac.40.2016.01.13.08.53.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Jan 2016 08:53:33 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] [ARM] Remove field syscall_next_pc in struct gdbarch_tdep Date: Wed, 13 Jan 2016 16:53:24 +0000 Message-Id: <1452704004-6821-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes Field syscall_next_pc in struct gdbarch_tdep was to calculate the next pc of syscall instruction. On linux target, syscall_next_pc is set to arm_linux_syscall_next_pc, to do linux specific things. However, after we have struct arm_get_next_pcs_ops, we can do the same thing in struct arm_get_next_pcs_ops field syscall_next_pc, so syscall_next_pc in struct gdbarch_tdep is not needed any more. No regressions on arm-linux. gdb: 2016-01-13 Yao Qi * arm-linux-tdep.c (arm_linux_get_next_pcs_syscall_next_pc): Declare. (arm_linux_get_next_pcs_ops): Install arm_linux_get_next_pcs_syscall_next_pc. (arm_linux_syscall_next_pc): Change to ... (arm_linux_get_next_pcs_syscall_next_pc): ... it. (arm_linux_init_abi): Don't set tdep->syscall_next_pc. * arm-tdep.c (arm_get_next_pcs_syscall_next_pc): Declare. (arm_get_next_pcs_syscall_next_pc): Make it static. Don't call tdep->syscall_next_pc. * arm-tdep.h (struct gdbarch_tdep) : Remove. (arm_get_next_pcs_syscall_next_pc): Remove. --- gdb/arm-linux-tdep.c | 27 +++++++++++++-------------- gdb/arm-tdep.c | 16 ++++++++-------- gdb/arm-tdep.h | 7 ------- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index 6050bdf..2306bda 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -265,10 +265,14 @@ static const gdb_byte arm_linux_thumb2_le_breakpoint[] = { 0xf0, 0xf7, 0x00, 0xa /* Syscall number for rt_sigreturn. */ #define ARM_RT_SIGRETURN 173 +static CORE_ADDR + arm_linux_get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self, + CORE_ADDR pc); + /* Operation function pointers for get_next_pcs. */ static struct arm_get_next_pcs_ops arm_linux_get_next_pcs_ops = { arm_get_next_pcs_read_memory_unsigned_integer, - arm_get_next_pcs_syscall_next_pc, + arm_linux_get_next_pcs_syscall_next_pc, arm_get_next_pcs_addr_bits_remove, arm_get_next_pcs_is_thumb }; @@ -859,26 +863,23 @@ arm_linux_get_syscall_number (struct gdbarch *gdbarch, return svc_number; } -/* When the processor is at a syscall instruction, return the PC of the - next instruction to be executed. */ - static CORE_ADDR -arm_linux_syscall_next_pc (struct regcache *regcache) +arm_linux_get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self, + CORE_ADDR pc) { - CORE_ADDR pc = regcache_read_pc (regcache); CORE_ADDR next_pc = 0; - int is_thumb = arm_is_thumb (regcache); + int is_thumb = arm_is_thumb (self->regcache); ULONGEST svc_number = 0; - struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch *gdbarch = get_regcache_arch (self->regcache); if (is_thumb) { - svc_number = regcache_raw_get_unsigned (regcache, 7); + svc_number = regcache_raw_get_unsigned (self->regcache, 7); next_pc = pc + 2; } else { - struct gdbarch *gdbarch = get_regcache_arch (regcache); + struct gdbarch *gdbarch = get_regcache_arch (self->regcache); enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch); unsigned long this_instr = @@ -891,14 +892,14 @@ arm_linux_syscall_next_pc (struct regcache *regcache) } else /* EABI. */ { - svc_number = regcache_raw_get_unsigned (regcache, 7); + svc_number = regcache_raw_get_unsigned (self->regcache, 7); } next_pc = pc + 4; } if (svc_number == ARM_SIGRETURN || svc_number == ARM_RT_SIGRETURN) - next_pc = arm_linux_sigreturn_next_pc (regcache, svc_number); + next_pc = arm_linux_sigreturn_next_pc (self->regcache, svc_number); /* Addresses for calling Thumb functions have the bit 0 set. */ if (is_thumb) @@ -1485,8 +1486,6 @@ arm_linux_init_abi (struct gdbarch_info info, set_gdbarch_stap_parse_special_token (gdbarch, arm_stap_parse_special_token); - tdep->syscall_next_pc = arm_linux_syscall_next_pc; - /* `catch syscall' */ set_xml_syscall_file_name (gdbarch, "syscalls/arm-linux.xml"); set_gdbarch_get_syscall_number (gdbarch, arm_linux_get_syscall_number); diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 8874ec8..ccc2a03 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -237,6 +237,11 @@ static void arm_neon_quad_write (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf); +static CORE_ADDR + arm_get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self, + CORE_ADDR pc); + + /* get_next_pcs operations. */ static struct arm_get_next_pcs_ops arm_get_next_pcs_ops = { arm_get_next_pcs_read_memory_unsigned_integer, @@ -6142,15 +6147,10 @@ arm_get_next_pcs_addr_bits_remove (struct arm_get_next_pcs *self, /* Wrapper over syscall_next_pc for use in get_next_pcs. */ -CORE_ADDR -arm_get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self, CORE_ADDR pc) +static CORE_ADDR +arm_get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self, + CORE_ADDR pc) { - struct gdbarch_tdep *tdep; - - tdep = gdbarch_tdep (get_regcache_arch (self->regcache)); - if (tdep->syscall_next_pc != NULL) - return tdep->syscall_next_pc (self->regcache); - return 0; } diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h index faa543e..1306cbb 100644 --- a/gdb/arm-tdep.h +++ b/gdb/arm-tdep.h @@ -138,10 +138,6 @@ struct gdbarch_tdep struct type *neon_double_type; struct type *neon_quad_type; - /* Return the expected next PC if the program is stopped at a syscall - instruction. */ - CORE_ADDR (*syscall_next_pc) (struct regcache *regcache); - /* syscall record. */ int (*arm_syscall_record) (struct regcache *regcache, unsigned long svc_number); }; @@ -261,9 +257,6 @@ ULONGEST arm_get_next_pcs_read_memory_unsigned_integer (CORE_ADDR memaddr, CORE_ADDR arm_get_next_pcs_addr_bits_remove (struct arm_get_next_pcs *self, CORE_ADDR val); -CORE_ADDR arm_get_next_pcs_syscall_next_pc (struct arm_get_next_pcs *self, - CORE_ADDR pc); - int arm_get_next_pcs_is_thumb (struct arm_get_next_pcs *self); void arm_insert_single_step_breakpoint (struct gdbarch *,