From 2b4d2eee5ff27e27de2f9ce277d2ae99cdd86898 Mon Sep 17 00:00:00 2001 From: Jim Cadden Date: Tue, 23 Jan 2018 17:58:52 -0500 Subject: [PATCH] refactor(debug): force print for abort messages --- src/hosted/Debug.h | 2 +- src/native/Idt.cc | 44 +++++++++++++++++++++++--------------------- src/native/Newlib.cc | 2 +- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/hosted/Debug.h b/src/hosted/Debug.h index 806f3f9d..6330835d 100644 --- a/src/hosted/Debug.h +++ b/src/hosted/Debug.h @@ -30,7 +30,7 @@ static __attribute__((noreturn)) void kabort() { abort(); } template __attribute__((noreturn)) void kabort(Args&&... args) { - kprintf(std::forward(args)...); // NOLINT + kprintf_force(std::forward(args)...); // NOLINT kabort(); } diff --git a/src/native/Idt.cc b/src/native/Idt.cc index da1f456b..3d86b618 100644 --- a/src/native/Idt.cc +++ b/src/native/Idt.cc @@ -114,26 +114,28 @@ extern "C" __attribute__((noreturn)) void ebbrt::idt::EventInterrupt(int num) { namespace { void PrintExceptionFrame(ebbrt::idt::ExceptionFrame* ef) { - ebbrt::kprintf("SS: %#018" PRIx64 " RSP: %#018" PRIx64 "\n", ef->ss, ef->rsp); - ebbrt::kprintf("FLAGS: %#018" PRIx64 "\n", - ef->rflags); // TODO(Dschatz): print out actual meaning - ebbrt::kprintf("CS: %#018" PRIx64 " RIP: %#018" PRIx64 "\n", ef->cs, ef->rip); - ebbrt::kprintf("Error Code: %" PRIx64 "\n", ef->error_code); - ebbrt::kprintf("RAX: %#018" PRIx64 " RBX: %#018" PRIx64 "\n", ef->rax, - ef->rbx); - ebbrt::kprintf("RCX: %#018" PRIx64 " RDX: %#018" PRIx64 "\n", ef->rcx, - ef->rdx); - ebbrt::kprintf("RSI: %#018" PRIx64 " RDI: %#018" PRIx64 "\n", ef->rsi, - ef->rdi); - ebbrt::kprintf("RBP: %#018" PRIx64 " R8: %#018" PRIx64 "\n", ef->rbp, - ef->r8); - ebbrt::kprintf("R9: %#018" PRIx64 " R10: %#018" PRIx64 "\n", ef->r9, - ef->r10); - ebbrt::kprintf("R11: %#018" PRIx64 " R12: %#018" PRIx64 "\n", ef->r11, - ef->r12); - ebbrt::kprintf("R13: %#018" PRIx64 " R14: %#018" PRIx64 "\n", ef->r13, - ef->r14); - ebbrt::kprintf("R15: %#018" PRIx64 "\n", ef->r15); + ebbrt::kprintf_force("SS: %#018" PRIx64 " RSP: %#018" PRIx64 "\n", ef->ss, + ef->rsp); + ebbrt::kprintf_force("FLAGS: %#018" PRIx64 "\n", + ef->rflags); // TODO(Dschatz): print out actual meaning + ebbrt::kprintf_force("CS: %#018" PRIx64 " RIP: %#018" PRIx64 "\n", ef->cs, + ef->rip); + ebbrt::kprintf_force("Error Code: %" PRIx64 "\n", ef->error_code); + ebbrt::kprintf_force("RAX: %#018" PRIx64 " RBX: %#018" PRIx64 "\n", ef->rax, + ef->rbx); + ebbrt::kprintf_force("RCX: %#018" PRIx64 " RDX: %#018" PRIx64 "\n", ef->rcx, + ef->rdx); + ebbrt::kprintf_force("RSI: %#018" PRIx64 " RDI: %#018" PRIx64 "\n", ef->rsi, + ef->rdi); + ebbrt::kprintf_force("RBP: %#018" PRIx64 " R8: %#018" PRIx64 "\n", ef->rbp, + ef->r8); + ebbrt::kprintf_force("R9: %#018" PRIx64 " R10: %#018" PRIx64 "\n", ef->r9, + ef->r10); + ebbrt::kprintf_force("R11: %#018" PRIx64 " R12: %#018" PRIx64 "\n", ef->r11, + ef->r12); + ebbrt::kprintf_force("R13: %#018" PRIx64 " R14: %#018" PRIx64 "\n", ef->r13, + ef->r14); + ebbrt::kprintf_force("R15: %#018" PRIx64 "\n", ef->r15); // TODO(dschatz): FPU } @@ -143,7 +145,7 @@ extern "C" void ebbrt::idt::NmiInterrupt(ExceptionFrame* ef) { kabort(); } #define UNHANDLED_INTERRUPT(name) \ extern "C" void ebbrt::idt::name(ExceptionFrame* ef) { \ - kprintf("%s\n", __PRETTY_FUNCTION__); \ + kprintf_force("%s\n", __PRETTY_FUNCTION__); \ PrintExceptionFrame(ef); \ kabort(); \ } diff --git a/src/native/Newlib.cc b/src/native/Newlib.cc index 836f443a..7110c825 100644 --- a/src/native/Newlib.cc +++ b/src/native/Newlib.cc @@ -103,7 +103,7 @@ extern "C" int ebbrt_newlib_write(int file, char* ptr, int len) { EBBRT_UNIMPLEMENTED(); return 0; } - ebbrt::kprintf("%*.*s", len, len, ptr); + ebbrt::kprintf_force("%*.*s", len, len, ptr); return len; }