?? entry.c
字號:
/****************************************************************************** * * Copyright (c) 2003 Gerhard W. Gruber * * PROJECT: pICE * $Source: /cvsroot/pice/pice/module/entry.c,v $ * $Revision: 1.3 $ * $Date: 2004/02/17 23:07:36 $ * $Author: lightweave $ * $Name: $ * * $Log: entry.c,v $ * Revision 1.3 2004/02/17 23:07:36 lightweave * * Improved the DEBUG facillity and replaced the configuration handler with a * new code which now can read MS Windows INI style files. See CHANGES.txt for * more details. * Also added a macro which prevents compiling for kernels before 2.4.19. * * Revision 1.2 2003/06/18 22:00:22 lightweave * DEBUG and DEBUG_SERIAL added * * *****************************************************************************/static char *ident = "$Header: /cvsroot/pice/pice/module/entry.c,v 1.3 2004/02/17 23:07:36 lightweave Exp $";/*++Copyright (c) 1998-2001 Klaus P. GerlicherModule Name: entry.cAbstract: C entry point into debuggerEnvironment: Kernel mode onlyAuthor: Klaus P. GerlicherRevision History: 14-Oct-2001: createdCopyright notice: This file may be distributed under the terms of the GNU Public License.--*/////////////////////////////////////////////////////// INCLUDES////#include "remods.h"#include <asm/io.h>#include <linux/interrupt.h>#include "precomp.h"static char tempEntry[256];BOOLEAN bStepThroughSource=FALSE;BOOLEAN bStepInto = FALSE;BOOLEAN bHasFixup = FALSE;#ifdef __PICE__DEBUG__static ULONG ulEnterCount = 0;#endif // __DEBUG__// registers save area (context)ULONG CurrentDR0,CurrentDR1,CurrentDR2,CurrentDR3,CurrentDR6,CurrentDR7;ULONG CurrentCR0,CurrentCR2,CurrentCR3,CurrentCR4;BOOLEAN bNotifyToExit=FALSE; // TRUE when debugger should leaveBOOLEAN bDebuggerHaltState = FALSE;char *szReasons[] ={"REASON_INT3","REASON_SINGLESTEP","REASON_HOTKEY","REASON_PAGEFAULT","REASON_GP_FAULT","REASON_HARDWARE_BP","REASON_DOUBLE_FAULT","REASON_MODULE_LOAD","REASON_INTERNAL_ERROR","REASON_SYSCALL","REASON_STACK_FAULT","REASON_INVALID_OPCODE_FAULT","REASON_DIVBYZERO_FAULT","REASON_TIMER","REASON_NMI","REASON_NOT_PRESENT","REASON_ALIGNMENT","REASON_BOOT_PARAMS","REASON_OTHER_CPU"};//*************************************************************************// InternalError()////*************************************************************************void InternalError(EXCEPTION_FRAME* pFrame){ // make sure nooe can take over __asm__ __volatile__("cli"); // display debugger SaveGraphicsState(); // show context DisplayRegs(pFrame); // notify user PICE_sprintf(tempEntry,"pICE: %.4X:%.8X (code %x)\n",pFrame->cs,pFrame->eip,pFrame->reason_code); Print(OUTPUT_WINDOW,tempEntry); Print(OUTPUT_WINDOW,"pICE: Please report this error to KlausPG@ATi.com!\n"); Print(OUTPUT_WINDOW,"pICE: !!! SYSTEM HALTED !!!\n"); __asm__ __volatile__("hlt");}//*************************************************************************// HandleEntry()////*************************************************************************ULONG HandleEntry(EXCEPTION_FRAME* pFrame){ ULONG ulCallOldHandlerFlags; BOOLEAN bDontEnterShell; ENTER_FUNC(); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "%8X (%p CPU #%u %s)++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %s\n", ++ulEnterCount, current, current->processor, current->comm, szReasons[pFrame->reason_code]); // set default reason_code on return // override this if necessary ulCallOldHandlerFlags = pFrame->reason_code; // don't assume we must call original handlers yet bDontEnterShell = TRUE; // control is not depressed bControl=FALSE; #if 0 // dump registers DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "EFL = %.8X\n",pFrame->eflags); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "CS:EIP = %.4X:%.8X\n",pFrame->cs,pFrame->eip); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "ERR = %.8X\n",pFrame->error_code); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "REA = %.8X\n",pFrame->reason_code); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "EAX = %.8X\n",pFrame->eax); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "EBX = %.8X\n",pFrame->ebx); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "ECX = %.8X\n",pFrame->ecx); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "EDX = %.8X\n",pFrame->edx); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "EBP = %.8X\n",pFrame->ebp); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "ESP = %.8X\n",pFrame->esp); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "ESI = %.8X\n",pFrame->esi); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "EDI = %.8X\n",pFrame->edi); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "DS = %.4X\n",pFrame->ds); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "ES = %.4X\n",pFrame->es); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "FS = %.4X\n",pFrame->fs); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "GS = %.4X\n",pFrame->gs); // switched stacks on entry if(pFrame->cs != __KERNEL_CS) { DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "--- privilege switch ----\n"); DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "SS:ESP = %.4X:%.8X\n",pFrame->ring3_ss,pFrame->ring3_esp); } // check for V86 mode if(pFrame->eflags & VM_FLAG) { DPRINT(PICE_DEBUG, DBT_ENTRY, DBL_INFO, "--- V86 mode ----\n"); }#endif // why'd we come here? switch(pFrame->reason_code) { // page faults *********************************************************************** case REASON_PAGEFAULT: switch(HandlePageFault(pFrame)) { case 0: break; // fall through case 1: PICE_sprintf(tempEntry,"pICE: Breakpoint due to page fault at %.4X:%.8X\n",pFrame->cs,pFrame->eip); Print(OUTPUT_WINDOW,tempEntry); bDontEnterShell = FALSE; break; case 2: Print(OUTPUT_WINDOW,"pICE: !!! SYSTEM HALTED !!!\n"); bDebuggerHaltState = TRUE; bDontEnterShell = FALSE; break; } break; // system calls ********************************************************************** case REASON_SYSCALL: HandleSyscall(pFrame); break; // timer ***************************************************************************** case REASON_TIMER: break; // single stepping ******************************************************************* // // Why can we come here? // // 1) Some application is under control of a user-mode debugger and is currently single-stepping // 2) PICE is single-stepping // 3) PICE needs to step over a SW breakpoint // 4) There's an error in PICE code // // How do we recognize the right situation? // // 1) bStepping is not set and there's no breakpoint at the previous instruction // 2) bStepping is set // 3) bStepping is not set and there is a breakpoint at the previous instruction case REASON_SINGLESTEP: { ULONG ulAddressCurrent; // clear TF flag pFrame->eflags &= ~TF_FLAG; // let noone else see the step ulCallOldHandlerFlags = REASON_HOTKEY; // this instruction ulAddressCurrent = GetLinearAddress(pFrame->cs,pFrame->eip); // if we came in because we needed to skip past a // INT3 hook, we need to put the INT3 back in place and // simply restart the system. if(ulSingleStepCondition & SINGLE_STEP_CONDITION_BREAKPOINT_SKIP) { if(IsSwBpAtPreviousAddress(ulAddressCurrent))
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -