kernel debugger: Use memcpy for stack trace on kernel stack.
If it was already determined that the memory is within the kernel stack, a simple memcpy is enough. This allows capturing kernel stack traces in situations where a fault handler cannot be installed (i.e. where one is already installed).
This commit is contained in:
@@ -63,11 +63,14 @@ already_visited(addr_t* visited, int32* _last, int32* _num, addr_t bp)
|
|||||||
/*! Safe to be called only from outside the debugger.
|
/*! Safe to be called only from outside the debugger.
|
||||||
*/
|
*/
|
||||||
static status_t
|
static status_t
|
||||||
get_next_frame_no_debugger(addr_t bp, addr_t* _next, addr_t* _ip)
|
get_next_frame_no_debugger(addr_t bp, addr_t* _next, addr_t* _ip,
|
||||||
|
bool onKernelStack)
|
||||||
{
|
{
|
||||||
// TODO: Do this more efficiently in assembly.
|
// TODO: Do this more efficiently in assembly.
|
||||||
stack_frame frame;
|
stack_frame frame;
|
||||||
if (user_memcpy(&frame, (void*)bp, sizeof(frame)) != B_OK)
|
if (onKernelStack)
|
||||||
|
memcpy(&frame, (void*)bp, sizeof(frame));
|
||||||
|
else if (user_memcpy(&frame, (void*)bp, sizeof(frame)) != B_OK)
|
||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
|
|
||||||
*_ip = frame.return_address;
|
*_ip = frame.return_address;
|
||||||
@@ -1089,7 +1092,7 @@ arch_debug_contains_call(Thread* thread, const char* symbol, addr_t start,
|
|||||||
} else {
|
} else {
|
||||||
addr_t ip, nextBp;
|
addr_t ip, nextBp;
|
||||||
|
|
||||||
if (get_next_frame_no_debugger(bp, &nextBp, &ip) != B_OK
|
if (get_next_frame_no_debugger(bp, &nextBp, &ip, true) != B_OK
|
||||||
|| ip == 0 || bp == 0)
|
|| ip == 0 || bp == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1159,8 +1162,10 @@ arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount,
|
|||||||
skipFrames = 0;
|
skipFrames = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (get_next_frame_no_debugger(bp, &nextBp, &ip) != B_OK)
|
if (get_next_frame_no_debugger(bp, &nextBp, &ip,
|
||||||
|
onKernelStack) != B_OK) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skipFrames <= 0
|
if (skipFrames <= 0
|
||||||
|
|||||||
Reference in New Issue
Block a user