From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26659 invoked by alias); 1 Dec 2004 04:57:34 -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 26616 invoked from network); 1 Dec 2004 04:57:26 -0000 Received: from unknown (HELO priv-edtnes56.telusplanet.net) (199.185.220.220) by sourceware.org with SMTP; 1 Dec 2004 04:57:26 -0000 Received: from takamaka.act-europe.fr ([142.179.108.108]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.03.02 201-2131-111-104-20040324) with ESMTP id <20041201045725.XMC21390.priv-edtnes56.telusplanet.net@takamaka.act-europe.fr> for ; Tue, 30 Nov 2004 21:57:25 -0700 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 74A8E47DA6; Tue, 30 Nov 2004 20:57:25 -0800 (PST) Date: Wed, 01 Dec 2004 04:57:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: Re: [RFA/alpha] Fix problem loading core files Message-ID: <20041201045725.GQ1204@adacore.com> References: <20041201043106.GP1204@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="DKU6Jbt7q3WqK7+M" Content-Disposition: inline In-Reply-To: <20041201043106.GP1204@adacore.com> User-Agent: Mutt/1.4i X-SW-Source: 2004-12/txt/msg00008.txt.bz2 --DKU6Jbt7q3WqK7+M Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 3684 [With the patch, this time. Thanks Daniel!] I noticed that GDB is no longer able to load the registers from a core file: (gdb) core core OK -> Core was generated by `crash'. OK -> Program terminated with signal 6, Aborted. !?! -> Register not found in core file. That lead me to a couple of issues. First, in fetch_osf_core_registers() in alpha-nat.c; we have an array named core_reg_mapping[ALPHA_NUM_REGS] which value is statically defined (minus a #if ... #else ... #endif twist): static int const core_reg_mapping[ALPHA_NUM_REGS] = { #ifdef NCF_REGS #define EFL NCF_REGS CF_V0, CF_T0, CF_T1, CF_T2, CF_T3, CF_T4, CF_T5, CF_T6, [...]. The problem is that ALPHA_NUM_REGS has been incremented on 2003-01-31: * alpha-nat.c (REGISTER_PTRACE_ADDR): Merge into ... (register_addr): ... here. Support ALPHA_UNIQUE_REGNUM. (fetch_elf_core_registers): Support ALPHA_UNIQUE_REGNUM. * alpha-tdep.c (alpha_register_name): Add "unique". * alpha-tdep.h (ALPHA_NUM_REGS): Increment. (ALPHA_UNIQUE_REGNUM): New. * config/alpha/nm-linux.h (ALPHA_UNIQUE_PTRACE_ADDR): New. But the table was not updated in consequence. So I added an index of -1 for this extra register in the table. So the number of elements in the value matches the number of elements declared. But that was not the problem that caused the error above. What happens is that we removed a vitual register on 2003-06-01: * alpha-tdep.h (ALPHA_FP_REGNUM): Remove. * alpha-tdep.c (alpha_register_name): Remove vfp entry. (alpha_cannot_fetch_register): Remove ALPHA_FP_REGNUM. (alpha_cannot_store_register): Likewise. * alphabsd-nat.c (fetch_inferior_registers): Don't set FP_REGNUM. * alpha-nat.c (supply_gregset): Likewise. * alphanbsd-tdep.c (fetch_core_registers): Likewise. The register index was kept reserved to maintain compatibility with alpha remote debug agents. But the problem is that now alpha_cannot_fetch_register() considers this old register as fetchable, which is not true. As a consequence, fetch_osf_core_registers() finds an inconsistency because on the one hand it has a negative offset (-1), and on the other hand it has a register that presumably is fetchable. And hence we get the error. This patch modified alpha_cannot_fetch_register() and alpha_cannot_store_register() to exclude the register which have an empty name. These empty names are the sign of a register number that is no longer used, but has been reserved to maintain compatibility with remote debug agents. 2004-11-30 Joel Brobecker * alpha-tdep.c (alpha_register_name): Add comment. (alpha_cannot_fetch_register): Exclude register number which are no longer used from the list of registers that can be fetched. (alpha_cannot_store_register): Exclude register number which are no longer used from the list of registers that can be stored. Tested on alpha-tru64. Makes the following changes to the testsuite results: * gdb.base: +------------+------------+----------------------------------------------------+ | FAIL | PASS | corefile.exp: args: -core=corefile | | FAIL | PASS | corefile.exp: args: execfile -core=corefile | | FAIL | PASS | corefile.exp: core-file command | | FAIL | PASS | corefile.exp: print func2::coremaker_local | | FAIL | PASS | corefile.exp: backtrace in corefile.exp | +------------+------------+----------------------------------------------------+ OK to apply? Thanks, -- Joel --DKU6Jbt7q3WqK7+M Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="core.diff" Content-length: 2239 Index: alpha-tdep.c =================================================================== RCS file: /nile.c/cvs/Dev/gdb/gdb-6.3/gdb/alpha-tdep.c,v retrieving revision 1.2 diff -u -p -r1.2 alpha-tdep.c --- alpha-tdep.c 1 Dec 2004 01:52:42 -0000 1.2 +++ alpha-tdep.c 1 Dec 2004 01:58:08 -0000 @@ -47,6 +47,13 @@ #include "alpha-tdep.h" +/* Return the name of the REGNO register. + + An empty name correspond to a register number that used to + be used for a virtual register. That virtual register has + been removed, but the index is still reserved to maintain + compatibility with existing remote alpha targets. */ + static const char * alpha_register_name (int regno) { @@ -73,13 +80,15 @@ alpha_register_name (int regno) static int alpha_cannot_fetch_register (int regno) { - return regno == ALPHA_ZERO_REGNUM; + return (regno == ALPHA_ZERO_REGNUM + || strlen (alpha_register_name (regno)) == 0); } static int alpha_cannot_store_register (int regno) { - return regno == ALPHA_ZERO_REGNUM; + return (regno == ALPHA_ZERO_REGNUM + || strlen (alpha_register_name (regno)) == 0); } static struct type * Index: alpha-nat.c =================================================================== RCS file: /nile.c/cvs/Dev/gdb/gdb-6.3/gdb/alpha-nat.c,v retrieving revision 1.1 diff -u -p -r1.1 alpha-nat.c --- alpha-nat.c 20 Oct 2004 23:11:33 -0000 1.1 +++ alpha-nat.c 1 Dec 2004 01:58:08 -0000 @@ -80,7 +80,7 @@ fetch_osf_core_registers (char *core_reg EFL + 8, EFL + 9, EFL + 10, EFL + 11, EFL + 12, EFL + 13, EFL + 14, EFL + 15, EFL + 16, EFL + 17, EFL + 18, EFL + 19, EFL + 20, EFL + 21, EFL + 22, EFL + 23, EFL + 24, EFL + 25, EFL + 26, EFL + 27, EFL + 28, EFL + 29, EFL + 30, EFL + 31, - CF_PC, -1 + CF_PC, -1, -1 #else #define EFL (EF_SIZE / 8) EF_V0, EF_T0, EF_T1, EF_T2, EF_T3, EF_T4, EF_T5, EF_T6, @@ -91,7 +91,7 @@ fetch_osf_core_registers (char *core_reg EFL + 8, EFL + 9, EFL + 10, EFL + 11, EFL + 12, EFL + 13, EFL + 14, EFL + 15, EFL + 16, EFL + 17, EFL + 18, EFL + 19, EFL + 20, EFL + 21, EFL + 22, EFL + 23, EFL + 24, EFL + 25, EFL + 26, EFL + 27, EFL + 28, EFL + 29, EFL + 30, EFL + 31, - EF_PC, -1 + EF_PC, -1, -1 #endif }; --DKU6Jbt7q3WqK7+M--