Skip to content

Commit

Permalink
refactor(debug): force print for abort messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jimcadden committed Jan 25, 2018
1 parent 3bffb46 commit 2b4d2ee
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/hosted/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static __attribute__((noreturn)) void kabort() { abort(); }

template <typename... Args>
__attribute__((noreturn)) void kabort(Args&&... args) {
kprintf(std::forward<Args>(args)...); // NOLINT
kprintf_force(std::forward<Args>(args)...); // NOLINT
kabort();
}

Expand Down
44 changes: 23 additions & 21 deletions src/native/Idt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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(); \
}
Expand Down
2 changes: 1 addition & 1 deletion src/native/Newlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 2b4d2ee

Please sign in to comment.