Reduce code duplication
This commit is contained in:
parent
6227abac73
commit
bd3428e039
|
@ -569,6 +569,27 @@ static void PrintCallstack(FILE* f, PEXCEPTION_POINTERS ex)
|
||||||
hLibDbgHelp=0;
|
hLibDbgHelp=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void writeMemoryErrorDetails(FILE* f, PEXCEPTION_POINTERS ex, const char* description)
|
||||||
|
{
|
||||||
|
fputs(description, f);
|
||||||
|
switch (ex->ExceptionRecord->ExceptionInformation[0]) {
|
||||||
|
case 0:
|
||||||
|
fprintf(f, " reading from 0x%x",
|
||||||
|
ex->ExceptionRecord->ExceptionInformation[1]);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
fprintf(f, " writing at 0x%x",
|
||||||
|
ex->ExceptionRecord->ExceptionInformation[1]);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
fprintf(f, " data execution prevention at 0x%x",
|
||||||
|
ex->ExceptionRecord->ExceptionInformation[1]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Any evaluation of the information about the exception needs to be done here!
|
* Any evaluation of the information about the exception needs to be done here!
|
||||||
*/
|
*/
|
||||||
|
@ -578,23 +599,7 @@ static int filterException(int code, PEXCEPTION_POINTERS ex)
|
||||||
fputs("Internal error: ", f);
|
fputs("Internal error: ", f);
|
||||||
switch (ex->ExceptionRecord->ExceptionCode) {
|
switch (ex->ExceptionRecord->ExceptionCode) {
|
||||||
case EXCEPTION_ACCESS_VIOLATION:
|
case EXCEPTION_ACCESS_VIOLATION:
|
||||||
fputs("Access violation", f);
|
writeMemoryErrorDetails(f, ex, "Access violation");
|
||||||
switch (ex->ExceptionRecord->ExceptionInformation[0]) {
|
|
||||||
case 0:
|
|
||||||
fprintf(f, " reading from 0x%x",
|
|
||||||
ex->ExceptionRecord->ExceptionInformation[1]);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
fprintf(f, " writing at 0x%x",
|
|
||||||
ex->ExceptionRecord->ExceptionInformation[1]);
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
fprintf(f, " data execution prevention at 0x%x",
|
|
||||||
ex->ExceptionRecord->ExceptionInformation[1]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
||||||
fputs("Out of array bounds", f);
|
fputs("Out of array bounds", f);
|
||||||
|
@ -633,23 +638,7 @@ static int filterException(int code, PEXCEPTION_POINTERS ex)
|
||||||
fputs("Illegal instruction", f);
|
fputs("Illegal instruction", f);
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_IN_PAGE_ERROR:
|
case EXCEPTION_IN_PAGE_ERROR:
|
||||||
fputs("Invalid page access", f);
|
writeMemoryErrorDetails(f, ex, "Invalid page access");
|
||||||
switch (ex->ExceptionRecord->ExceptionInformation[0]) {
|
|
||||||
case 0:
|
|
||||||
fprintf(f, " reading from 0x%x",
|
|
||||||
ex->ExceptionRecord->ExceptionInformation[1]);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
fprintf(f, " writing at 0x%x",
|
|
||||||
ex->ExceptionRecord->ExceptionInformation[1]);
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
fprintf(f, " data execution prevention at 0x%x",
|
|
||||||
ex->ExceptionRecord->ExceptionInformation[1]);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
||||||
fputs("Integer divide-by-zero", f);
|
fputs("Integer divide-by-zero", f);
|
||||||
|
|
Loading…
Reference in New Issue