Skip to content

Commit

Permalink
Merge pull request #1716 from FEX-Emu/skmp/jitsymbols-file-offsets
Browse files Browse the repository at this point in the history
JitSymbols: Print file+offset if possible
  • Loading branch information
Stefanos Kornilios Mitsis Poiitidis authored May 17, 2022
2 parents 5460a24 + 29859d2 commit a715627
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions External/FEXCore/Source/Common/JitSymbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ namespace FEXCore {
fmt::print(fp.get(), "{} {:x} {}_{}\n", HostAddr, CodeSize, Name, HostAddr);
}

void JITSymbols::Register(const void *HostAddr, uint32_t CodeSize, std::string_view Name, uintptr_t Offset) {
if (!fp) return;

// Linux perf format is very straightforward
// `<HostPtr> <Size> <Name>\n`
fmt::print(fp.get(), "{} {:x} {}+0x{:x} ({})\n", HostAddr, CodeSize, Name, Offset, HostAddr);
}

void JITSymbols::RegisterNamedRegion(const void *HostAddr, uint32_t CodeSize, std::string_view Name) {
if (!fp) return;

Expand Down
1 change: 1 addition & 0 deletions External/FEXCore/Source/Common/JitSymbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class JITSymbols final {

void Register(const void *HostAddr, uint64_t GuestAddr, uint32_t CodeSize);
void Register(const void *HostAddr, uint32_t CodeSize, std::string_view Name);
void Register(const void *HostAddr, uint32_t CodeSize, std::string_view Name, uintptr_t Offset);
void RegisterNamedRegion(const void *HostAddr, uint32_t CodeSize, std::string_view Name);
void RegisterJITSpace(const void *HostAddr, uint32_t CodeSize);

Expand Down
10 changes: 10 additions & 0 deletions External/FEXCore/Source/Interface/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,12 +996,22 @@ namespace FEXCore::Context {
// The core managed to compile the code.
if (Config.BlockJITNaming()) {
if (DebugData) {
auto GuestRIPLookup = this->SyscallHandler->LookupAOTIRCacheEntry(GuestRIP);

if (DebugData->Subblocks.size()) {
for (auto& Subblock: DebugData->Subblocks) {
if (GuestRIPLookup.Entry) {
Symbols.Register(CodePtr, DebugData->HostCodeSize, GuestRIPLookup.Entry->Filename, GuestRIP - GuestRIPLookup.Offset);
} else {
Symbols.Register((void*)Subblock.HostCodeStart, GuestRIP, Subblock.HostCodeSize);
}
}
} else {
if (GuestRIPLookup.Entry) {
Symbols.Register(CodePtr, DebugData->HostCodeSize, GuestRIPLookup.Entry->Filename, GuestRIP - GuestRIPLookup.Offset);
} else {
Symbols.Register(CodePtr, GuestRIP, DebugData->HostCodeSize);
}
}
}
}
Expand Down

0 comments on commit a715627

Please sign in to comment.