debug: update debug kit to correctly recognize commpage

This commit is contained in:
Pawel Dziepak
2013-04-04 15:27:23 +02:00
parent e85e399fd7
commit ffbf0328d2
5 changed files with 81 additions and 21 deletions
+62
View File
@@ -400,3 +400,65 @@ KernelImage::Init(const image_info& info)
fSymbolTable, &fSymbolCount, fStringTable, &fStringTableSize,
&fLoadDelta);
}
CommPageImage::CommPageImage()
{
}
CommPageImage::~CommPageImage()
{
delete[] fSymbolTable;
delete[] fStringTable;
}
status_t
CommPageImage::Init(const image_info& info)
{
// find kernel image for commpage
image_id commPageID = -1;
image_info commPageInfo;
int32 cookie = 0;
while (_kern_get_next_image_info(B_SYSTEM_TEAM, &cookie, &commPageInfo,
sizeof(image_info)) == B_OK) {
if (!strcmp("commpage", commPageInfo.name)) {
commPageID = commPageInfo.id;
break;
}
}
if (commPageID < 0)
return B_ENTRY_NOT_FOUND;
fInfo = commPageInfo;
fInfo.text = info.text;
// get the table sizes
fSymbolCount = 0;
fStringTableSize = 0;
status_t error = _kern_read_kernel_image_symbols(commPageID, NULL,
&fSymbolCount, NULL, &fStringTableSize, NULL);
if (error != B_OK)
return error;
// allocate the tables
fSymbolTable = new(std::nothrow) elf_sym[fSymbolCount];
fStringTable = new(std::nothrow) char[fStringTableSize];
if (fSymbolTable == NULL || fStringTable == NULL)
return B_NO_MEMORY;
// get the info
error = _kern_read_kernel_image_symbols(commPageID,
fSymbolTable, &fSymbolCount, fStringTable, &fStringTableSize, NULL);
if (error != B_OK) {
delete[] fSymbolTable;
delete[] fStringTable;
return error;
}
fLoadDelta = (addr_t)info.text;
return B_OK;
}
+9
View File
@@ -111,6 +111,15 @@ public:
status_t Init(const image_info& info);
};
class CommPageImage : public SymbolTableBasedImage {
public:
CommPageImage();
virtual ~CommPageImage();
status_t Init(const image_info& info);
};
} // namespace Debug
} // namespace BPrivate
+8
View File
@@ -295,6 +295,14 @@ SymbolLookup::Init()
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;