ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

i386bug.c
Go to the documentation of this file.
00001 
00002 #include <freeldr.h>
00003 
00004 #define NDEBUG
00005 #include <debug.h>
00006 
00007 typedef struct _FRAME
00008 {
00009     struct _FRAME *Next;
00010     void *Address;
00011 } FRAME;
00012 
00013 char *i386ExceptionDescriptionText[] =
00014 {
00015     "Exception 00: DIVIDE BY ZERO\n\n",
00016     "Exception 01: DEBUG EXCEPTION\n\n",
00017     "Exception 02: NON-MASKABLE INTERRUPT EXCEPTION\n\n",
00018     "Exception 03: BREAKPOINT (INT 3)\n\n",
00019     "Exception 04: OVERFLOW\n\n",
00020     "Exception 05: BOUND EXCEPTION\n\n",
00021     "Exception 06: INVALID OPCODE\n\n",
00022     "Exception 07: FPU NOT AVAILABLE\n\n",
00023     "Exception 08: DOUBLE FAULT\n\n",
00024     "Exception 09: COPROCESSOR SEGMENT OVERRUN\n\n",
00025     "Exception 0A: INVALID TSS\n\n",
00026     "Exception 0B: SEGMENT NOT PRESENT\n\n",
00027     "Exception 0C: STACK EXCEPTION\n\n",
00028     "Exception 0D: GENERAL PROTECTION FAULT\n\n",
00029     "Exception 0E: PAGE FAULT\n\n",
00030     "Exception 0F: Reserved\n\n",
00031     "Exception 10: COPROCESSOR ERROR\n\n",
00032     "Exception 11: ALIGNMENT CHECK\n\n",
00033     "Exception 12: MACHINE CHECK\n\n"
00034 };
00035 
00036 #define SCREEN_ATTR 0x1f
00037 void
00038 i386PrintChar(char chr, ULONG x, ULONG y)
00039 {
00040     MachVideoPutChar(chr, SCREEN_ATTR, x, y);
00041 }
00042 
00043 /* Used to store the current X and Y position on the screen */
00044 ULONG i386_ScreenPosX = 0;
00045 ULONG i386_ScreenPosY = 0;
00046 
00047 void
00048 i386PrintText(char *pszText)
00049 {
00050     char chr;
00051     while (1)
00052     {
00053         chr = *pszText++;
00054         
00055         if (chr == 0) break;
00056         if (chr == '\n')
00057         {
00058             i386_ScreenPosY++;
00059             i386_ScreenPosX = 0;
00060             continue;
00061         }
00062         
00063         MachVideoPutChar(chr, SCREEN_ATTR, i386_ScreenPosX, i386_ScreenPosY);
00064         i386_ScreenPosX++;
00065     }
00066 }
00067 
00068 void
00069 PrintText(const char *format, ...)
00070 {
00071     va_list argptr;
00072     char buffer[256];
00073     
00074     va_start(argptr, format);
00075     _vsnprintf(buffer, sizeof(buffer), format, argptr);
00076     buffer[sizeof(buffer) - 1] = 0;
00077     va_end(argptr);
00078     i386PrintText(buffer);
00079 }
00080 
00081 void
00082 i386PrintFrames(PKTRAP_FRAME TrapFrame)
00083 {
00084     FRAME *Frame;
00085 
00086     PrintText("Frames:\n");
00087 
00088     for (Frame = (FRAME*)TrapFrame->Ebp;
00089          Frame != 0 && (ULONG_PTR)Frame < STACK32ADDR;
00090          Frame = Frame->Next)
00091     {
00092         PrintText("%p  ", Frame->Address);
00093     }
00094 }
00095 
00096 void
00097 NTAPI
00098 i386PrintExceptionText(ULONG TrapIndex, PKTRAP_FRAME TrapFrame, PKSPECIAL_REGISTERS Special)
00099 {
00100     MachVideoClearScreen(SCREEN_ATTR);
00101     i386_ScreenPosX = 0;
00102     i386_ScreenPosY = 0;
00103 
00104     PrintText("An error occured in FreeLoader\n"
00105               VERSION"\n"
00106               "Report this error to the ReactOS Development mailing list <ros-dev@reactos.org>\n\n"
00107               "%s\n", i386ExceptionDescriptionText[TrapIndex]);
00108 
00109     PrintText("EAX: %.8lx        ESP: %.8lx        CR0: %.8lx        DR0: %.8lx\n", 
00110               TrapFrame->Eax, TrapFrame->HardwareEsp, Special->Cr0, TrapFrame->Dr0);
00111     PrintText("EBX: %.8lx        EBP: %.8lx        CR1: ????????        DR1: %.8lx\n", 
00112               TrapFrame->Ebx, TrapFrame->Ebp, TrapFrame->Dr1);
00113     PrintText("ECX: %.8lx        ESI: %.8lx        CR2: %.8lx        DR2: %.8lx\n", 
00114               TrapFrame->Ecx, TrapFrame->Esi, Special->Cr2, TrapFrame->Dr2);
00115     PrintText("EDX: %.8lx        EDI: %.8lx        CR3: %.8lx        DR3: %.8lx\n", 
00116               TrapFrame->Edx, TrapFrame->Edi, Special->Cr3, TrapFrame->Dr3);
00117     PrintText("                                                               DR6: %.8lx\n", 
00118               TrapFrame->Dr6);
00119     PrintText("                                                               DR7: %.8lx\n\n", 
00120               TrapFrame->Dr7);
00121     PrintText("CS: %.4lx        EIP: %.8lx\n", 
00122               TrapFrame->SegCs, TrapFrame->Eip);
00123     PrintText("DS: %.4lx        ERROR CODE: %.8lx\n", 
00124               TrapFrame->SegDs, TrapFrame->Eip);
00125     PrintText("ES: %.4lx        EFLAGS: %.8lx\n", 
00126               TrapFrame->SegEs, TrapFrame->EFlags);
00127     PrintText("FS: %.4lx        GDTR Base: %.8lx Limit: %.4x\n", 
00128               TrapFrame->SegFs, Special->Gdtr.Base, Special->Gdtr.Limit);
00129     PrintText("GS: %.4lx        IDTR Base: %.8lx Limit: %.4x\n", 
00130               TrapFrame->SegGs, Special->Idtr.Base, Special->Idtr.Limit);
00131     PrintText("SS: %.4lx        LDTR: %.4lx TR: %.4lx\n\n", 
00132               TrapFrame->HardwareSegSs, Special->Ldtr, Special->Idtr.Limit);
00133 
00134     i386PrintFrames(TrapFrame);                     // Display frames
00135 }

Generated on Sat May 26 2012 04:17:53 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.