creport: Improve code region list (as N did in 6.1.0)

This commit is contained in:
Michael Scire 2018-11-11 19:52:19 -08:00
parent 1aba87ef76
commit 36530a5501
4 changed files with 49 additions and 14 deletions

View file

@ -32,15 +32,37 @@ void CodeList::SaveToFile(FILE *f_report) {
}
}
void CodeList::ReadCodeRegionsFromProcess(Handle debug_handle, u64 pc, u64 lr) {
void CodeList::ReadCodeRegionsFromThreadInfo(Handle debug_handle, const ThreadInfo *thread) {
u64 code_base;
/* Guess that either PC or LR will point to a code region. This could be false. */
if (!TryFindCodeRegion(debug_handle, pc, &code_base) && !TryFindCodeRegion(debug_handle, lr, &code_base)) {
return;
/* Try to add the thread's PC. */
if (TryFindCodeRegion(debug_handle, thread->GetPC(), &code_base)) {
AddCodeRegion(debug_handle, code_base);
}
u64 cur_ptr = code_base;
/* Try to add the thread's LR. */
if (TryFindCodeRegion(debug_handle, thread->GetLR(), &code_base)) {
AddCodeRegion(debug_handle, code_base);
}
/* Try to add all the addresses in the thread's stacktrace. */
for (u32 i = 0; i < thread->GetStackTraceSize(); i++) {
if (TryFindCodeRegion(debug_handle, thread->GetStackTrace(i), &code_base)) {
AddCodeRegion(debug_handle, code_base);
}
}
}
void CodeList::AddCodeRegion(u64 debug_handle, u64 code_address) {
/* Check whether we already have this code region. */
for (size_t i = 0; i < this->code_count; i++) {
if (this->code_infos[i].start_address <= code_address && code_address < this->code_infos[i].end_address) {
return;
}
}
/* Add all contiguous code regions. */
u64 cur_ptr = code_address;
while (this->code_count < max_code_count) {
MemoryInfo mi;
u32 pi;