Made SymbolLookup safe to be used for the kernel team. Only the image

file based functionality will be used.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27667 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-09-21 13:02:13 +00:00
parent 82368346f8
commit d8b24b47e3
+36 -24
View File
@@ -80,12 +80,16 @@ RemoteMemoryAccessor::~RemoteMemoryAccessor()
status_t status_t
RemoteMemoryAccessor::Init() RemoteMemoryAccessor::Init()
{ {
// If the team is the kernel team, we don't try to clone the areas. Only
// SymbolLookup's image file functionality will be available.
if (fTeam == B_SYSTEM_TEAM)
return B_OK;
// get a list of the team's areas // get a list of the team's areas
area_info areaInfo; area_info areaInfo;
int32 cookie = 0; int32 cookie = 0;
status_t error; status_t error;
while ((error = get_next_area_info(fTeam, &cookie, &areaInfo)) == B_OK) { while ((error = get_next_area_info(fTeam, &cookie, &areaInfo)) == B_OK) {
TRACE(("area %ld: address: %p, size: %ld, name: %s\n", areaInfo.area, TRACE(("area %ld: address: %p, size: %ld, name: %s\n", areaInfo.area,
areaInfo.address, areaInfo.size, areaInfo.name)); areaInfo.address, areaInfo.size, areaInfo.name));
@@ -428,39 +432,41 @@ SymbolLookup::Init()
if (error != B_OK) if (error != B_OK)
return error; return error;
TRACE(("SymbolLookup::Init(): searching debug area...\n")); if (fTeam != B_SYSTEM_TEAM) {
TRACE(("SymbolLookup::Init(): searching debug area...\n"));
// find the runtime loader debug area // find the runtime loader debug area
runtime_loader_debug_area *remoteDebugArea = NULL; runtime_loader_debug_area *remoteDebugArea = NULL;
int32 cookie = 0; int32 cookie = 0;
area_info areaInfo; area_info areaInfo;
while (get_next_area_info(fTeam, &cookie, &areaInfo) == B_OK) { while (get_next_area_info(fTeam, &cookie, &areaInfo) == B_OK) {
if (strcmp(areaInfo.name, RUNTIME_LOADER_DEBUG_AREA_NAME) == 0) { if (strcmp(areaInfo.name, RUNTIME_LOADER_DEBUG_AREA_NAME) == 0) {
remoteDebugArea = (runtime_loader_debug_area*)areaInfo.address; remoteDebugArea = (runtime_loader_debug_area*)areaInfo.address;
break; break;
}
} }
}
if (!remoteDebugArea) { if (!remoteDebugArea) {
TRACE(("SymbolLookup::Init(): Couldn't find debug area!\n")); TRACE(("SymbolLookup::Init(): Couldn't find debug area!\n"));
return B_ERROR; return B_ERROR;
} }
TRACE(("SymbolLookup::Init(): found debug area, translating address...\n")); TRACE(("SymbolLookup::Init(): found debug area, translating address...\n"));
// translate the address // translate the address
try { try {
fDebugArea = &Read(*remoteDebugArea); fDebugArea = &Read(*remoteDebugArea);
TRACE(("SymbolLookup::Init(): translated debug area is at: %p, " TRACE(("SymbolLookup::Init(): translated debug area is at: %p, "
"loaded_images: %p\n", fDebugArea, fDebugArea->loaded_images)); "loaded_images: %p\n", fDebugArea, fDebugArea->loaded_images));
} catch (Exception exception) { } catch (Exception exception) {
return exception.Error(); return exception.Error();
}
} }
// create a list of the team's images // create a list of the team's images
image_info imageInfo; image_info imageInfo;
cookie = 0; int32 cookie = 0;
while (get_next_image_info(fTeam, &cookie, &imageInfo) == B_OK) { while (get_next_image_info(fTeam, &cookie, &imageInfo) == B_OK) {
ImageFile* imageFile = new(std::nothrow) ImageFile(imageInfo); ImageFile* imageFile = new(std::nothrow) ImageFile(imageInfo);
if (imageFile == NULL) if (imageFile == NULL)
@@ -689,6 +695,9 @@ SymbolLookup::_FindImageAtAddress(addr_t address) const
{ {
TRACE(("SymbolLookup::_FindImageAtAddress(%p)\n", (void*)address)); TRACE(("SymbolLookup::_FindImageAtAddress(%p)\n", (void*)address));
if (fDebugArea == NULL)
return NULL;
// iterate through the images // iterate through the images
for (const image_t *image = &Read(*Read(fDebugArea->loaded_images->head)); for (const image_t *image = &Read(*Read(fDebugArea->loaded_images->head));
image; image;
@@ -707,6 +716,9 @@ SymbolLookup::_FindImageAtAddress(addr_t address) const
const image_t* const image_t*
SymbolLookup::_FindImageByID(image_id id) const SymbolLookup::_FindImageByID(image_id id) const
{ {
if (fDebugArea == NULL)
return NULL;
// iterate through the images // iterate through the images
for (const image_t *image = &Read(*Read(fDebugArea->loaded_images->head)); for (const image_t *image = &Read(*Read(fDebugArea->loaded_images->head));
image; image;