Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
Improve debugging a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed May 25, 2021
1 parent c7cdd21 commit dc45214
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions kernel/arch/x86_64/idt.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include <kernel/arch/x86_64/regs.h>
#include <kernel/arch/x86_64/irq.h>

#undef DEBUG_FAULTS
#define LOUD_SEGFAULTS

static struct idt_pointer idtp;
static idt_entry_t idt[256];

Expand Down Expand Up @@ -213,6 +216,10 @@ struct regs * isr_handler(struct regs * r) {
spin_unlock(fault_lock);
arch_fatal();
#else
# ifdef LOUD_SEGFAULTS
printf("Page fault in pid=%d (%s; cpu=%d) at %#zx\n", (int)this_core->current_process->id, this_core->current_process->name, this_core->cpu_id, faulting_address);
dump_regs(r);
# endif
send_signal(this_core->current_process->id, SIGSEGV, 1);
#endif
break;
Expand All @@ -230,6 +237,10 @@ struct regs * isr_handler(struct regs * r) {
spin_unlock(fault_lock);
arch_fatal();
#else
# ifdef LOUD_SEGFAULTS
printf("GPF in userspace on CPU %d\n", this_core->cpu_id);
dump_regs(r);
# endif
send_signal(this_core->current_process->id, SIGSEGV, 1);
#endif
break;
Expand Down
4 changes: 4 additions & 0 deletions kernel/misc/fbterm.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,14 @@ static void process_char(char ch) {
invert_at(x,y);
}

static size_t (*previous_writer)(size_t,uint8_t*) = NULL;

size_t fbterm_write(size_t size, uint8_t *buffer) {
if (!buffer) return 0;
for (unsigned int i = 0; i < size; ++i) {
process_char(buffer[i]);
}
if (previous_writer) previous_writer(size,buffer);
return size;
}

Expand All @@ -234,5 +237,6 @@ void fbterm_initialize(void) {

fbterm_width = (lfb_resolution_x - LEFT_PAD) / char_width;
fbterm_height = (lfb_resolution_y) / char_height;
previous_writer = printf_output;
printf_output = fbterm_write;
}

0 comments on commit dc45214

Please sign in to comment.