[Crash-utility] [PATCH 3/3] mips: use get_stackframe() implementation from ARM

Rabin Vincent rabin at rab.in
Wed Oct 19 21:15:33 UTC 2016


On Wed, Oct 19, 2016 at 09:56:08AM -0400, Dave Anderson wrote:
> But with the patch installed, both dumpfiles show the "WARNING: cannot
> retrieve registers for active task" during initialization, and "bt" fails
> as expected:

Right, thanks for catching this.  The code borrowed from ARM assumes
that the kernel was built with core dump support, which is not
necessarily the case if the dump was saved via some external means which
creates ELF dumps (QEMU in the case of my example dumps).

Folding in the following patch makes it work for both the example dumps
you have and dumps with crash_notes.  Thanks.

8<----
>From fd9cec4ae5e5f310e3de073e66825b7b9df07573 Mon Sep 17 00:00:00 2001
From: Rabin Vincent <rabinv at axis.com>
Date: Wed, 19 Oct 2016 21:18:31 +0200
Subject: [PATCH] mips: get regs from ELF notes if no crash_notes

---
 mips.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/mips.c b/mips.c
index e3f1569..4eeab55 100644
--- a/mips.c
+++ b/mips.c
@@ -898,6 +898,54 @@ fail:
 	return FALSE;
 }
 
+static int mips_get_elf_notes(void)
+{
+	struct machine_specific *ms = machdep->machspec;
+	int i;
+
+	if (!DISKDUMP_DUMPFILE() && !KDUMP_DUMPFILE())
+		return FALSE;
+
+	panic_task_regs = calloc(kt->cpus, sizeof(*panic_task_regs));
+	if (!panic_task_regs)
+		error(FATAL, "cannot calloc panic_task_regs space\n");
+
+	for (i = 0; i < kt->cpus; i++) {
+		Elf32_Nhdr *note = NULL;
+		size_t len;
+
+		if (DISKDUMP_DUMPFILE())
+			note = diskdump_get_prstatus_percpu(i);
+		else if (KDUMP_DUMPFILE())
+			note = netdump_get_prstatus_percpu(i);
+
+		if (!note)
+			error(WARNING,
+			      "cannot find NT_PRSTATUS note for cpu: %d\n", i);
+
+		len = sizeof(Elf32_Nhdr);
+		len = roundup(len + note->n_namesz, 4);
+
+		BCOPY((char *)note + len + OFFSET(elf_prstatus_pr_reg),
+		      &panic_task_regs[i], sizeof(panic_task_regs[i]));
+	}
+
+	ms->crash_task_regs = panic_task_regs;
+
+	return TRUE;
+}
+
+static int mips_init_active_task_regs(void)
+{
+	int retval;
+
+	retval = mips_get_crash_notes();
+	if (retval == TRUE)
+		return retval;
+
+	return mips_get_elf_notes();
+}
+
 static int
 mips_verify_symbol(const char *name, ulong value, char type)
 {
@@ -1075,7 +1123,7 @@ mips_init(int when)
 		 * of the crash. We need this information to extract correct
 		 * backtraces from the panic task.
 		 */
-		if (!ACTIVE() && !mips_get_crash_notes())
+		if (!ACTIVE() && !mips_init_active_task_regs())
 			error(WARNING,
 			    "cannot retrieve registers for active task%s\n\n",
 				kt->cpus > 1 ? "s" : "");
-- 
2.1.4




More information about the Crash-utility mailing list