diff --git a/diskdump.c b/diskdump.c index bec0d82e..3ae7bf2d 100644 --- a/diskdump.c +++ b/diskdump.c @@ -2648,6 +2648,9 @@ diskdump_display_regs(int cpu, FILE *ofp) if (machine_type("MIPS64")) mips64_display_regs_from_elf_notes(cpu, ofp); + + if (machine_type("LOONGARCH64")) + loongarch64_display_regs_from_elf_notes(cpu, ofp); } void @@ -2659,7 +2662,7 @@ dump_registers_for_compressed_kdump(void) !(machine_type("X86") || machine_type("X86_64") || machine_type("ARM64") || machine_type("PPC64") || machine_type("MIPS") || machine_type("MIPS64") || - machine_type("RISCV64"))) + machine_type("RISCV64") || machine_type("LOONGARCH64"))) error(FATAL, "-r option not supported for this dumpfile\n"); if (machine_type("ARM64") && (kt->cpus != dd->num_prstatus_notes)) diff --git a/loongarch64.c b/loongarch64.c index 2624c9ba..5c19933e 100644 --- a/loongarch64.c +++ b/loongarch64.c @@ -1269,6 +1269,75 @@ loongarch64_init(int when) void loongarch64_display_regs_from_elf_notes(int cpu, FILE *ofp) { + const struct machine_specific *ms = machdep->machspec; + struct loongarch64_pt_regs *regs; + + if (!ms->crash_task_regs) { + error(INFO, "registers not collected for cpu %d\n", cpu); + return; + } + + regs = &ms->crash_task_regs[cpu]; + if (!regs->regs[LOONGARCH64_EF_SP] && !regs->csr_epc) { + error(INFO, "registers not collected for cpu %d\n", cpu); + return; + } + + fprintf(ofp, + " R0: %016lx R1: %016lx R2: %016lx\n" + " R3: %016lx R4: %016lx R5: %016lx\n" + " R6: %016lx R7: %016lx R8: %016lx\n" + " R9: %016lx R10: %016lx R11: %016lx\n" + " R12: %016lx R13: %016lx R14: %016lx\n" + " R15: %016lx R16: %016lx R17: %016lx\n" + " R18: %016lx R19: %016lx R20: %016lx\n" + " R21: %016lx R22: %016lx R23: %016lx\n" + " R24: %016lx R25: %016lx R26: %016lx\n" + " R27: %016lx R28: %016lx R29: %016lx\n" + " R30: %016lx R31: %016lx\n" + " CSR epc : %016lx CSR badv: %016lx\n" + " CSR crmd: %08lx CSR prmd: %08lx\n" + " CSR ecfg: %08lx CSR estat: %08lx\n" + " CSR eneu: %08lx", + regs->regs[LOONGARCH64_EF_R0], + regs->regs[LOONGARCH64_EF_R0 + 1], + regs->regs[LOONGARCH64_EF_R0 + 2], + regs->regs[LOONGARCH64_EF_R0 + 3], + regs->regs[LOONGARCH64_EF_R0 + 4], + regs->regs[LOONGARCH64_EF_R0 + 5], + regs->regs[LOONGARCH64_EF_R0 + 6], + regs->regs[LOONGARCH64_EF_R0 + 7], + regs->regs[LOONGARCH64_EF_R0 + 8], + regs->regs[LOONGARCH64_EF_R0 + 9], + regs->regs[LOONGARCH64_EF_R0 + 10], + regs->regs[LOONGARCH64_EF_R0 + 11], + regs->regs[LOONGARCH64_EF_R0 + 12], + regs->regs[LOONGARCH64_EF_R0 + 13], + regs->regs[LOONGARCH64_EF_R0 + 14], + regs->regs[LOONGARCH64_EF_R0 + 15], + regs->regs[LOONGARCH64_EF_R0 + 16], + regs->regs[LOONGARCH64_EF_R0 + 17], + regs->regs[LOONGARCH64_EF_R0 + 18], + regs->regs[LOONGARCH64_EF_R0 + 19], + regs->regs[LOONGARCH64_EF_R0 + 20], + regs->regs[LOONGARCH64_EF_R0 + 21], + regs->regs[LOONGARCH64_EF_R0 + 22], + regs->regs[LOONGARCH64_EF_R0 + 23], + regs->regs[LOONGARCH64_EF_R0 + 24], + regs->regs[LOONGARCH64_EF_R0 + 25], + regs->regs[LOONGARCH64_EF_R0 + 26], + regs->regs[LOONGARCH64_EF_R0 + 27], + regs->regs[LOONGARCH64_EF_R0 + 28], + regs->regs[LOONGARCH64_EF_R0 + 29], + regs->regs[LOONGARCH64_EF_R0 + 30], + regs->regs[LOONGARCH64_EF_R0 + 31], + regs->csr_epc, + regs->csr_badvaddr, + regs->csr_crmd, + regs->csr_prmd, + regs->csr_ecfg, + regs->csr_estat, + regs->csr_euen); } #else /* !LOONGARCH64 */ diff --git a/netdump.c b/netdump.c index dbcf253c..b4e2a5cb 100644 --- a/netdump.c +++ b/netdump.c @@ -2961,6 +2961,8 @@ display_regs_from_elf_notes(int cpu, FILE *ofp) mips64_display_regs_from_elf_notes(cpu, ofp); } else if (machine_type("RISCV64")) { riscv64_display_regs_from_elf_notes(cpu, ofp); + } else if (machine_type("LOONGARCH64")) { + loongarch64_display_regs_from_elf_notes(cpu, ofp); } } @@ -2972,7 +2974,7 @@ dump_registers_for_elf_dumpfiles(void) if (!(machine_type("X86") || machine_type("X86_64") || machine_type("ARM64") || machine_type("PPC64") || machine_type("MIPS") || machine_type("MIPS64") || - machine_type("RISCV64"))) + machine_type("RISCV64") || machine_type("LOONGARCH64"))) error(FATAL, "-r option not supported for this dumpfile\n"); if (NETDUMP_DUMPFILE()) {