From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6701 invoked by alias); 3 Sep 2005 01:10:07 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 5882 invoked by uid 22791); 3 Sep 2005 01:09:23 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Sat, 03 Sep 2005 01:09:23 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j8319LMf011548 for ; Fri, 2 Sep 2005 21:09:21 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j8319LV06455; Fri, 2 Sep 2005 21:09:21 -0400 Received: from localhost.localdomain (vpn50-99.rdu.redhat.com [172.16.50.99]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id j8319KHW032060; Fri, 2 Sep 2005 21:09:21 -0400 Received: from ironwood.lan (ironwood.lan [192.168.64.8]) by localhost.localdomain (8.12.11/8.12.10) with ESMTP id j8319FkE007327; Fri, 2 Sep 2005 18:09:15 -0700 Date: Sat, 03 Sep 2005 01:10:00 -0000 From: Kevin Buettner To: gdb-patches@sources.redhat.com Cc: Michael Snyder Subject: [commit] mn10300: Register a dwarf2_reg_to_regnum function Message-ID: <20050902180915.07468bb1@ironwood.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SW-Source: 2005-09/txt/msg00017.txt.bz2 I've just committed the change below. This code used to be in the old version of mn10300-tdep.c. It's absence from the current version of mn10300-tdep.c is an oversight. When I asked Michael Snyder about it a while back, he asked me to reinstate it. So here it is... * mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): New function. (mn10300_gdbarch_init): Register mn10300_dwarf2_reg_to_regnum(). Index: mn10300-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/mn10300-tdep.c,v retrieving revision 1.128 diff -u -p -r1.128 mn10300-tdep.c --- mn10300-tdep.c 3 Sep 2005 00:49:06 -0000 1.128 +++ mn10300-tdep.c 3 Sep 2005 01:02:48 -0000 @@ -937,6 +937,37 @@ mn10300_push_dummy_call (struct gdbarch return sp; } +/* If DWARF2 is a register number appearing in Dwarf2 debug info, then + mn10300_dwarf2_reg_to_regnum (DWARF2) is the corresponding GDB + register number. Why don't Dwarf2 and GDB use the same numbering? + Who knows? But since people have object files lying around with + the existing Dwarf2 numbering, and other people have written stubs + to work with the existing GDB, neither of them can change. So we + just have to cope. */ +static int +mn10300_dwarf2_reg_to_regnum (int dwarf2) +{ + /* This table is supposed to be shaped like the REGISTER_NAMES + initializer in gcc/config/mn10300/mn10300.h. Registers which + appear in GCC's numbering, but have no counterpart in GDB's + world, are marked with a -1. */ + static int dwarf2_to_gdb[] = { + 0, 1, 2, 3, 4, 5, 6, 7, -1, 8, + 15, 16, 17, 18, 19, 20, 21, 22, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 + }; + + if (dwarf2 < 0 + || dwarf2 >= (sizeof (dwarf2_to_gdb) / sizeof (dwarf2_to_gdb[0])) + || dwarf2_to_gdb[dwarf2] == -1) + internal_error (__FILE__, __LINE__, + "bogus register number in debug info: %d", dwarf2); + + return dwarf2_to_gdb[dwarf2]; +} static struct gdbarch * mn10300_gdbarch_init (struct gdbarch_info info, @@ -977,6 +1008,7 @@ mn10300_gdbarch_init (struct gdbarch_inf set_gdbarch_write_pc (gdbarch, mn10300_write_pc); set_gdbarch_pc_regnum (gdbarch, E_PC_REGNUM); set_gdbarch_sp_regnum (gdbarch, E_SP_REGNUM); + set_gdbarch_dwarf2_reg_to_regnum (gdbarch, mn10300_dwarf2_reg_to_regnum); /* Stack unwinding. */ set_gdbarch_inner_than (gdbarch, core_addr_lessthan);