From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1464 invoked by alias); 30 Apr 2002 12:28:01 -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 1427 invoked from network); 30 Apr 2002 12:27:59 -0000 Received: from unknown (HELO kerberos.suse.cz) (195.47.106.10) by sources.redhat.com with SMTP; 30 Apr 2002 12:27:59 -0000 Received: from chimera.suse.cz (chimera.suse.cz [10.20.0.2]) by kerberos.suse.cz (SuSE SMTP server) with ESMTP id 03E0559D349 for ; Tue, 30 Apr 2002 14:27:59 +0200 (CEST) Received: from suse.cz (leviathan.suse.cz [10.20.1.56]) by chimera.suse.cz (8.11.0/8.11.0/SuSE Linux 8.11.0-0.4) with ESMTP id g3UCRwf03165 for ; Tue, 30 Apr 2002 14:27:58 +0200 X-Authentication-Warning: chimera.suse.cz: Host leviathan.suse.cz [10.20.1.56] claimed to be suse.cz Message-ID: <3CCE8DC4.2080100@suse.cz> Date: Tue, 30 Apr 2002 05:28:00 -0000 From: Michal Ludvig Organization: SuSE CR User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0rc1) Gecko/20020417 X-Accept-Language: cs, cz, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [RFA] x86-64 dwarf2 regnum mapping Content-Type: multipart/mixed; boundary="------------070806030107000208080803" X-SW-Source: 2002-04/txt/msg01153.txt.bz2 This is a multi-part message in MIME format. --------------070806030107000208080803 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit Content-length: 433 Hi, This patch adds mapping from dwarf2 register numbers to gdb ones. Surprisingly enough this important part was missing... Can I commit to mainline and branch? BTW Is there a reason why the place where all those set_gdbarch_whatever functions are called is named i386_gdbarch_init and not x86_64_gdbarch_init? Can I rename it? Michal Ludvig -- * SuSE CR, s.r.o * mludvig@suse.cz * +420 2 9654 5373 * http://www.suse.cz --------------070806030107000208080803 Content-Type: text/plain; name="dwarf2regnum.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="dwarf2regnum.diff" Content-length: 2994 2002-04-30 Michal Ludvig * x86-64-tdep.c (x86_64_dwarf2gdb_regno_map), (x86_64_dwarf2gdb_regno_map_length), (x86_64_dwarf2_reg_to_regnum): Added. (i386_gdbarch_init): Added registration of x86_64_dwarf2_reg_to_regnum. Index: x86-64-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v retrieving revision 1.15 diff -c -3 -p -r1.15 x86-64-tdep.c *** x86-64-tdep.c 29 Apr 2002 18:27:31 -0000 1.15 --- x86-64-tdep.c 30 Apr 2002 12:04:15 -0000 *************** *** 37,42 **** --- 37,43 ---- #define RDX_REGNUM 3 #define RDI_REGNUM 5 #define EFLAGS_REGNUM 17 + #define ST0_REGNUM 22 #define XMM1_REGNUM 39 struct register_info *************** static struct register_info x86_64_regis *** 106,111 **** --- 107,139 ---- /* 54 */ {4, "mxcsr", &builtin_type_int32} }; + /* This array is a mapping from Dwarf-2 register + numbering to GDB's one. Dwarf-2 numbering is + defined in x86-64 ABI, section 3.6. */ + static int x86_64_dwarf2gdb_regno_map[] = { + 0, 1, 2, 3, /* RAX - RDX */ + 6, 4, 5, 7, /* RBP, RSI, RDI, RSP */ + 8, 9, 10, 11, /* R8 - R11 */ + 12, 13, 14, 15, /* R12 - R15 */ + -1, /* RA - not mapped */ + XMM1_REGNUM - 1, XMM1_REGNUM, /* XMM0 ... */ + XMM1_REGNUM + 1, XMM1_REGNUM + 2, + XMM1_REGNUM + 3, XMM1_REGNUM + 4, + XMM1_REGNUM + 5, XMM1_REGNUM + 6, + XMM1_REGNUM + 7, XMM1_REGNUM + 8, + XMM1_REGNUM + 9, XMM1_REGNUM + 10, + XMM1_REGNUM + 11, XMM1_REGNUM + 12, + XMM1_REGNUM + 13, XMM1_REGNUM + 14, /* ... XMM15 */ + ST0_REGNUM + 0, ST0_REGNUM + 1, /* ST0 ... */ + ST0_REGNUM + 2, ST0_REGNUM + 3, + ST0_REGNUM + 4, ST0_REGNUM + 5, + ST0_REGNUM + 6, ST0_REGNUM + 7 /* ... ST7 */ + }; + + static int x86_64_dwarf2gdb_regno_map_length = + sizeof (x86_64_dwarf2gdb_regno_map) / + sizeof (x86_64_dwarf2gdb_regno_map[0]); + /* Number of all registers */ #define X86_64_NUM_REGS (sizeof (x86_64_register_info_table) / \ sizeof (x86_64_register_info_table[0])) *************** x86_64_register_convert_to_raw (struct t *** 198,203 **** --- 226,244 ---- memcpy (to, from, FPU_REG_RAW_SIZE); } + /* Dwarf-2 <-> GDB register numbers mapping. */ + int + x86_64_dwarf2_reg_to_regnum (int dw_reg) + { + if (dw_reg < 0 || dw_reg > x86_64_dwarf2gdb_regno_map_length) + { + warning ("Dwarf-2 uses unmapped register #%d\n", dw_reg); + return dw_reg; + } + + return x86_64_dwarf2gdb_regno_map[dw_reg]; + } + /* This is the variable that is set with "set disassembly-flavour", and its legitimate values. */ static const char att_flavour[] = "att"; *************** i386_gdbarch_init (struct gdbarch_info i *** 1075,1080 **** --- 1116,1123 ---- /* Use dwarf2 debug frame informations. */ set_gdbarch_dwarf2_build_frame_info (gdbarch, dwarf2_build_frame_info); + set_gdbarch_dwarf2_reg_to_regnum (gdbarch, x86_64_dwarf2_reg_to_regnum); + return gdbarch; } --------------070806030107000208080803--