creport: Implement reading info about all threads.
This commit is contained in:
@@ -28,6 +28,9 @@ bool ThreadInfo::ReadFromProcess(Handle debug_handle, u64 thread_id, bool is_64_
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Try to locate stack top/bottom. */
|
||||
TryGetStackInfo(debug_handle);
|
||||
|
||||
u64 cur_fp = this->context.fp;
|
||||
for (unsigned int i = 0; i < sizeof(this->stack_trace)/sizeof(u64); i++) {
|
||||
/* Validate the current frame. */
|
||||
@@ -47,4 +50,49 @@ bool ThreadInfo::ReadFromProcess(Handle debug_handle, u64 thread_id, bool is_64_
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ThreadInfo::TryGetStackInfo(Handle debug_handle) {
|
||||
MemoryInfo mi;
|
||||
u32 pi;
|
||||
if (R_FAILED(svcQueryDebugProcessMemory(&mi, &pi, debug_handle, this->context.sp))) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if sp points into the stack. */
|
||||
if (mi.type == MemType_MappedMemory) {
|
||||
this->stack_bottom = mi.addr;
|
||||
this->stack_top = mi.addr + mi.size;
|
||||
return;
|
||||
}
|
||||
|
||||
/* It's possible that sp is below the stack... */
|
||||
if (R_FAILED(svcQueryDebugProcessMemory(&mi, &pi, debug_handle, mi.addr + mi.size))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mi.type == MemType_MappedMemory) {
|
||||
this->stack_bottom = mi.addr;
|
||||
this->stack_top = mi.addr + mi.size;
|
||||
}
|
||||
}
|
||||
|
||||
void ThreadList::ReadThreadsFromProcess(Handle debug_handle, bool is_64_bit) {
|
||||
u32 thread_count;
|
||||
u64 thread_ids[max_thread_count];
|
||||
|
||||
if (R_FAILED(svcGetThreadList(&thread_count, thread_ids, max_thread_count, debug_handle))) {
|
||||
this->thread_count = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (thread_count > max_thread_count) {
|
||||
thread_count = max_thread_count;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < thread_count; i++) {
|
||||
if (this->thread_infos[this->thread_count].ReadFromProcess(debug_handle, thread_ids[this->thread_count], is_64_bit)) {
|
||||
this->thread_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user