Added new function get_debug_exception_string(). Refactored a bit.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11702 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -13,6 +13,40 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
static const char *const sDebugWhyStrings[] = {
|
||||||
|
"Thread not running", // B_THREAD_NOT_RUNNING
|
||||||
|
"Signal received", // B_SIGNAL_RECEIVED
|
||||||
|
"Team created", // B_TEAM_CREATED
|
||||||
|
"Thread created", // B_THREAD_CREATED
|
||||||
|
"Image created", // B_IMAGE_CREATED
|
||||||
|
"Image deleted", // B_IMAGE_DELETED
|
||||||
|
"Debugger call", // B_DEBUGGER_CALL
|
||||||
|
"Breakpoint hit", // B_BREAKPOINT_HIT
|
||||||
|
"watchpoint hit", // B_WATCHPOINT_HIT
|
||||||
|
"Before syscall", // B_PRE_SYSCALL_HIT
|
||||||
|
"After syscall", // B_POST_SYSCALL_HIT
|
||||||
|
"Single step", // B_SINGLE_STEP
|
||||||
|
};
|
||||||
|
static const int32 sDebugWhyStringCount = B_SINGLE_STEP + 1;
|
||||||
|
|
||||||
|
static const char *const sDebugExceptionTypeStrings[] = {
|
||||||
|
"Non-maskable interrupt", // B_NMI
|
||||||
|
"Machine check exception", // B_MACHINE_CHECK_EXCEPTION
|
||||||
|
"Segment violation", // B_SEGMENT_VIOLATION
|
||||||
|
"Alignment exception", // B_ALIGNMENT_EXCEPTION
|
||||||
|
"Divide error", // B_DIVIDE_ERROR
|
||||||
|
"Overflow exception", // B_OVERFLOW_EXCEPTION
|
||||||
|
"Bounds check exception", // B_BOUNDS_CHECK_EXCEPTION
|
||||||
|
"Invalid opcode exception", // B_INVALID_OPCODE_EXCEPTION
|
||||||
|
"Segment not present", // B_SEGMENT_NOT_PRESENT
|
||||||
|
"Stack fault", // B_STACK_FAULT
|
||||||
|
"General protection fault", // B_GENERAL_PROTECTION_FAULT
|
||||||
|
"Floating point exception", // B_FLOATING_POINT_EXCEPTION
|
||||||
|
};
|
||||||
|
static const int32 sDebugExceptionTypeStringCount
|
||||||
|
= B_FLOATING_POINT_EXCEPTION + 1;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
debugger(const char *message)
|
debugger(const char *message)
|
||||||
{
|
{
|
||||||
@@ -70,47 +104,34 @@ wait_for_debugger(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *const sDebugWhyStrings[] = {
|
static void
|
||||||
"Thread not running", // B_THREAD_NOT_RUNNING
|
get_debug_string(const char *const *strings, int32 stringCount,
|
||||||
"Signal received", // B_SIGNAL_RECEIVED
|
const char *defaultString, int32 index, char *buffer, int32 bufferSize)
|
||||||
"Team created", // B_TEAM_CREATED
|
|
||||||
"Thread created", // B_THREAD_CREATED
|
|
||||||
"Image created", // B_IMAGE_CREATED
|
|
||||||
"Image deleted", // B_IMAGE_DELETED
|
|
||||||
"Debugger call", // B_DEBUGGER_CALL
|
|
||||||
"Breakpoint hit", // B_BREAKPOINT_HIT
|
|
||||||
"watchpoint hit", // B_WATCHPOINT_HIT
|
|
||||||
"Before syscall", // B_PRE_SYSCALL_HIT
|
|
||||||
"After syscall", // B_POST_SYSCALL_HIT
|
|
||||||
"Single step", // B_SINGLE_STEP
|
|
||||||
|
|
||||||
"Non-masked interrupt", // B_NMI
|
|
||||||
"Machine check exception", // B_MACHINE_CHECK_EXCEPTION
|
|
||||||
"Segment violation", // B_SEGMENT_VIOLATION
|
|
||||||
"Alignment exception", // B_ALIGNMENT_EXCEPTION
|
|
||||||
"Divide error", // B_DIVIDE_ERROR
|
|
||||||
"Overflow exception", // B_OVERFLOW_EXCEPTION
|
|
||||||
"Bounds check exception", // B_BOUNDS_CHECK_EXCEPTION
|
|
||||||
"Invalid opcode exception", // B_INVALID_OPCODE_EXCEPTION
|
|
||||||
"Segment not present", // B_SEGMENT_NOT_PRESENT
|
|
||||||
"Stack fault", // B_STACK_FAULT
|
|
||||||
"General protection fault", // B_GENERAL_PROTECTION_FAULT
|
|
||||||
"Floating point exception", // B_FLOATING_POINT_EXCEPTION
|
|
||||||
};
|
|
||||||
static const int32 sDebugWhyStringCount = B_FLOATING_POINT_EXCEPTION + 1;
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
get_why_stopped_string(debug_why_stopped whyStopped, char *buffer,
|
|
||||||
int32 bufferSize)
|
|
||||||
{
|
{
|
||||||
if (!buffer || bufferSize <= 0)
|
if (!buffer || bufferSize <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((int32)whyStopped >= 0 && (int32)whyStopped < sDebugWhyStringCount)
|
if ((int32)index >= 0 && (int32)index < stringCount)
|
||||||
strlcpy(buffer, sDebugWhyStrings[whyStopped], bufferSize);
|
strlcpy(buffer, strings[index], bufferSize);
|
||||||
else
|
else
|
||||||
snprintf(buffer, bufferSize, "Unknown reason %ld", (int32)whyStopped);
|
snprintf(buffer, bufferSize, defaultString, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
get_debug_why_stopped_string(debug_why_stopped whyStopped, char *buffer,
|
||||||
|
int32 bufferSize)
|
||||||
|
{
|
||||||
|
get_debug_string(sDebugWhyStrings, sDebugWhyStringCount,
|
||||||
|
"Unknown reason %ld", (int32)whyStopped, buffer, bufferSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
get_debug_exception_string(debug_exception_type exception, char *buffer,
|
||||||
|
int32 bufferSize)
|
||||||
|
{
|
||||||
|
get_debug_string(sDebugExceptionTypeStrings, sDebugExceptionTypeStringCount,
|
||||||
|
"Unknown exception %ld", (int32)exception, buffer, bufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user