From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27812 invoked by alias); 12 Feb 2014 12:42:16 -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 27735 invoked by uid 89); 12 Feb 2014 12:42:16 -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,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Feb 2014 12:42:14 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1CCgBje017366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 12 Feb 2014 07:42:12 -0500 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1CCg751000516; Wed, 12 Feb 2014 07:42:09 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Cc: Yoshinori Sato , Mark Kettenis Subject: [PATCH 1/2] H8/300: Fix gdb<->sim register mapping. Date: Wed, 12 Feb 2014 12:42:00 -0000 Message-Id: <1392208927-15739-2-git-send-email-palves@redhat.com> In-Reply-To: <1392208927-15739-1-git-send-email-palves@redhat.com> References: <87y51hiyjt.wl%ysato@users.sourceforge.jp> <1392208927-15739-1-git-send-email-palves@redhat.com> X-SW-Source: 2014-02/txt/msg00405.txt.bz2 Currently, printing the H8/300 ccr register when debugging with the sim is broken: (gdb) target sim ... (gdb) load ... (gdb) start ... Breakpoint 1, foo (i=0x0 ) at main.c:4 4 { (gdb) info registers ccr Register 13 is not available '13' is the ccr pseudo-register. This pseudo-register provides an 8-bit view into the raw ccr register (regno=8). The problem is that the H8/300 port does not define a register_sim_regno gdbarch hook, and thus when fetching the raw register off of the sim, we end up in legacy_register_sim_regno trying to figure out the sim register number for the raw CCR register: int legacy_register_sim_regno (struct gdbarch *gdbarch, int regnum) { /* Only makes sense to supply raw registers. */ gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch)); /* NOTE: cagney/2002-05-13: The old code did it this way and it is suspected that some GDB/SIM combinations may rely on this behavour. The default should be one2one_register_sim_regno (below). */ if (gdbarch_register_name (gdbarch, regnum) != NULL && gdbarch_register_name (gdbarch, regnum)[0] != '\0') return regnum; else return LEGACY_SIM_REGNO_IGNORE; } Because the raw ccr register does not have a name (so that it is hidden from the user), that returns LEGACY_SIM_REGNO_IGNORE. That means that we never actually read the value of the raw ccr register. Before the support, this must have meant that ccr was _always_ read as 0... At least, I'm not seeing how this ever worked. The fix for that is adding a gdbarch_register_sim_regno hook that maps all raw registers. Looking at sim/h8300/sim-main.h, I believe the sim's register numbers are compatible with gdb's, so no actual convertion is necessary. gdb/ 2014-02-12 Pedro Alves * h8300-tdep.c (h8300_register_sim_regno): New function. (h8300_gdbarch_init): Install h8300_register_sim_regno as gdbarch_register_sim_regno hook. --- gdb/ChangeLog | 6 ++++++ gdb/h8300-tdep.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bb977b5..6f0f903 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2014-02-12 Pedro Alves + + * h8300-tdep.c (h8300_register_sim_regno): New function. + (h8300_gdbarch_init): Install h8300_register_sim_regno as + gdbarch_register_sim_regno hook. + 2014-02-12 Sanimir Agovic * nios2-tdep.c (nios2_stub_frame_base): Remove global. diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c index ffffbc9..4193287 100644 --- a/gdb/h8300-tdep.c +++ b/gdb/h8300-tdep.c @@ -939,6 +939,22 @@ h8300h_return_value (struct gdbarch *gdbarch, struct value *function, static struct cmd_list_element *setmachinelist; +/* Implementation of 'register_sim_regno' gdbarch method. */ + +static int +h8300_register_sim_regno (struct gdbarch *gdbarch, int regnum) +{ + /* Only makes sense to supply raw registers. */ + gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch)); + + /* We hide the raw ccr from the user by making it nameless. Because + the default register_sim_regno hook returns + LEGACY_SIM_REGNO_IGNORE for unnamed registers, we need to + override it. The sim register numbering is compatible with + gdb's. */ + return regnum; +} + static const char * h8300_register_name (struct gdbarch *gdbarch, int regno) { @@ -1230,6 +1246,8 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) gdbarch = gdbarch_alloc (&info, 0); + set_gdbarch_register_sim_regno (gdbarch, h8300_register_sim_regno); + switch (info.bfd_arch_info->mach) { case bfd_mach_h8300: -- 1.7.11.7