[PATCH V2 0/2] Add C-SKY support
Mao Han
han_mao@c-sky.com
Wed Apr 17 06:45:00 GMT 2019
On Sun, Apr 14, 2019 at 10:23:49PM +0200, Mark Wielaard wrote:
> It is hard to say what went wrong.
> In theory you can examine the executable and core file cross arch, if
> there is backend support. So if you could post a small binary and a
> core file for it somewhere we can try debugging together.
>
> Try something like:
> $ ulimit -c unlimited
> $ echo "int main () { int i = 1; i /= i - 1; }" | gcc -xc -static -o divzero -
> $ ./divzero
> Floating point exception (core dumped)
> $ eu-stack --core core.18678 --exec divzero
> PID 18678 - core
> TID 18678:
> #0 0x0000000000400ff3 main
> #1 0x00000000004011e4 generic_start_main
> #2 0x0000000000401461 __libc_start_main
> #3 0x0000000000400ef6 _start
>
> If you could run that on your C-SKY setup and post the (static) binary
> and core file somewhere (they are probably too big for the mailinglist.
>
I'v just spent sometime debuging this. Core dump backtrace on C-SKY seems
can't be supported with current generic routine. DWARF register order is
different from the order in core notes. The initialization of frame
registers is totally incorrect. As the comment says some fix with
private function is needed.
# eu-stack --core core
PID 140 - core
TID 140:
#0 0x0000000000136bd2
eu-stack: dwfl_thread_getframes tid 140 at 0x136bd2 in <unknown>: No DWARF information found
./libdwfl/linux-core-attach.cï¼260
/* PPC provides DWARF register 65 irrelevant for
CFI which clashes with register 108 (LR) we need.
LR (108) is provided earlier (in NT_PRSTATUS) than the # 65.
FIXME: It depends now on their order in core notes.
FIXME: It uses private function. */
if (regno < nregs
&& __libdwfl_frame_reg_get (thread->unwound, regno, NULL))
continue;
Dwarf_Word val;
switch (regloc->bits)
linux/arch/csky/abiv2/inc/abi/elf.h
#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \
pr_reg[0] = regs->pc; \
pr_reg[1] = regs->a1; \
pr_reg[2] = regs->a0; \
pr_reg[3] = regs->sr; \
pr_reg[4] = regs->a2; \
pr_reg[5] = regs->a3; \
pr_reg[6] = regs->regs[0]; \
pr_reg[7] = regs->regs[1]; \
pr_reg[8] = regs->regs[2]; \
pr_reg[9] = regs->regs[3]; \
pr_reg[10] = regs->regs[4]; \
pr_reg[11] = regs->regs[5]; \
pr_reg[12] = regs->regs[6]; \
pr_reg[13] = regs->regs[7]; \
pr_reg[14] = regs->regs[8]; \
pr_reg[15] = regs->regs[9]; \
BTW the error log seems incorrect here.
diff --git a/src/stack.c b/src/stack.c
index c5f347e..4daabce 100644
--- a/src/stack.c
+++ b/src/stack.c
@@ -608,7 +608,7 @@ parse_opt (int key, char *arg __attribute__ ((unused)),
if (core != NULL)
{
if (dwfl_core_file_attach (dwfl, core) < 0)
- error (EXIT_BAD, 0, "dwfl_core_file_report: %s", dwfl_errmsg (-1));
+ error (EXIT_BAD, 0, "dwfl_core_file_attach: %s", dwfl_errmsg (-1));
}
/* Makes sure we are properly attached. */
Thanks,
Mao Han
More information about the Elfutils-devel
mailing list