From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5065 invoked by alias); 30 May 2013 12:14:31 -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 5038 invoked by uid 89); 30 May 2013 12:14:30 -0000 X-Spam-SWARE-Status: No, score=-8.0 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS,TW_EG,TW_HW,TW_SR,TW_VF autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 30 May 2013 12:14:30 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4UCESMY026645 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 30 May 2013 08:14:28 -0400 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4UCERTx030619 for ; Thu, 30 May 2013 08:14:28 -0400 Subject: [PATCH 07/22] [GDBserver] Multi-process + multi-arch: GNU/Linux ARM To: gdb-patches@sourceware.org From: Pedro Alves Date: Thu, 30 May 2013 12:14:00 -0000 Message-ID: <20130530121427.15047.7954.stgit@brno.lan> In-Reply-To: <20130530121335.15047.12654.stgit@brno.lan> References: <20130530121335.15047.12654.stgit@brno.lan> User-Agent: StGit/0.16 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-SW-Source: 2013-05/txt/msg01064.txt.bz2 This adjusts the GNU/Linux ARM port to new interfaces. Built with a cross arm-linux-gnu toolchain. Otherwise not tested. 2012-05-30 Pedro Alves * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. --- gdb/gdbserver/linux-arm-low.c | 91 +++++++++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 22 deletions(-) diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c index 8ddd90a..a6b745d 100644 --- a/gdb/gdbserver/linux-arm-low.c +++ b/gdb/gdbserver/linux-arm-low.c @@ -29,10 +29,19 @@ /* Defined in auto-generated files. */ void init_registers_arm (void); +extern const struct target_desc *tdesc_arm; + void init_registers_arm_with_iwmmxt (void); +extern const struct target_desc *tdesc_arm_with_iwmmxt; + void init_registers_arm_with_vfpv2 (void); +extern const struct target_desc *tdesc_arm_with_vfpv2; + void init_registers_arm_with_vfpv3 (void); +extern const struct target_desc *tdesc_arm_with_vfpv3; + void init_registers_arm_with_neon (void); +extern const struct target_desc *tdesc_arm_with_neon; #ifndef PTRACE_GET_THREAD_AREA #define PTRACE_GET_THREAD_AREA 22 @@ -212,7 +221,7 @@ arm_fill_vfpregset (struct regcache *regcache, void *buf) else num = 16; - base = find_regno ("d0"); + base = find_regno (regcache->tdesc, "d0"); for (i = 0; i < num; i++) collect_register (regcache, base + i, (char *) buf + i * 8); @@ -232,7 +241,7 @@ arm_store_vfpregset (struct regcache *regcache, const void *buf) else num = 16; - base = find_regno ("d0"); + base = find_regno (regcache->tdesc, "d0"); for (i = 0; i < num; i++) supply_register (regcache, base + i, (char *) buf + i * 8); @@ -768,8 +777,8 @@ arm_get_hwcap (unsigned long *valp) return 0; } -static void -arm_arch_setup (void) +static const struct target_desc * +arm_read_description (void) { int pid = lwpid_of (get_thread_lwp (current_inferior)); @@ -778,29 +787,24 @@ arm_arch_setup (void) arm_hwcap = 0; if (arm_get_hwcap (&arm_hwcap) == 0) - { - init_registers_arm (); - return; - } + return tdesc_arm; if (arm_hwcap & HWCAP_IWMMXT) - { - init_registers_arm_with_iwmmxt (); - return; - } + return tdesc_arm_with_iwmmxt; if (arm_hwcap & HWCAP_VFP) { + const struct target_desc *result; char *buf; /* NEON implies either no VFP, or VFPv3-D32. We only support it with VFP. */ if (arm_hwcap & HWCAP_NEON) - init_registers_arm_with_neon (); + result = tdesc_arm_with_neon; else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3) - init_registers_arm_with_vfpv3 (); + result = tdesc_arm_with_vfpv3; else - init_registers_arm_with_vfpv2 (); + result = tdesc_arm_with_vfpv2; /* Now make sure that the kernel supports reading these registers. Support was added in 2.6.30. */ @@ -810,19 +814,25 @@ arm_arch_setup (void) && errno == EIO) { arm_hwcap = 0; - init_registers_arm (); + result = tdesc_arm; } free (buf); - return; + return result; } /* The default configuration uses legacy FPA registers, probably simulated. */ - init_registers_arm (); + return tdesc_arm; } -struct regset_info target_regsets[] = { +static void +arm_arch_setup (void) +{ + current_process ()->tdesc = arm_read_description (); +} + +static struct regset_info arm_regsets[] = { { PTRACE_GETREGS, PTRACE_SETREGS, 0, 18 * 4, GENERAL_REGS, arm_fill_gregset, arm_store_gregset }, @@ -835,11 +845,35 @@ struct regset_info target_regsets[] = { { 0, 0, 0, -1, -1, NULL, NULL } }; +static struct regsets_info arm_regsets_info = + { + arm_regsets, /* regsets */ + 0, /* num_regsets */ + NULL, /* disabled_regsets */ + }; + +static struct usrregs_info arm_usrregs_info = + { + arm_num_regs, + arm_regmap, + }; + +static struct regs_info regs_info = + { + NULL, /* regset_bitmap */ + &arm_usrregs_info, + &arm_regsets_info + }; + +static const struct regs_info * +arm_regs_info (void) +{ + return ®s_info; +} + struct linux_target_ops the_low_target = { arm_arch_setup, - arm_num_regs, - arm_regmap, - NULL, + arm_regs_info, arm_cannot_fetch_register, arm_cannot_store_register, NULL, /* fetch_register */ @@ -871,3 +905,16 @@ struct linux_target_ops the_low_target = { arm_new_thread, arm_prepare_to_resume, }; + +void +initialize_low_arch (void) +{ + /* Initialize the Linux target descriptions. */ + init_registers_arm (); + init_registers_arm_with_iwmmxt (); + init_registers_arm_with_vfpv2 (); + init_registers_arm_with_vfpv3 (); + init_registers_arm_with_neon (); + + initialize_regsets_info (&arm_regsets_info); +}