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:
Unknown W. Brackets 2014-05-04 01:24:18 -07:00
parent 4706876809
commit c3a6092e26
3 changed files with 31 additions and 16 deletions

View File

@ -287,44 +287,38 @@ bool SymbolMap::GetSymbolInfo(SymbolInfo *info, u32 address, SymbolType symmask)
u32 functionAddress = INVALID_ADDRESS;
u32 dataAddress = INVALID_ADDRESS;
if (symmask & ST_FUNCTION)
if (symmask & ST_FUNCTION) {
functionAddress = GetFunctionStart(address);
if (symmask & ST_DATA)
dataAddress = GetDataStart(address);
if (functionAddress == INVALID_ADDRESS || dataAddress == INVALID_ADDRESS) {
// If both are found, we always return the function, so just do that early.
if (functionAddress != INVALID_ADDRESS) {
if (info != NULL) {
info->type = ST_FUNCTION;
info->address = functionAddress;
info->size = GetFunctionSize(functionAddress);
info->moduleAddress = GetFunctionModuleAddress(functionAddress);
}
return true;
}
}
if (symmask & ST_DATA) {
dataAddress = GetDataStart(address);
if (dataAddress != INVALID_ADDRESS) {
if (info != NULL) {
info->type = ST_DATA;
info->address = dataAddress;
info->size = GetDataSize(dataAddress);
info->moduleAddress = GetDataModuleAddress(dataAddress);
}
return true;
}
return false;
}
// if both exist, return the function
if (info != NULL) {
info->type = ST_FUNCTION;
info->address = functionAddress;
info->size = GetFunctionSize(functionAddress);
}
return true;
return false;
}
u32 SymbolMap::GetNextSymbolAddress(u32 address, SymbolType symmask) {
@ -588,6 +582,15 @@ u32 SymbolMap::GetFunctionSize(u32 startAddress) const {
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 {
lock_guard guard(lock_);
u32 start = GetFunctionStart(address);
@ -904,6 +907,14 @@ u32 SymbolMap::GetDataSize(u32 startAddress) const {
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 {
lock_guard guard(lock_);
auto it = activeData.find(startAddress);

View File

@ -37,6 +37,7 @@ struct SymbolInfo {
SymbolType type;
u32 address;
u32 size;
u32 moduleAddress;
};
struct SymbolEntry {
@ -93,6 +94,7 @@ public:
u32 GetFunctionStart(u32 address) const;
int GetFunctionNum(u32 address) const;
u32 GetFunctionSize(u32 startAddress) const;
u32 GetFunctionModuleAddress(u32 startAddress) const;
bool SetFunctionSize(u32 startAddress, u32 newSize);
bool RemoveFunction(u32 startAddress, bool removeName);
// 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);
u32 GetDataStart(u32 address) const;
u32 GetDataSize(u32 startAddress) const;
u32 GetDataModuleAddress(u32 startAddress) const;
DataType GetDataType(u32 startAddress) const;
static const u32 INVALID_ADDRESS = (u32)-1;

View File

@ -751,7 +751,8 @@ skip:
// We still need to insert the func for hashing purposes.
currentFunction.start = syminfo.address;
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);
currentFunction.foundInSymbolMap = false;
currentFunction.start = addr + 4;