summaryrefslogtreecommitdiff
path: root/src/core/arm/arm_interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/arm/arm_interface.cpp')
-rw-r--r--src/core/arm/arm_interface.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/core/arm/arm_interface.cpp b/src/core/arm/arm_interface.cpp
index 2945fcff8..372612c9b 100644
--- a/src/core/arm/arm_interface.cpp
+++ b/src/core/arm/arm_interface.cpp
@@ -9,6 +9,7 @@
9#include "common/logging/log.h" 9#include "common/logging/log.h"
10#include "core/arm/arm_interface.h" 10#include "core/arm/arm_interface.h"
11#include "core/core.h" 11#include "core/core.h"
12#include "core/loader/loader.h"
12#include "core/memory.h" 13#include "core/memory.h"
13 14
14namespace Core { 15namespace Core {
@@ -80,15 +81,17 @@ Symbols GetSymbols(VAddr text_offset) {
80 const auto value = Memory::Read64(dynamic_index + 0x8); 81 const auto value = Memory::Read64(dynamic_index + 0x8);
81 dynamic_index += 0x10; 82 dynamic_index += 0x10;
82 83
83 if (tag == ELF_DYNAMIC_TAG_NULL) 84 if (tag == ELF_DYNAMIC_TAG_NULL) {
84 break; 85 break;
86 }
85 87
86 if (tag == ELF_DYNAMIC_TAG_STRTAB) 88 if (tag == ELF_DYNAMIC_TAG_STRTAB) {
87 string_table_offset = value; 89 string_table_offset = value;
88 else if (tag == ELF_DYNAMIC_TAG_SYMTAB) 90 } else if (tag == ELF_DYNAMIC_TAG_SYMTAB) {
89 symbol_table_offset = value; 91 symbol_table_offset = value;
90 else if (tag == ELF_DYNAMIC_TAG_SYMENT) 92 } else if (tag == ELF_DYNAMIC_TAG_SYMENT) {
91 symbol_entry_size = value; 93 symbol_entry_size = value;
94 }
92 } 95 }
93 96
94 if (string_table_offset == 0 || symbol_table_offset == 0 || symbol_entry_size == 0) { 97 if (string_table_offset == 0 || symbol_table_offset == 0 || symbol_entry_size == 0) {
@@ -126,8 +129,10 @@ std::optional<std::string> GetSymbolName(const Symbols& symbols, VAddr func_addr
126 return func_address >= symbol.value && func_address < end_address; 129 return func_address >= symbol.value && func_address < end_address;
127 }); 130 });
128 131
129 if (iter == symbols.end()) 132 if (iter == symbols.end()) {
130 return std::nullopt; 133 return std::nullopt;
134 }
135
131 return iter->second; 136 return iter->second;
132} 137}
133 138
@@ -150,7 +155,12 @@ std::vector<ARM_Interface::BacktraceEntry> ARM_Interface::GetBacktrace() const {
150 fp = Memory::Read64(fp); 155 fp = Memory::Read64(fp);
151 } 156 }
152 157
153 const auto& modules{System::GetInstance().GetRegisteredNSOModules()}; 158 std::map<VAddr, std::string> modules;
159 auto& loader{System::GetInstance().GetAppLoader()};
160 if (loader.ReadNSOModules(modules) != Loader::ResultStatus::Success) {
161 return {};
162 }
163
154 std::map<std::string, Symbols> symbols; 164 std::map<std::string, Symbols> symbols;
155 for (const auto& module : modules) { 165 for (const auto& module : modules) {
156 symbols.insert_or_assign(module.second, GetSymbols(module.first)); 166 symbols.insert_or_assign(module.second, GetSymbols(module.first));
@@ -158,7 +168,8 @@ std::vector<ARM_Interface::BacktraceEntry> ARM_Interface::GetBacktrace() const {
158 168
159 for (auto& entry : out) { 169 for (auto& entry : out) {
160 VAddr base = 0; 170 VAddr base = 0;
161 for (const auto& module : modules) { 171 for (auto iter = modules.rbegin(); iter != modules.rend(); ++iter) {
172 const auto& module{*iter};
162 if (entry.original_address >= module.first) { 173 if (entry.original_address >= module.first) {
163 entry.module = module.second; 174 entry.module = module.second;
164 base = module.first; 175 base = module.first;
@@ -191,7 +202,7 @@ void ARM_Interface::LogBacktrace() const {
191 LOG_ERROR(Core_ARM, "Backtrace, sp={:016X}, pc={:016X}", sp, pc); 202 LOG_ERROR(Core_ARM, "Backtrace, sp={:016X}, pc={:016X}", sp, pc);
192 LOG_ERROR(Core_ARM, "{:20}{:20}{:20}{:20}{}", "Module Name", "Address", "Original Address", 203 LOG_ERROR(Core_ARM, "{:20}{:20}{:20}{:20}{}", "Module Name", "Address", "Original Address",
193 "Offset", "Symbol"); 204 "Offset", "Symbol");
194 LOG_ERROR(Core_ARM, "{}", std::string(100, '-')); 205 LOG_ERROR(Core_ARM, "");
195 206
196 const auto backtrace = GetBacktrace(); 207 const auto backtrace = GetBacktrace();
197 for (const auto& entry : backtrace) { 208 for (const auto& entry : backtrace) {