Added debug_get_symbol(). It's not implemented particularly efficiently, though.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31392 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4d365bbed9
commit
9774f385b5
@ -62,6 +62,9 @@ status_t debug_create_symbol_lookup_context(team_id team,
|
||||
void debug_delete_symbol_lookup_context(
|
||||
debug_symbol_lookup_context *lookupContext);
|
||||
|
||||
status_t debug_get_symbol(debug_symbol_lookup_context* lookupContext,
|
||||
image_id image, const char* name, int32 symbolType,
|
||||
void** _symbolLocation, size_t* _symbolSize, int32* _symbolType);
|
||||
status_t debug_lookup_symbol_address(debug_symbol_lookup_context *lookupContext,
|
||||
const void *address, void **baseAddress, char *symbolName,
|
||||
int32 symbolNameSize, char *imageName, int32 imageNameSize,
|
||||
|
@ -34,6 +34,35 @@ Image::~Image()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Image::GetSymbol(const char* name, int32 symbolType, void** _symbolLocation,
|
||||
size_t* _symbolSize, int32* _symbolType) const
|
||||
{
|
||||
// TODO: At least for ImageFile we could do hash lookups!
|
||||
int32 iterator = 0;
|
||||
const char* foundName;
|
||||
size_t foundNameLen;
|
||||
addr_t foundAddress;
|
||||
size_t foundSize;
|
||||
int32 foundType;
|
||||
while (NextSymbol(iterator, &foundName, &foundNameLen, &foundAddress,
|
||||
&foundSize, &foundType) == B_OK) {
|
||||
if ((symbolType == B_SYMBOL_TYPE_ANY || symbolType == foundType)
|
||||
&& strcmp(name, foundName) == 0) {
|
||||
if (_symbolLocation != NULL)
|
||||
*_symbolLocation = (void*)foundAddress;
|
||||
if (_symbolSize != NULL)
|
||||
*_symbolSize = foundSize;
|
||||
if (_symbolType != NULL)
|
||||
*_symbolType = foundType;
|
||||
return B_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - SymbolTableBasedImage
|
||||
|
||||
|
||||
|
@ -46,6 +46,10 @@ public:
|
||||
addr_t* _symbolAddress, size_t* _symbolSize,
|
||||
int32* _symbolType) const = 0;
|
||||
|
||||
virtual status_t GetSymbol(const char* name, int32 symbolType,
|
||||
void** _symbolLocation, size_t* _symbolSize,
|
||||
int32* _symbolType) const;
|
||||
|
||||
protected:
|
||||
image_info fInfo;
|
||||
};
|
||||
|
@ -426,6 +426,20 @@ SymbolLookup::NextSymbol(SymbolIterator& iterator, const char** _symbolName,
|
||||
}
|
||||
|
||||
|
||||
// GetSymbol
|
||||
status_t
|
||||
SymbolLookup::GetSymbol(image_id imageID, const char* name, int32 symbolType,
|
||||
void** _symbolLocation, size_t* _symbolSize, int32* _symbolType) const
|
||||
{
|
||||
Image* image = _FindImageByID(imageID);
|
||||
if (image == NULL)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
return image->GetSymbol(name, symbolType, _symbolLocation, _symbolSize,
|
||||
_symbolType);
|
||||
}
|
||||
|
||||
|
||||
// _FindLoadedImageAtAddress
|
||||
const image_t *
|
||||
SymbolLookup::_FindLoadedImageAtAddress(addr_t address) const
|
||||
|
@ -154,6 +154,9 @@ public:
|
||||
size_t* _symbolNameLen, addr_t* _symbolAddress, size_t* _symbolSize,
|
||||
int32* _symbolType) const;
|
||||
|
||||
status_t GetSymbol(image_id imageID, const char* name, int32 symbolType,
|
||||
void** _symbolLocation, size_t* _symbolSize, int32* _symbolType) const;
|
||||
|
||||
private:
|
||||
class LoadedImage;
|
||||
friend class LoadedImage;
|
||||
|
@ -318,6 +318,22 @@ debug_delete_symbol_lookup_context(debug_symbol_lookup_context *lookupContext)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// debug_get_symbol
|
||||
status_t
|
||||
debug_get_symbol(debug_symbol_lookup_context* lookupContext, image_id image,
|
||||
const char* name, int32 symbolType, void** _symbolLocation,
|
||||
size_t* _symbolSize, int32* _symbolType)
|
||||
{
|
||||
if (!lookupContext || !lookupContext->lookup)
|
||||
return B_BAD_VALUE;
|
||||
SymbolLookup* lookup = lookupContext->lookup;
|
||||
|
||||
return lookup->GetSymbol(image, name, symbolType, _symbolLocation,
|
||||
_symbolSize, _symbolType);
|
||||
}
|
||||
|
||||
|
||||
// debug_lookup_symbol_address
|
||||
status_t
|
||||
debug_lookup_symbol_address(debug_symbol_lookup_context *lookupContext,
|
||||
|
Loading…
x
Reference in New Issue
Block a user