Extend debug_create_symbol_lookup_context().
- debug_create_symbol_lookup_context() now takes an image ID parameter that can optionally be used to restrict the symbols it gathers to only those of the targeted image rather than the entire team, allowing for significantly more lightweight usage when the desired image is known. The previous behavior can still be obtained if desired by passing -1 as said ID. - Adjust callers.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2005-2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2013, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -220,11 +221,12 @@ private:
|
||||
|
||||
|
||||
// constructor
|
||||
SymbolLookup::SymbolLookup(team_id team)
|
||||
SymbolLookup::SymbolLookup(team_id team, image_id image)
|
||||
:
|
||||
RemoteMemoryAccessor(team),
|
||||
fDebugArea(NULL),
|
||||
fImages()
|
||||
fImages(),
|
||||
fImageID(image)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -281,53 +283,23 @@ SymbolLookup::Init()
|
||||
}
|
||||
}
|
||||
|
||||
// create a list of the team's images
|
||||
image_info imageInfo;
|
||||
int32 cookie = 0;
|
||||
while (get_next_image_info(fTeam, &cookie, &imageInfo) == B_OK) {
|
||||
Image* image;
|
||||
|
||||
if (fTeam == B_SYSTEM_TEAM) {
|
||||
// kernel image
|
||||
KernelImage* kernelImage = new(std::nothrow) KernelImage;
|
||||
if (kernelImage == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
error = kernelImage->Init(imageInfo);
|
||||
image = kernelImage;
|
||||
} else if (!strcmp("commpage", imageInfo.name)) {
|
||||
// commpage image
|
||||
CommPageImage* commPageImage = new(std::nothrow) CommPageImage;
|
||||
if (commPageImage == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
error = commPageImage->Init(imageInfo);
|
||||
image = commPageImage;
|
||||
} else {
|
||||
// userland image -- try to load an image file
|
||||
ImageFile* imageFile = new(std::nothrow) ImageFile;
|
||||
if (imageFile == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
error = imageFile->Init(imageInfo);
|
||||
image = imageFile;
|
||||
if (fImageID < 0) {
|
||||
// create a list of the team's images
|
||||
int32 cookie = 0;
|
||||
while (get_next_image_info(fTeam, &cookie, &imageInfo) == B_OK) {
|
||||
error = _LoadImageInfo(imageInfo);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
}
|
||||
} else {
|
||||
error = get_image_info(fImageID, &imageInfo);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
if (error != B_OK) {
|
||||
// initialization error -- fall back to the loaded image
|
||||
delete image;
|
||||
|
||||
const image_t* loadedImage = _FindLoadedImageByID(imageInfo.id);
|
||||
if (loadedImage == NULL)
|
||||
continue;
|
||||
|
||||
image = new(std::nothrow) LoadedImage(this, loadedImage,
|
||||
Read(loadedImage->symhash[1]));
|
||||
if (image == NULL)
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
fImages.Add(image);
|
||||
error = _LoadImageInfo(imageInfo);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
@@ -534,6 +506,58 @@ SymbolLookup::_SymbolNameLen(const char* address) const
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
SymbolLookup::_LoadImageInfo(const image_info& imageInfo)
|
||||
{
|
||||
status_t error = B_OK;
|
||||
|
||||
Image* image;
|
||||
if (fTeam == B_SYSTEM_TEAM) {
|
||||
// kernel image
|
||||
KernelImage* kernelImage = new(std::nothrow) KernelImage;
|
||||
if (kernelImage == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
error = kernelImage->Init(imageInfo);
|
||||
image = kernelImage;
|
||||
} else if (!strcmp("commpage", imageInfo.name)) {
|
||||
// commpage image
|
||||
CommPageImage* commPageImage = new(std::nothrow) CommPageImage;
|
||||
if (commPageImage == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
error = commPageImage->Init(imageInfo);
|
||||
image = commPageImage;
|
||||
} else {
|
||||
// userland image -- try to load an image file
|
||||
ImageFile* imageFile = new(std::nothrow) ImageFile;
|
||||
if (imageFile == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
error = imageFile->Init(imageInfo);
|
||||
image = imageFile;
|
||||
}
|
||||
|
||||
if (error != B_OK) {
|
||||
// initialization error -- fall back to the loaded image
|
||||
delete image;
|
||||
|
||||
const image_t* loadedImage = _FindLoadedImageByID(imageInfo.id);
|
||||
if (loadedImage == NULL)
|
||||
return B_OK;
|
||||
|
||||
image = new(std::nothrow) LoadedImage(this, loadedImage,
|
||||
Read(loadedImage->symhash[1]));
|
||||
if (image == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
}
|
||||
|
||||
fImages.Add(image);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// #pragma mark - LoadedImage
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2005-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2013, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -136,7 +137,7 @@ struct SymbolIterator {
|
||||
// SymbolLookup
|
||||
class SymbolLookup : private RemoteMemoryAccessor {
|
||||
public:
|
||||
SymbolLookup(team_id team);
|
||||
SymbolLookup(team_id team, image_id image);
|
||||
~SymbolLookup();
|
||||
|
||||
status_t Init();
|
||||
@@ -166,10 +167,12 @@ private:
|
||||
Image* _FindImageAtAddress(addr_t address) const;
|
||||
Image* _FindImageByID(image_id id) const;
|
||||
size_t _SymbolNameLen(const char* address) const;
|
||||
status_t _LoadImageInfo(const image_info& imageInfo);
|
||||
|
||||
private:
|
||||
const runtime_loader_debug_area *fDebugArea;
|
||||
DoublyLinkedList<Image> fImages;
|
||||
image_id fImageID;
|
||||
};
|
||||
|
||||
} // namespace Debug
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2005-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2010, Rene Gollent, rene@gollent.com.
|
||||
* Copyright 2010-2013, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -345,7 +345,7 @@ debug_get_stack_frame(debug_context *context, void *stackFrameAddress,
|
||||
|
||||
// debug_create_symbol_lookup_context
|
||||
status_t
|
||||
debug_create_symbol_lookup_context(team_id team,
|
||||
debug_create_symbol_lookup_context(team_id team, image_id image,
|
||||
debug_symbol_lookup_context **_lookupContext)
|
||||
{
|
||||
if (team < 0 || !_lookupContext)
|
||||
@@ -359,7 +359,7 @@ debug_create_symbol_lookup_context(team_id team,
|
||||
ObjectDeleter<debug_symbol_lookup_context> contextDeleter(lookupContext);
|
||||
|
||||
// create and init symbol lookup
|
||||
SymbolLookup *lookup = new(std::nothrow) SymbolLookup(team);
|
||||
SymbolLookup *lookup = new(std::nothrow) SymbolLookup(team, image);
|
||||
if (lookup == NULL)
|
||||
return B_NO_MEMORY;
|
||||
ObjectDeleter<SymbolLookup> lookupDeleter(lookup);
|
||||
|
||||
Reference in New Issue
Block a user