From patchwork Thu Apr 17 12:30:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 606 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id CEB6C36007E for ; Thu, 17 Apr 2014 05:30:35 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id 76BF6629E1107; Thu, 17 Apr 2014 05:30:35 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx23.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-mx23.g.dreamhost.com (Postfix) with ESMTPS id 20454629F5E71 for ; Thu, 17 Apr 2014 05:30: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:message-id:subject:to:date:from:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=kIi pQV2YKuhgP/yijDQqq18GmMhU4vdghtdndj3DbQ64JpgZlK5FWoy3j3MVpqAbgIT hxlzaOl1Orcmto0vERf8ko1O2QzRRo/HUR3WNYyp6cko5DwBq0F0tF55w6fN/3Kk aM1GmyRYCYNqiNl2LfVbMD+JtgGj2NuEEiRJBuPI= 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:message-id:subject:to:date:from:mime-version :content-type:content-transfer-encoding; s=default; bh=IAZhidhlV xyrR2azdDmS7/sbT1c=; b=YqBdew6IrYVeG/MQ1atFYQZ4pwjYOFpLkG7Z8jDJ5 ojNqkRrYkPgJZdMIUtG/KZmDqGYGtJg0D4xSRX+ZaFXY6bufkXVKDeuvnUi1BqVE mQopBO5Sck9R+vVFMUE7jVLAQQOAAXa1o9FQly3q3GnpHPLnkVwJ/D1vfVBnu8O4 xE= Received: (qmail 23360 invoked by alias); 17 Apr 2014 12:30:32 -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 23348 invoked by uid 89); 17 Apr 2014 12:30:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, MSGID_FROM_MTA_HEADER, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: e06smtp13.uk.ibm.com Received: from e06smtp13.uk.ibm.com (HELO e06smtp13.uk.ibm.com) (195.75.94.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 17 Apr 2014 12:30:31 +0000 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 17 Apr 2014 13:30:27 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 17 Apr 2014 13:30:26 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 8BF5E1B08051 for ; Thu, 17 Apr 2014 13:30:28 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps3074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s3HCUPZ966715716 for ; Thu, 17 Apr 2014 12:30:25 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s3HCUPA3014253 for ; Thu, 17 Apr 2014 06:30:25 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with SMTP id s3HCUOvU014206 for ; Thu, 17 Apr 2014 06:30:24 -0600 Message-Id: <201404171230.s3HCUOvU014206@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Thu, 17 Apr 2014 14:30:24 +0200 Subject: Enable DWARF unwinders for SPU To: gdb-patches@sourceware.org Date: Thu, 17 Apr 2014 14:30:24 +0200 (CEST) From: "Ulrich Weigand" MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14041712-2966-0000-0000-00000AF8C148 X-DH-Original-To: gdb@patchwork.siddhesh.in Hello, this patch enables use of DWARF unwinders for the SPU target. In addition to appending the DWARF unwinders, we also need to install a spu_dwarf_reg_to_regnum that maps the raw stack pointer register to the cooked version (to avoid mismatches with gdbarch_sp_regnum). This also causes confusion with the AX collect handling, so we also install ax_pseudo_register routines to handle the cooked SP. Tested on spu-elf, committed to mainline. Bye, Ulrich ChangeLog: * spu-tdep.c: Include "dwarf2-frame.h" and "ax.h". (spu_ax_pseudo_register_collect): New function. (spu_ax_pseudo_register_push_stack): Likewise. (spu_dwarf_reg_to_regnum): Likewise. (spu_gdbarch_init): Install them. Append DWARF unwinders. Index: binutils-gdb/gdb/spu-tdep.c =================================================================== --- binutils-gdb.orig/gdb/spu-tdep.c +++ binutils-gdb/gdb/spu-tdep.c @@ -44,6 +44,8 @@ #include "observer.h" #include "infcall.h" #include "dwarf2.h" +#include "dwarf2-frame.h" +#include "ax.h" #include "exceptions.h" #include "spu-tdep.h" @@ -311,6 +313,51 @@ spu_pseudo_register_write (struct gdbarc } } +static int +spu_ax_pseudo_register_collect (struct gdbarch *gdbarch, + struct agent_expr *ax, int regnum) +{ + switch (regnum) + { + case SPU_SP_REGNUM: + ax_reg_mask (ax, SPU_RAW_SP_REGNUM); + return 0; + + case SPU_FPSCR_REGNUM: + case SPU_SRR0_REGNUM: + case SPU_LSLR_REGNUM: + case SPU_DECR_REGNUM: + case SPU_DECR_STATUS_REGNUM: + return -1; + + default: + internal_error (__FILE__, __LINE__, _("invalid regnum")); + } +} + +static int +spu_ax_pseudo_register_push_stack (struct gdbarch *gdbarch, + struct agent_expr *ax, int regnum) +{ + switch (regnum) + { + case SPU_SP_REGNUM: + ax_reg (ax, SPU_RAW_SP_REGNUM); + return 0; + + case SPU_FPSCR_REGNUM: + case SPU_SRR0_REGNUM: + case SPU_LSLR_REGNUM: + case SPU_DECR_REGNUM: + case SPU_DECR_STATUS_REGNUM: + return -1; + + default: + internal_error (__FILE__, __LINE__, _("invalid regnum")); + } +} + + /* Value conversion -- access scalar values at the preferred slot. */ static struct value * @@ -352,6 +399,15 @@ spu_register_reggroup_p (struct gdbarch return default_register_reggroup_p (gdbarch, regnum, group); } +/* DWARF-2 register numbers. */ + +static int +spu_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg) +{ + /* Use cooked instead of raw SP. */ + return (reg == SPU_RAW_SP_REGNUM)? SPU_SP_REGNUM : reg; +} + /* Address handling. */ @@ -2680,6 +2736,11 @@ spu_gdbarch_init (struct gdbarch_info in set_gdbarch_pseudo_register_write (gdbarch, spu_pseudo_register_write); set_gdbarch_value_from_register (gdbarch, spu_value_from_register); set_gdbarch_register_reggroup_p (gdbarch, spu_register_reggroup_p); + set_gdbarch_dwarf2_reg_to_regnum (gdbarch, spu_dwarf_reg_to_regnum); + set_gdbarch_ax_pseudo_register_collect + (gdbarch, spu_ax_pseudo_register_collect); + set_gdbarch_ax_pseudo_register_push_stack + (gdbarch, spu_ax_pseudo_register_push_stack); /* Data types. */ set_gdbarch_char_signed (gdbarch, 0); @@ -2718,6 +2779,7 @@ spu_gdbarch_init (struct gdbarch_info in /* Frame handling. */ set_gdbarch_inner_than (gdbarch, core_addr_lessthan); + dwarf2_append_unwinders (gdbarch); frame_unwind_append_unwinder (gdbarch, &spu_frame_unwind); frame_base_set_default (gdbarch, &spu_frame_base); set_gdbarch_unwind_pc (gdbarch, spu_unwind_pc);