From patchwork Wed Jun 4 16:21:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omair Javaid X-Patchwork-Id: 31380 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0024B203AC for ; Wed, 4 Jun 2014 16:21:45 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id vb8sf43188264obc.4 for ; Wed, 04 Jun 2014 09:21:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results; bh=Xi0jDTu/Ui31xayHd10y5Glu6A10318i3LznjePbyAY=; b=TvpGa0ihNzX5Ct6xUqP7bOFeo/J0H+R2Bhl+YbssyjOwBIRJw0rwc/q5DEc1G200ye MHWOn+nIwWYt3fFyIEspLlVz6ZfK8bR0ocUuilBFam+WpQXR/XACe/TVEQf/trt7MqRY KjUOq49CVbBMyBmoPHWBx48QxP/6mfQK0lJ63Cso3P3xKuXqJ4ebO57TgWQQD9DDMRhM JbP0SQ6hnerC1zgvQZ4vHJZK56FTK5CeHmlwePUN9qWUBTTKGqAw4DSS7zNwjZAseFEp 9qEwwxua5uHgPoblRJgfTXXz7c/AzOUGN4Bi43X95Uwz32rmk7fE6u7jeSzWZyuFw07j /cyg== X-Gm-Message-State: ALoCoQnPoPX5jpch+0tWq/FDoHTpYp1BdC3r2TjLo1M2c/GaYBCjA9zWsXY4wSci1EXlUk2FoJKh X-Received: by 10.182.104.74 with SMTP id gc10mr22827592obb.40.1401898905524; Wed, 04 Jun 2014 09:21:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.27.138 with SMTP id 10ls3091415qgx.9.gmail; Wed, 04 Jun 2014 09:21:45 -0700 (PDT) X-Received: by 10.52.12.229 with SMTP id b5mr3127118vdc.52.1401898905396; Wed, 04 Jun 2014 09:21:45 -0700 (PDT) Received: from mail-vc0-x230.google.com (mail-vc0-x230.google.com [2607:f8b0:400c:c03::230]) by mx.google.com with ESMTPS id lv1si728968vcb.85.2014.06.04.09.21.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Jun 2014 09:21:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::230 as permitted sender) client-ip=2607:f8b0:400c:c03::230; Received: by mail-vc0-f176.google.com with SMTP id im17so1693449vcb.7 for ; Wed, 04 Jun 2014 09:21:45 -0700 (PDT) X-Received: by 10.221.26.10 with SMTP id rk10mr45019700vcb.0.1401898905294; Wed, 04 Jun 2014 09:21:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp57822vcb; Wed, 4 Jun 2014 09:21:44 -0700 (PDT) X-Received: by 10.68.103.98 with SMTP id fv2mr41585514pbb.18.1401898904439; Wed, 04 Jun 2014 09:21:44 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id in2si6706492pbc.229.2014.06.04.09.21.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jun 2014 09:21:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-return-113107-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 2657 invoked by alias); 4 Jun 2014 16:21:37 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 2646 invoked by uid 89); 4 Jun 2014 16:21:36 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f43.google.com Received: from mail-wg0-f43.google.com (HELO mail-wg0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 04 Jun 2014 16:21:34 +0000 Received: by mail-wg0-f43.google.com with SMTP id l18so8597805wgh.2 for ; Wed, 04 Jun 2014 09:21:30 -0700 (PDT) X-Received: by 10.180.96.6 with SMTP id do6mr6927529wib.44.1401898890569; Wed, 04 Jun 2014 09:21:30 -0700 (PDT) Received: from localhost.localdomain ([182.185.152.186]) by mx.google.com with ESMTPSA id um7sm2677062wjc.12.2014.06.04.09.21.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Jun 2014 09:21:29 -0700 (PDT) From: Omair Javaid To: gdb-patches@sourceware.org Cc: Omair Javaid Subject: [PATCH 2/7] Fixes for aarch64-linux gdb core file support Date: Wed, 4 Jun 2014 21:21:06 +0500 Message-Id: <1401898871-2270-3-git-send-email-omair.javaid@linaro.org> In-Reply-To: <1401898871-2270-1-git-send-email-omair.javaid@linaro.org> References: <1401898871-2270-1-git-send-email-omair.javaid@linaro.org> X-IsSubscribed: yes X-Original-Sender: omair.javaid@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c03::230 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 This patch fixes aarch64 linux core file support by adding/updating aarch64-linux supply/collect methods for aarch64 register set. gdb: 2014-06-04 Omair Javaid * aarch64-linux-tdep.c (aarch64_linux_supply_gregset): Updated. (aarch64_linux_supply_fpregset): Updated. (supply_gregset_from_core): Removed. (aarch64_linux_collect_gregset): New function. (supply_fpregset_from_core): Removed. (aarch64_linux_collect_fpregset): New function. (struct regset aarch64_linux_gregset): Updated. (struct core_regset_section aarch64_linux_regset_sections[]): Declared. * aarch64-linux-tdep.h (aarch64_linux_supply_gregset): Updated extern. (aarch64_linux_supply_fpregset): New extern declaration. (aarch64_linux_collect_gregset): New extern declaration. (aarch64_linux_collect_fpregset): New extern declaration. * aarch64-linux-nat.c (aarch64_linux_supply_gregset): Updated. (aarch64_linux_supply_fpregset): Updated. --- gdb/aarch64-linux-nat.c | 4 +-- gdb/aarch64-linux-tdep.c | 91 +++++++++++++++++++++++++++++++++--------------- gdb/aarch64-linux-tdep.h | 22 +++++++++--- 3 files changed, 83 insertions(+), 34 deletions(-) diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 877e702..f631d9e 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -632,7 +632,7 @@ fill_gregset (const struct regcache *regcache, void supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp) { - aarch64_linux_supply_gregset (regcache, (const gdb_byte *) gregsetp); + aarch64_linux_supply_gregset (NULL, regcache, -1, gregsetp, 0); } /* Fill register REGNO (if it is a floating-point register) in @@ -667,7 +667,7 @@ fill_fpregset (const struct regcache *regcache, void supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp) { - aarch64_linux_supply_fpregset (regcache, (const gdb_byte *) fpregsetp); + aarch64_linux_supply_fpregset (NULL, regcache, -1, fpregsetp, 0); } /* Called when resuming a thread. diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 30ed73f..b285818 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -191,70 +191,93 @@ static const struct tramp_frame aarch64_linux_rt_sigframe = }; /* Fill GDB's register array with the general-purpose register values - in the buffer pointed by GREGS_BUF. */ + in the buffer pointed by gregs_buf. */ void -aarch64_linux_supply_gregset (struct regcache *regcache, - const gdb_byte *gregs_buf) +aarch64_linux_supply_gregset (const struct regset *regset, + struct regcache *regcache, int regnum, + const void *gregs_buf, size_t len) { + gdb_byte *gregs_bufp = (gdb_byte *) gregs_buf; int regno; for (regno = AARCH64_X0_REGNUM; regno <= AARCH64_CPSR_REGNUM; regno++) regcache_raw_supply (regcache, regno, - gregs_buf + X_REGISTER_SIZE + gregs_bufp + X_REGISTER_SIZE * (regno - AARCH64_X0_REGNUM)); } -/* The "supply_regset" function for the general-purpose register set. */ +/* Fill registers in *gregs_buf with the values in GDB's register cache. */ -static void -supply_gregset_from_core (const struct regset *regset, - struct regcache *regcache, - int regnum, const void *regbuf, size_t len) +void +aarch64_linux_collect_gregset (const struct regset *regset, + const struct regcache *regcache, int regnum, + void *gregs_buf, size_t len) { - aarch64_linux_supply_gregset (regcache, (const gdb_byte *) regbuf); + gdb_byte *gregs_bufp = (gdb_byte *) gregs_buf; + int regno; + + for (regno = AARCH64_X0_REGNUM; regno <= AARCH64_CPSR_REGNUM; regno++) + if (regnum == -1 || regnum == regno) + regcache_raw_collect (regcache, regno, gregs_bufp + X_REGISTER_SIZE * + (regno - AARCH64_X0_REGNUM)); } /* Fill GDB's register array with the floating-point register values - in the buffer pointed by FPREGS_BUF. */ + in the buffer pointed by fpregs_buf. */ void -aarch64_linux_supply_fpregset (struct regcache *regcache, - const gdb_byte *fpregs_buf) +aarch64_linux_supply_fpregset (const struct regset *regset, + struct regcache *regcache, int regnum, + const void *fpregs_buf, size_t len) { + gdb_byte *fpregs_bufp = (gdb_byte *) fpregs_buf; int regno; for (regno = AARCH64_V0_REGNUM; regno <= AARCH64_V31_REGNUM; regno++) - regcache_raw_supply (regcache, regno, - fpregs_buf + V_REGISTER_SIZE - * (regno - AARCH64_V0_REGNUM)); + regcache_raw_supply (regcache, regno, fpregs_bufp + V_REGISTER_SIZE * + (regno - AARCH64_V0_REGNUM)); - regcache_raw_supply (regcache, AARCH64_FPSR_REGNUM, - fpregs_buf + V_REGISTER_SIZE * 32); - regcache_raw_supply (regcache, AARCH64_FPCR_REGNUM, - fpregs_buf + V_REGISTER_SIZE * 32 + 4); + regcache_raw_supply (regcache, AARCH64_FPSR_REGNUM, fpregs_bufp + + V_REGISTER_SIZE * 32); + regcache_raw_supply (regcache, AARCH64_FPCR_REGNUM, fpregs_bufp + + V_REGISTER_SIZE * 32 + 4); } -/* The "supply_regset" function for the floating-point register set. */ +/* Fill registers in *fpregs_buf with the values in GDB's register cache. */ -static void -supply_fpregset_from_core (const struct regset *regset, - struct regcache *regcache, - int regnum, const void *regbuf, size_t len) +void +aarch64_linux_collect_fpregset (const struct regset *regset, + const struct regcache *regcache, int regnum, + void *fpregs_buf, size_t len) { - aarch64_linux_supply_fpregset (regcache, (const gdb_byte *) regbuf); + gdb_byte *fpregs_bufp = (gdb_byte *) fpregs_buf; + int regno; + + for (regno = AARCH64_V0_REGNUM; regno <= AARCH64_V31_REGNUM; regno++) + if (regnum == -1 || regnum == regno) + regcache_raw_collect (regcache, regno, fpregs_bufp + V_REGISTER_SIZE * + (regno - AARCH64_V0_REGNUM)); + + if (regnum == -1 || regnum == AARCH64_FPSR_REGNUM) + regcache_raw_collect (regcache, AARCH64_FPSR_REGNUM, fpregs_bufp + + V_REGISTER_SIZE * 32); + + if (regnum == -1 || regnum == AARCH64_FPCR_REGNUM) + regcache_raw_collect (regcache, AARCH64_FPCR_REGNUM, fpregs_bufp + + V_REGISTER_SIZE * 32 + 4); } /* Register set definitions. */ static const struct regset aarch64_linux_gregset = { - NULL, supply_gregset_from_core, NULL + NULL, aarch64_linux_supply_gregset, aarch64_linux_collect_gregset }; static const struct regset aarch64_linux_fpregset = { - NULL, supply_fpregset_from_core, NULL + NULL, aarch64_linux_supply_fpregset, aarch64_linux_collect_fpregset }; /* Implement the "regset_from_core_section" gdbarch method. */ @@ -275,6 +298,15 @@ aarch64_linux_regset_from_core_section (struct gdbarch *gdbarch, return NULL; } +/* Core file register set sections. */ + +static struct core_regset_section aarch64_linux_regset_sections[] = +{ + { ".reg", AARCH64_LINUX_SIZEOF_GREGSET, "general-purpose" }, + { ".reg2", AARCH64_LINUX_SIZEOF_FPREGSET, "floating-point" }, + { NULL, 0} +}; + /* Implementation of `gdbarch_stap_is_single_operand', as defined in gdbarch.h. */ @@ -420,6 +452,9 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) /* Enable longjmp. */ tdep->jb_pc = 11; + /* Install supported register note sections. */ + set_gdbarch_core_regset_sections (gdbarch, aarch64_linux_regset_sections); + set_gdbarch_regset_from_core_section (gdbarch, aarch64_linux_regset_from_core_section); diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h index 48c7092..e3d7ed7 100644 --- a/gdb/aarch64-linux-tdep.h +++ b/gdb/aarch64-linux-tdep.h @@ -20,7 +20,21 @@ struct regcache; -extern void aarch64_linux_supply_gregset (struct regcache *regcache, - const gdb_byte *gregs_buf); -extern void aarch64_linux_supply_fpregset (struct regcache *regcache, - const gdb_byte *fpregs_buf); +/* Function prototypes for function transferring the general-purpose + registers between GDB, inferiors and core files. */ + +/* Fill GDB's register array with the general-purpose register values + in *gregs_buf. */ + +extern void aarch64_linux_supply_gregset (const struct regset *regset, + struct regcache *regcache, int regnum, + const void *gregs_buf, size_t len); +extern void aarch64_linux_collect_gregset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *gregs_buf, size_t len); +extern void aarch64_linux_supply_fpregset (const struct regset *regset, + struct regcache *regcache, int regnum, + const void *fpregs_buf, size_t len); +extern void aarch64_linux_collect_fpregset (const struct regset *regset, + const struct regcache *regcache, + int regnum, void *fpregs_buf, size_t len);