From 12eaf4687316b6b7cea4a57701a6479d0248bfdd Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sat, 12 Apr 2014 23:31:21 +0200 Subject: [PATCH] Let kernel debugger know how it was invoked. --- kernel/debugger.cpp | 10 +++++----- kernel/include/sortix/kernel/debugger.h | 4 ++-- kernel/kb/ps2.cpp | 2 +- kernel/x86-family/interrupt.cpp | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/debugger.cpp b/kernel/debugger.cpp index 08d725eb..74878649 100644 --- a/kernel/debugger.cpp +++ b/kernel/debugger.cpp @@ -51,7 +51,7 @@ namespace Debugger { uint16_t* const VIDEO_MEMORY = (uint16_t*) 0xB8000; -bool first_f10; +bool ignore_next_f10; static int column; static int row; static Thread* current_thread; @@ -258,12 +258,12 @@ void ReadCommand(char* buffer, size_t buffer_length) if ( !written && kbkey == -KBKEY_F10 ) { - if ( !first_f10 ) + if ( !ignore_next_f10 ) { strncpy(buffer, "exit", buffer_length); break; } - first_f10 = false; + ignore_next_f10 = false; } // Translate the keystroke into unicode. @@ -604,7 +604,7 @@ bool RunCommand() return true; } -void Run() +void Run(bool entered_through_keyboard) { static uint16_t saved_video_memory[80*25]; @@ -612,7 +612,7 @@ void Run() bool was_enabled = Interrupt::SetEnabled(false); - first_f10 = true; + ignore_next_f10 = entered_through_keyboard; addr_t saved_addrspace = current_thread->registers.cr3; diff --git a/kernel/include/sortix/kernel/debugger.h b/kernel/include/sortix/kernel/debugger.h index cb272936..52fe4b65 100644 --- a/kernel/include/sortix/kernel/debugger.h +++ b/kernel/include/sortix/kernel/debugger.h @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2013. + Copyright(C) Jonas 'Sortie' Termansen 2013, 2014. This file is part of Sortix. @@ -28,7 +28,7 @@ namespace Sortix { namespace Debugger { -void Run(); +void Run(bool entered_through_keyboard); } // namespace Debugger } // namespace Sortix diff --git a/kernel/kb/ps2.cpp b/kernel/kb/ps2.cpp index 0dbf334c..b263d34b 100644 --- a/kernel/kb/ps2.cpp +++ b/kernel/kb/ps2.cpp @@ -107,7 +107,7 @@ void PS2Keyboard::OnInterrupt(struct interrupt_context* intctx) if ( scancode == KBKEY_F10 ) { Scheduler::SaveInterruptedContext(intctx, &CurrentThread()->registers); - Debugger::Run(); + Debugger::Run(true); } PS2KeyboardWork work; work.scancode = scancode; diff --git a/kernel/x86-family/interrupt.cpp b/kernel/x86-family/interrupt.cpp index 0b67c62b..4c386f6d 100644 --- a/kernel/x86-family/interrupt.cpp +++ b/kernel/x86-family/interrupt.cpp @@ -282,7 +282,7 @@ void KernelCrashHandler(struct interrupt_context* intctx) // Possibly switch to the kernel debugger in event of a crash. if ( RUN_DEBUGGER_ON_KERNEL_CRASH ) - Debugger::Run(); + Debugger::Run(false); // Panic the kernel with a diagnostic message. PanicF("Unhandled CPU Exception id %zu `%s' at ip=0x%zx (cr2=0x%zx, " @@ -316,7 +316,7 @@ void UserCrashHandler(struct interrupt_context* intctx) // Possibly switch to the kernel debugger in event of a crash. if ( RUN_DEBUGGER_ON_USER_CRASH ) - Debugger::Run(); + Debugger::Run(false); // Issue a diagnostic message to the kernel log concerning the crash. Log::PrintF("The current process (pid %ji `%s') crashed and was terminated:\n",