mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
get symbol
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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; };
|
||||
|
||||
Reference in New Issue
Block a user