linux-mips
[Top] [All Lists]

Re: Can't debug core files with GDB

To: "Daniel Jacobowitz" <dan@debian.org>
Subject: Re: Can't debug core files with GDB
From: "Tony Lin" <lin.tony@gmail.com>
Date: Thu, 25 May 2006 17:50:56 -0700
Cc: "ashley jones" <ashley_jones_2000@yahoo.com>, linux-mips@linux-mips.org
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Kqvl1/rL9t4GFTg9iYEXnNrgbla9Fl4QMOXu2dXpmOXsHjeu5u2FLO6nxINQ5+iAKQLJMf0XGUhqpU1w/BOil5XjY8PHGGtotAuOhE+opgQBKBUlaRKPBv7hezzuxU2GlNs4WUhEA6zXeF/6K4uJhMy3NR/2MYwe9gT5h8nvJYA=
In-reply-to: <20060525133529.GA31379@nevyn.them.org>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <404548f40605171139i67084776pd9ae7c34ec19ec95@mail.gmail.com> <20060524081406.90333.qmail@web38407.mail.mud.yahoo.com> <404548f40605241844y41b897b6sb8a7512feb8655f6@mail.gmail.com> <20060525133529.GA31379@nevyn.them.org>
Sender: linux-mips-bounce@linux-mips.org
Hmm... It looks like the output format changed between linux 2.4 ->
2.6. In 2.4's include/asm-mips/ptrace.h, we have:
struct pt_regs {
      /* Pad bytes for argument save space on the stack. */
      unsigned long pad0[6];

      /* Saved main processor registers. */
      unsigned long regs[32];

      /* Other saved registers. */
      unsigned long lo;
      unsigned long hi;

      /*
       * saved cp0 registers
       */
      unsigned long cp0_epc;
      unsigned long cp0_badvaddr;
      unsigned long cp0_status;
      unsigned long cp0_cause;

Then in 2.6, it changes to:
struct pt_regs {
#ifdef CONFIG_MIPS32
      /* Pad bytes for argument save space on the stack. */
      unsigned long pad0[6];
#endif

      /* Saved main processor registers. */
      unsigned long regs[32];

      /* Saved special registers. */
      unsigned long cp0_status;
      unsigned long lo;
      unsigned long hi;
      unsigned long cp0_badvaddr;
      unsigned long cp0_cause;
      unsigned long cp0_epc;
};

Notice how the offsets has changed, no idea why this was done. I
loaded the core file in the hex dump, and sure enough it is dumped
with this new ordering.

I guess gdb is still trying to decode using the old pt_regs format. Is
it correct to modify gdb to use this new format? Or modify linux to
output using the old format?

Thanks much,
- Tony

On 5/25/06, Daniel Jacobowitz <dan@debian.org> wrote:
On Wed, May 24, 2006 at 06:44:26PM -0700, Tony Lin wrote:
> I've pretty much concluded the gdb is not at fault. Loading a coredump
> generated by another mips-linux system, it was able to read the
> registers correctly and lookup the program counter.
>
> So the problem now is my 32-bit mips-linux is generating core files in
> a different format than what gdb expects. I've been digging into
> fs/exec.c and fs/binfmt_elf.c without much success. Are there
> documents describing the expected coredump header format?

No.  But...

> I'm not really familiar with the register terminology (fpu? xfpregs?)
> so am having some trouble figuring out where linux write the program
> counter into the core dump.

Take a look at asm-mips/elf.h and IIRC arch/mips/kernel/process.c.  Or,
trace the macros through binfmt_elf.c, where it creates NOTE sections.

--
Daniel Jacobowitz
CodeSourcery


<Prev in Thread] Current Thread [Next in Thread>