-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: prepare for remove direct symbol resolve
- Loading branch information
Showing
18 changed files
with
227 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "ll/api/memory/Symbol.h" | ||
|
||
#include "ll/api/utils/SystemUtils.h" | ||
#include "ll/core/LeviLamina.h" | ||
|
||
#include "demangler/Demangle.h" | ||
#include "pl/SymbolProvider.h" | ||
|
||
namespace ll::memory { | ||
void* SymbolView::resolve(bool disableErrorOutput) const { | ||
auto res = pl::symbol_provider::pl_resolve_symbol_silent_n(sym.data(), sym.size()); | ||
if (!disableErrorOutput && res == nullptr) { | ||
getLogger().fatal("Couldn't find: {}", toString()); | ||
getLogger().fatal("In module: {}", sys_utils::getCallerModuleFileName()); | ||
} | ||
return res; | ||
} | ||
std::string SymbolView::toString() const { | ||
std::string res; | ||
if (demangler::nonMicrosoftDemangle(sym, res)) return res; | ||
else if (sym.starts_with("_")) { // some platform's external sym style... | ||
demangler::nonMicrosoftDemangle(sym.substr(1), res); | ||
} else { | ||
if (char* demangled = demangler::microsoftDemangle( | ||
sym, | ||
nullptr, | ||
nullptr, | ||
(demangler::MSDemangleFlags)(demangler::MSDF_NoAccessSpecifier | demangler::MSDF_NoCallingConvention) | ||
)) { | ||
res = demangled; | ||
std::free(demangled); | ||
} else { | ||
res = sym; | ||
} | ||
} | ||
return res; | ||
} | ||
std::vector<Symbol> Symbol::fromAddress(void* func) { | ||
std::vector<Symbol> result; | ||
size_t length{}; | ||
auto symbols = pl::symbol_provider::pl_lookup_symbol(func, &length); | ||
for (size_t i = 0; i < length; i++) { | ||
result.emplace_back(symbols[i]); | ||
} | ||
if (symbols) pl::symbol_provider::pl_free_lookup_result(symbols); | ||
return result; | ||
} | ||
} // namespace ll::memory |
Oops, something went wrong.