Re: Can't debug core files with GDB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx> 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



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux