From patchwork Mon Apr 28 10:00:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 716 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 782E6360075 for ; Mon, 28 Apr 2014 03:00:35 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 3D475414CB642; Mon, 28 Apr 2014 03:00:35 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 1F4AF414D8469 for ; Mon, 28 Apr 2014 03:00:35 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type; q=dns; s=default; b=GMArX b7O+wf5JAQmj23Gd/seG+ixiC15GtK6+RcizbhdiUFtBdXN9dtDCtKb5rqTXz6hl UZYjmWVxUVTDmB9tedj2blEFn8tGdoM9cx+K1Zui3OTZJB+jSuJUU8EYBwcGTu/z Oq8FVu/FTRp1b34nRbAZ/iFPyHcJ4hbv4pfaQw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type; s=default; bh=P2DILwGrbyc Hj4r0lIAgirUXrE4=; b=S6L7kI7/AZ61zDVV5VEjzCYZUZ6S7DoNi64OXVlsi3T FUIrPuhEbTm0GKMTguFR9i0/sbdhNv8fkh7aIEcHuF/LeQVezB6V9dG9Db3GrhfP MEtzvjXbwgPbqIVp3ui+1z2ZpYwVt7RCn2JFD5a/YWAuMM1wC2/DeItXsdrD8Gj0 = Received: (qmail 16690 invoked by alias); 28 Apr 2014 10:00:33 -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 16666 invoked by uid 89); 28 Apr 2014 10:00:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp16.uk.ibm.com Received: from e06smtp16.uk.ibm.com (HELO e06smtp16.uk.ibm.com) (195.75.94.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 28 Apr 2014 10:00:32 +0000 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Apr 2014 11:00:28 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp16.uk.ibm.com (192.168.101.146) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Apr 2014 11:00:26 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 8054717D8062 for ; Mon, 28 Apr 2014 11:01:26 +0100 (BST) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s3SA0OT866388128 for ; Mon, 28 Apr 2014 10:00:25 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s3SA0OWl021619 for ; Mon, 28 Apr 2014 04:00:24 -0600 Received: from br87z6lw.de.ibm.com (dyn-9-152-212-188.boeblingen.de.ibm.com [9.152.212.188]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s3SA0O01021605; Mon, 28 Apr 2014 04:00:24 -0600 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Qinwei Subject: [RFC 20/23] SCORE: Fill 'collect_regset' in regset structure References: <87eh0h6bkq.fsf@br87z6lw.de.ibm.com> Date: Mon, 28 Apr 2014 12:00:24 +0200 In-Reply-To: <87eh0h6bkq.fsf@br87z6lw.de.ibm.com> (Andreas Arnez's message of "Mon, 28 Apr 2014 11:35:33 +0200") Message-ID: <87wqe922pz.fsf@br87z6lw.de.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14042810-3548-0000-0000-000008E00765 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in gdb/ * score-tdep.c (score7_linux_supply_gregset): Delete function. Move logic to... (score7_linux_gregmap): ... this new register map. (SCORE7_LINUX_SIZEOF_GREGSET): New macro. (score7_linux_gregset): Refer to register map, replace supply method by regcache_supply_regset, and add collect method. (score7_linux_regset_from_core_section): Replace sizeof(elf_gregset_t) by SCORE7_LINUX_SIZEOF_GREGSET. * score-tdep.h (SCORE_EPC_REGNUM): New enum value. (struct pt_regs): Delete structure definition. (elf_gregset_t): Delete typedef. --- gdb/score-tdep.c | 72 +++++++++++++++++++------------------------------------- gdb/score-tdep.h | 34 +------------------------- 2 files changed, 25 insertions(+), 81 deletions(-) diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c index c224189..90afdf3 100644 --- a/gdb/score-tdep.c +++ b/gdb/score-tdep.c @@ -1398,59 +1398,34 @@ score_prologue_frame_base_sniffer (struct frame_info *this_frame) return &score_prologue_frame_base; } -/* Core file support (dirty hack) - - The core file MUST be generated by GNU/Linux on S+core. */ - -static void -score7_linux_supply_gregset(const struct regset *regset, - struct regcache *regcache, - int regnum, const void *gregs_buf, size_t len) -{ - int regno; - elf_gregset_t *gregs; - - gdb_assert (regset != NULL); - gdb_assert ((regcache != NULL) && (gregs_buf != NULL)); - - gregs = (elf_gregset_t *) gregs_buf; - - for (regno = 0; regno < 32; regno++) - if (regnum == -1 || regnum == regno) - regcache_raw_supply (regcache, regno, gregs->regs + regno); +/* Core file support. */ +static const struct regcache_map_entry score7_linux_gregmap[] = { - struct sreg { - int regnum; - void *buf; - } sregs [] = { - { 55, &(gregs->cel) }, /* CEL */ - { 54, &(gregs->ceh) }, /* CEH */ - { 53, &(gregs->sr0) }, /* sr0, i.e. cnt or COUNTER */ - { 52, &(gregs->sr1) }, /* sr1, i.e. lcr or LDCR */ - { 51, &(gregs->sr1) }, /* sr2, i.e. scr or STCR */ - - /* Exception occured at this address, exactly the PC we want */ - { 49, &(gregs->cp0_epc) }, /* PC */ - - { 38, &(gregs->cp0_ema) }, /* EMA */ - { 37, &(gregs->cp0_epc) }, /* EPC */ - { 34, &(gregs->cp0_ecr) }, /* ECR */ - { 33, &(gregs->cp0_condition) }, /* COND */ - { 32, &(gregs->cp0_psr) }, /* PSR */ - }; + { 7 * 4, REGCACHE_MAP_SKIP_BYTES }, + { 32, 0 }, /* r0 ... r31 */ + { 1, 55 }, /* CEL */ + { 1, 54 }, /* CEH */ + { 1, 53 }, /* sr0, i.e. cnt or COUNTER */ + { 1, 52 }, /* sr1, i.e. lcr or LDCR */ + { 1, 51 }, /* sr2, i.e. scr or STCR */ + /* EPC and PC are stored in the same slot. */ + { 1, 37 }, /* EPC */ + { -4, REGCACHE_MAP_SKIP_BYTES }, + { 1, 49 }, /* PC */ + { 1, 38 }, /* EMA */ + { 1, 32 }, /* PSR */ + { 1, 34 }, /* ECR */ + { 1, 33 }, /* COND */ + { 0 } + }; - for (regno = 0; regno < sizeof(sregs)/sizeof(sregs[0]); regno++) - if (regnum == -1 || regnum == sregs[regno].regnum) - regcache_raw_supply (regcache, - sregs[regno].regnum, sregs[regno].buf); - } -} +#define SCORE7_LINUX_SIZEOF_GREGSET 196 static const struct regset score7_linux_gregset = { - NULL, - score7_linux_supply_gregset, NULL + score7_linux_gregmap, + regcache_supply_regset, regcache_collect_regset }; /* Return the appropriate register set from the core section identified @@ -1463,7 +1438,8 @@ score7_linux_regset_from_core_section(struct gdbarch *gdbarch, gdb_assert (gdbarch != NULL); gdb_assert (sect_name != NULL); - if (strcmp(sect_name, ".reg") == 0 && sect_size == sizeof(elf_gregset_t)) + if (strcmp(sect_name, ".reg") == 0 + && sect_size == SCORE7_LINUX_SIZEOF_GREGSET) return &score7_linux_gregset; return NULL; diff --git a/gdb/score-tdep.h b/gdb/score-tdep.h index 02a334e..cef0e6a 100644 --- a/gdb/score-tdep.h +++ b/gdb/score-tdep.h @@ -32,6 +32,7 @@ enum gdb_regnum SCORE_RA_REGNUM = 3, SCORE_A0_REGNUM = 4, SCORE_AL_REGNUM = 7, + SCORE_EPC_REGNUM = 37, SCORE_PC_REGNUM = 49, }; @@ -46,37 +47,4 @@ enum gdb_regnum #define SCORE_INSTLEN 4 #define SCORE16_INSTLEN 2 -/* Forward declarations. */ -struct regset; - -/* Linux Core file support (dirty hack) - - S+core Linux register set definition, copy from S+core Linux. */ -struct pt_regs { - /* Pad bytes for argument save space on the stack. */ - unsigned long pad0[6]; /* may be 4, MIPS accept 6var, SCore - accepts 4 Var--yuchen */ - - /* Saved main processor registers. */ - unsigned long orig_r4; - unsigned long regs[32]; - - /* Other saved registers. */ - unsigned long cel; - unsigned long ceh; - - unsigned long sr0; /*cnt*/ - unsigned long sr1; /*lcr*/ - unsigned long sr2; /*scr*/ - - /* saved cp0 registers */ - unsigned long cp0_epc; - unsigned long cp0_ema; - unsigned long cp0_psr; - unsigned long cp0_ecr; - unsigned long cp0_condition; -}; - -typedef struct pt_regs elf_gregset_t; - #endif /* SCORE_TDEP_H */