Upgrade symbolmaps with module address info.
This fixes some issues with jit replacement only if you had a map laying around.
This commit is contained in:
parent
4706876809
commit
c3a6092e26
3 changed files with 31 additions and 16 deletions
|
@ -287,46 +287,40 @@ bool SymbolMap::GetSymbolInfo(SymbolInfo *info, u32 address, SymbolType symmask)
|
||||||
u32 functionAddress = INVALID_ADDRESS;
|
u32 functionAddress = INVALID_ADDRESS;
|
||||||
u32 dataAddress = INVALID_ADDRESS;
|
u32 dataAddress = INVALID_ADDRESS;
|
||||||
|
|
||||||
if (symmask & ST_FUNCTION)
|
if (symmask & ST_FUNCTION) {
|
||||||
functionAddress = GetFunctionStart(address);
|
functionAddress = GetFunctionStart(address);
|
||||||
|
|
||||||
if (symmask & ST_DATA)
|
// If both are found, we always return the function, so just do that early.
|
||||||
dataAddress = GetDataStart(address);
|
|
||||||
|
|
||||||
if (functionAddress == INVALID_ADDRESS || dataAddress == INVALID_ADDRESS) {
|
|
||||||
if (functionAddress != INVALID_ADDRESS) {
|
if (functionAddress != INVALID_ADDRESS) {
|
||||||
if (info != NULL) {
|
if (info != NULL) {
|
||||||
info->type = ST_FUNCTION;
|
info->type = ST_FUNCTION;
|
||||||
info->address = functionAddress;
|
info->address = functionAddress;
|
||||||
info->size = GetFunctionSize(functionAddress);
|
info->size = GetFunctionSize(functionAddress);
|
||||||
|
info->moduleAddress = GetFunctionModuleAddress(functionAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (symmask & ST_DATA) {
|
||||||
|
dataAddress = GetDataStart(address);
|
||||||
|
|
||||||
if (dataAddress != INVALID_ADDRESS) {
|
if (dataAddress != INVALID_ADDRESS) {
|
||||||
if (info != NULL) {
|
if (info != NULL) {
|
||||||
info->type = ST_DATA;
|
info->type = ST_DATA;
|
||||||
info->address = dataAddress;
|
info->address = dataAddress;
|
||||||
info->size = GetDataSize(dataAddress);
|
info->size = GetDataSize(dataAddress);
|
||||||
|
info->moduleAddress = GetDataModuleAddress(dataAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if both exist, return the function
|
|
||||||
if (info != NULL) {
|
|
||||||
info->type = ST_FUNCTION;
|
|
||||||
info->address = functionAddress;
|
|
||||||
info->size = GetFunctionSize(functionAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 SymbolMap::GetNextSymbolAddress(u32 address, SymbolType symmask) {
|
u32 SymbolMap::GetNextSymbolAddress(u32 address, SymbolType symmask) {
|
||||||
lock_guard guard(lock_);
|
lock_guard guard(lock_);
|
||||||
const auto functionEntry = symmask & ST_FUNCTION ? activeFunctions.upper_bound(address) : activeFunctions.end();
|
const auto functionEntry = symmask & ST_FUNCTION ? activeFunctions.upper_bound(address) : activeFunctions.end();
|
||||||
|
@ -588,6 +582,15 @@ u32 SymbolMap::GetFunctionSize(u32 startAddress) const {
|
||||||
return it->second.size;
|
return it->second.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 SymbolMap::GetFunctionModuleAddress(u32 startAddress) const {
|
||||||
|
lock_guard guard(lock_);
|
||||||
|
auto it = activeFunctions.find(startAddress);
|
||||||
|
if (it == activeFunctions.end())
|
||||||
|
return INVALID_ADDRESS;
|
||||||
|
|
||||||
|
return GetModuleAbsoluteAddr(0, it->second.module);
|
||||||
|
}
|
||||||
|
|
||||||
int SymbolMap::GetFunctionNum(u32 address) const {
|
int SymbolMap::GetFunctionNum(u32 address) const {
|
||||||
lock_guard guard(lock_);
|
lock_guard guard(lock_);
|
||||||
u32 start = GetFunctionStart(address);
|
u32 start = GetFunctionStart(address);
|
||||||
|
@ -904,6 +907,14 @@ u32 SymbolMap::GetDataSize(u32 startAddress) const {
|
||||||
return it->second.size;
|
return it->second.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 SymbolMap::GetDataModuleAddress(u32 startAddress) const {
|
||||||
|
lock_guard guard(lock_);
|
||||||
|
auto it = activeData.find(startAddress);
|
||||||
|
if (it == activeData.end())
|
||||||
|
return INVALID_ADDRESS;
|
||||||
|
return GetModuleAbsoluteAddr(0, it->second.module);
|
||||||
|
}
|
||||||
|
|
||||||
DataType SymbolMap::GetDataType(u32 startAddress) const {
|
DataType SymbolMap::GetDataType(u32 startAddress) const {
|
||||||
lock_guard guard(lock_);
|
lock_guard guard(lock_);
|
||||||
auto it = activeData.find(startAddress);
|
auto it = activeData.find(startAddress);
|
||||||
|
|
|
@ -37,6 +37,7 @@ struct SymbolInfo {
|
||||||
SymbolType type;
|
SymbolType type;
|
||||||
u32 address;
|
u32 address;
|
||||||
u32 size;
|
u32 size;
|
||||||
|
u32 moduleAddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SymbolEntry {
|
struct SymbolEntry {
|
||||||
|
@ -93,6 +94,7 @@ public:
|
||||||
u32 GetFunctionStart(u32 address) const;
|
u32 GetFunctionStart(u32 address) const;
|
||||||
int GetFunctionNum(u32 address) const;
|
int GetFunctionNum(u32 address) const;
|
||||||
u32 GetFunctionSize(u32 startAddress) const;
|
u32 GetFunctionSize(u32 startAddress) const;
|
||||||
|
u32 GetFunctionModuleAddress(u32 startAddress) const;
|
||||||
bool SetFunctionSize(u32 startAddress, u32 newSize);
|
bool SetFunctionSize(u32 startAddress, u32 newSize);
|
||||||
bool RemoveFunction(u32 startAddress, bool removeName);
|
bool RemoveFunction(u32 startAddress, bool removeName);
|
||||||
// Search for the first address their may be a function after address.
|
// Search for the first address their may be a function after address.
|
||||||
|
@ -107,6 +109,7 @@ public:
|
||||||
void AddData(u32 address, u32 size, DataType type, int moduleIndex = -1);
|
void AddData(u32 address, u32 size, DataType type, int moduleIndex = -1);
|
||||||
u32 GetDataStart(u32 address) const;
|
u32 GetDataStart(u32 address) const;
|
||||||
u32 GetDataSize(u32 startAddress) const;
|
u32 GetDataSize(u32 startAddress) const;
|
||||||
|
u32 GetDataModuleAddress(u32 startAddress) const;
|
||||||
DataType GetDataType(u32 startAddress) const;
|
DataType GetDataType(u32 startAddress) const;
|
||||||
|
|
||||||
static const u32 INVALID_ADDRESS = (u32)-1;
|
static const u32 INVALID_ADDRESS = (u32)-1;
|
||||||
|
|
|
@ -751,7 +751,8 @@ skip:
|
||||||
// We still need to insert the func for hashing purposes.
|
// We still need to insert the func for hashing purposes.
|
||||||
currentFunction.start = syminfo.address;
|
currentFunction.start = syminfo.address;
|
||||||
currentFunction.end = syminfo.address + syminfo.size - 4;
|
currentFunction.end = syminfo.address + syminfo.size - 4;
|
||||||
currentFunction.foundInSymbolMap = true;
|
// Re-add it to the map if the module address is not known yet (only happens from loaded maps.)
|
||||||
|
currentFunction.foundInSymbolMap = syminfo.moduleAddress != 0;
|
||||||
functions.push_back(currentFunction);
|
functions.push_back(currentFunction);
|
||||||
currentFunction.foundInSymbolMap = false;
|
currentFunction.foundInSymbolMap = false;
|
||||||
currentFunction.start = addr + 4;
|
currentFunction.start = addr + 4;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue