get symbol

This commit is contained in:
petrie911
2025-05-06 13:47:58 -06:00
committed by Lywx
parent 9c460ea543
commit 8e56ea0294
2 changed files with 18 additions and 0 deletions
+17
View File
@@ -1433,6 +1433,23 @@ std::optional<std::tuple<std::string, YAML::Node>> Companion::GetSafeNodeByAddr(
}
std::string Companion::GetSymbolFromAddr(uint32_t address, bool validZero) {
auto dec = Companion::Instance->GetNodeByAddr(address);
std::ostringstream outSymbol;
if(address == 0 && !validZero) {
outSymbol << "NULL";
} else if (dec.has_value()) {
auto node = std::get<1>(dec.value());
auto symbol = GetSafeNode<std::string>(node, "symbol");
outSymbol << "&" << symbol;
} else {
outSymbol << "0x" << std::uppercase << std::hex << address;
}
return outSymbol.str();
}
std::optional<ParseResultData> Companion::GetParseDataByAddr(uint32_t addr) {
if(!this->gParseResults.contains(this->gCurrentFile)){
for (auto &file : this->gCurrentExternalFiles) {
+1
View File
@@ -156,6 +156,7 @@ public:
std::optional<std::tuple<std::string, YAML::Node>> GetNodeByAddr(uint32_t addr);
std::optional<std::tuple<std::string, YAML::Node>> GetSafeNodeByAddr(const uint32_t addr, std::string type);
std::optional<std::vector<std::tuple<std::string, YAML::Node>>> GetNodesByType(const std::string& type);
std::string GetSymbolFromAddr(uint32_t addr, bool validZero = false);
std::optional<std::uint32_t> GetFileOffset(void) const { return this->gCurrentFileOffset; };
std::optional<std::uint32_t> GetCurrSegmentNumber(void) const { return this->gCurrentSegmentNumber; };