From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 88756 invoked by alias); 1 Jul 2015 13:58:47 -0000 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 Received: (qmail 88687 invoked by uid 89); 1 Jul 2015 13:58:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f51.google.com Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 01 Jul 2015 13:58:41 +0000 Received: by paceq1 with SMTP id eq1so23598600pac.3 for ; Wed, 01 Jul 2015 06:58:39 -0700 (PDT) X-Received: by 10.70.22.131 with SMTP id d3mr55428177pdf.67.1435759119080; Wed, 01 Jul 2015 06:58:39 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id sc7sm2417503pbb.85.2015.07.01.06.58.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jul 2015 06:58:38 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 02/11] New aarch32-linux-nat.c Date: Wed, 01 Jul 2015 13:58:00 -0000 Message-Id: <1435759111-22856-3-git-send-email-yao.qi@linaro.org> In-Reply-To: <1435759111-22856-1-git-send-email-yao.qi@linaro.org> References: <1435759111-22856-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00031.txt.bz2 This patch is to move all the code about transferring regcache <-> byte buffer for arm (aarch32) to a separate file aarch32-linux-nat.c. Then, in the following patch, aarch64 code can use it to do multi-arch debugging. This is a refactory patch. gdb: 2015-06-24 Yao Qi * aarch32-linux-nat.c: New file. * aarch32-linux-nat.h: New file. * arm-linux-nat.c: Include aarch32-linux-nat.h. (fetch_regs): Move code to aarch32-linux-nat.c. Call aarch32_gp_regcache_supply. (store_regs): Move code to aarch32-linux-nat.c. Call aarch32_gp_regcache_collect. (fetch_vfp_regs): Move code to aarch32-linux-nat.c. Call aarch32_vfp_regcache_supply. (store_vfp_regs): Move code to aarch32-linux-nat.c. Call aarch32_vfp_regcache_collect. * config/arm/linux.mh (NATDEPFILES): Add aarch32-linux-nat.o. --- gdb/aarch32-linux-nat.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++ gdb/aarch32-linux-nat.h | 29 +++++++++++++++ gdb/arm-linux-nat.c | 46 +++++------------------ gdb/config/arm/linux.mh | 2 +- 4 files changed, 138 insertions(+), 38 deletions(-) create mode 100644 gdb/aarch32-linux-nat.c create mode 100644 gdb/aarch32-linux-nat.h diff --git a/gdb/aarch32-linux-nat.c b/gdb/aarch32-linux-nat.c new file mode 100644 index 0000000..3147399 --- /dev/null +++ b/gdb/aarch32-linux-nat.c @@ -0,0 +1,99 @@ +/* Copyright (C) 1999-2015 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" + +#include "regcache.h" +#include "arm-tdep.h" +#include "arm-linux-tdep.h" + +#include "aarch32-linux-nat.h" + +/* Supply GP registers contents, stored in REGS, to REGCACHE. ARM_APCS_32 + is true if the 32-bit mode is in use, otherwise, it is false. */ + +void +aarch32_gp_regcache_supply (struct regcache *regcache, uint32_t *regs, + int arm_apcs_32) +{ + int regno; + + for (regno = ARM_A1_REGNUM; regno < ARM_PC_REGNUM; regno++) + regcache_raw_supply (regcache, regno, ®s[regno]); + + if (arm_apcs_32) + regcache_raw_supply (regcache, ARM_PS_REGNUM, ®s[ARM_CPSR_GREGNUM]); + else + regcache_raw_supply (regcache, ARM_PS_REGNUM, ®s[ARM_PC_REGNUM]); + + regs[ARM_PC_REGNUM] = gdbarch_addr_bits_remove + (get_regcache_arch (regcache), regs[ARM_PC_REGNUM]); + regcache_raw_supply (regcache, ARM_PC_REGNUM, ®s[ARM_PC_REGNUM]); +} + +/* Collect GP registers from REGCACHE to buffer REGS. ARM_APCS_32 is + true if the 32-bit mode is in use, otherwise, it is false. */ + +void +aarch32_gp_regcache_collect (const struct regcache *regcache, uint32_t *regs, + int arm_apcs_32) +{ + int regno; + + for (regno = ARM_A1_REGNUM; regno <= ARM_PC_REGNUM; regno++) + { + if (REG_VALID == regcache_register_status (regcache, regno)) + regcache_raw_collect (regcache, regno, ®s[regno]); + } + + if (arm_apcs_32 + && REG_VALID == regcache_register_status (regcache, ARM_PS_REGNUM)) + regcache_raw_collect (regcache, ARM_PS_REGNUM, + ®s[ARM_CPSR_GREGNUM]); +} + +/* Supply VFP registers contents, stored in REGS, to REGCACHE. + VFP_REGISTER_COUNT is the number of VFP registers. */ + +void +aarch32_vfp_regcache_supply (struct regcache *regcache, gdb_byte *regs, + const int vfp_register_count) +{ + int regno; + + for (regno = 0; regno < vfp_register_count; regno++) + regcache_raw_supply (regcache, regno + ARM_D0_REGNUM, + regs + regno * 8); + + regcache_raw_supply (regcache, ARM_FPSCR_REGNUM, + regs + 32 * 8); +} + +/* Collect VFP registers from REGCACHE to buffer REGS. + VFP_REGISTER_COUNT is the number VFP registers. */ + +void +aarch32_vfp_regcache_collect (const struct regcache *regcache, gdb_byte *regs, + const int vfp_register_count) +{ + int regno; + + for (regno = 0; regno < vfp_register_count; regno++) + regcache_raw_collect (regcache, regno + ARM_D0_REGNUM, regs + regno * 8); + + regcache_raw_collect (regcache, ARM_FPSCR_REGNUM, regs + 32 * 8); +} diff --git a/gdb/aarch32-linux-nat.h b/gdb/aarch32-linux-nat.h new file mode 100644 index 0000000..1b7ff83e --- /dev/null +++ b/gdb/aarch32-linux-nat.h @@ -0,0 +1,29 @@ +/* Copyright (C) 1999-2015 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +void aarch32_gp_regcache_supply (struct regcache *regcache, uint32_t *regs, + int arm_apcs_32); + +void aarch32_gp_regcache_collect (const struct regcache *regcache, + uint32_t *regs, int arm_apcs_32); + +void aarch32_vfp_regcache_supply (struct regcache *regcache, gdb_byte *regs, + const int vfp_register_count); + +void aarch32_vfp_regcache_collect (const struct regcache *regcache, + gdb_byte *regs, + const int vfp_register_count); diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index 5a8880f..aca0461 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -29,6 +29,7 @@ #include "arm-tdep.h" #include "arm-linux-tdep.h" +#include "aarch32-linux-nat.h" #include #include @@ -212,20 +213,7 @@ fetch_regs (struct regcache *regcache) return; } - for (regno = ARM_A1_REGNUM; regno < ARM_PC_REGNUM; regno++) - regcache_raw_supply (regcache, regno, (char *) ®s[regno]); - - if (arm_apcs_32) - regcache_raw_supply (regcache, ARM_PS_REGNUM, - (char *) ®s[ARM_CPSR_GREGNUM]); - else - regcache_raw_supply (regcache, ARM_PS_REGNUM, - (char *) ®s[ARM_PC_REGNUM]); - - regs[ARM_PC_REGNUM] = gdbarch_addr_bits_remove - (get_regcache_arch (regcache), regs[ARM_PC_REGNUM]); - regcache_raw_supply (regcache, ARM_PC_REGNUM, - (char *) ®s[ARM_PC_REGNUM]); + aarch32_gp_regcache_supply (regcache, (uint32_t *) regs, arm_apcs_32); } static void @@ -256,15 +244,7 @@ store_regs (const struct regcache *regcache) return; } - for (regno = ARM_A1_REGNUM; regno <= ARM_PC_REGNUM; regno++) - { - if (REG_VALID == regcache_register_status (regcache, regno)) - regcache_raw_collect (regcache, regno, (char *) ®s[regno]); - } - - if (arm_apcs_32 && REG_VALID == regcache_register_status (regcache, ARM_PS_REGNUM)) - regcache_raw_collect (regcache, ARM_PS_REGNUM, - (char *) ®s[ARM_CPSR_GREGNUM]); + aarch32_gp_regcache_collect (regcache, (uint32_t *) regs, arm_apcs_32); if (have_ptrace_getregset == TRIBOOL_TRUE) { @@ -370,7 +350,7 @@ store_wmmx_regs (const struct regcache *regcache) static void fetch_vfp_regs (struct regcache *regcache) { - char regbuf[VFP_REGS_SIZE]; + gdb_byte regbuf[VFP_REGS_SIZE]; int ret, regno, tid; struct gdbarch *gdbarch = get_regcache_arch (regcache); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); @@ -395,18 +375,14 @@ fetch_vfp_regs (struct regcache *regcache) return; } - for (regno = 0; regno < tdep->vfp_register_count; regno++) - regcache_raw_supply (regcache, regno + ARM_D0_REGNUM, - (char *) regbuf + regno * 8); - - regcache_raw_supply (regcache, ARM_FPSCR_REGNUM, - (char *) regbuf + 32 * 8); + aarch32_vfp_regcache_supply (regcache, regbuf, + tdep->vfp_register_count); } static void store_vfp_regs (const struct regcache *regcache) { - char regbuf[VFP_REGS_SIZE]; + gdb_byte regbuf[VFP_REGS_SIZE]; int ret, regno, tid; struct gdbarch *gdbarch = get_regcache_arch (regcache); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); @@ -431,12 +407,8 @@ store_vfp_regs (const struct regcache *regcache) return; } - for (regno = 0; regno < tdep->vfp_register_count; regno++) - regcache_raw_collect (regcache, regno + ARM_D0_REGNUM, - (char *) regbuf + regno * 8); - - regcache_raw_collect (regcache, ARM_FPSCR_REGNUM, - (char *) regbuf + 32 * 8); + aarch32_vfp_regcache_collect (regcache, regbuf, + tdep->vfp_register_count); if (have_ptrace_getregset == TRIBOOL_TRUE) { diff --git a/gdb/config/arm/linux.mh b/gdb/config/arm/linux.mh index f0c5967..003ca1f 100644 --- a/gdb/config/arm/linux.mh +++ b/gdb/config/arm/linux.mh @@ -2,7 +2,7 @@ NAT_FILE= config/nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o arm-linux-nat.o \ - proc-service.o linux-thread-db.o \ + aarch32-linux-nat.o proc-service.o linux-thread-db.o \ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \ linux-waitpid.o linux-personality.o linux-namespaces.o NAT_CDEPS = $(srcdir)/proc-service.list -- 1.9.1