[Haiku-commits] r27688 - haiku/trunk/src/kits/debug
bonefish at BerliOS
bonefish at mail.berlios.de
Mon Sep 22 13:17:31 CEST 2008
Author: bonefish
Date: 2008-09-22 13:17:30 +0200 (Mon, 22 Sep 2008)
New Revision: 27688
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=27688&view=rev
Modified:
haiku/trunk/src/kits/debug/SymbolLookup.cpp
haiku/trunk/src/kits/debug/SymbolLookup.h
Log:
Rather use the new _kern_read_kernel_image_symbols() syscall to use
kernel image symbol tables.
Modified: haiku/trunk/src/kits/debug/SymbolLookup.cpp
===================================================================
--- haiku/trunk/src/kits/debug/SymbolLookup.cpp 2008-09-22 11:13:38 UTC (rev 27687)
+++ haiku/trunk/src/kits/debug/SymbolLookup.cpp 2008-09-22 11:17:30 UTC (rev 27688)
@@ -15,6 +15,7 @@
#include <new>
#include <runtime_loader.h>
+#include <syscalls.h>
#undef TRACE
@@ -208,8 +209,12 @@
ImageFile::~ImageFile()
{
- if (fMappedFile != MAP_FAILED)
+ if (fMappedFile != MAP_FAILED) {
munmap(fMappedFile, fFileSize);
+ } else {
+ delete[] fSymbolTable;
+ delete[] fStringTable;
+ }
if (fFD >= 0)
close(fFD);
@@ -297,9 +302,8 @@
return B_BAD_DATA;
}
- fSymbolTable
- = (const Elf32_Sym*)(fMappedFile + sectionHeader->sh_offset);
- fStringTable = (const char*)(fMappedFile + stringHeader.sh_offset);
+ fSymbolTable = (Elf32_Sym*)(fMappedFile + sectionHeader->sh_offset);
+ fStringTable = (char*)(fMappedFile + stringHeader.sh_offset);
fSymbolCount = sectionHeader->sh_size / sizeof(Elf32_Sym);
fStringTableSize = stringHeader.sh_size;
@@ -311,6 +315,30 @@
}
+status_t
+ImageFile::LoadKernel()
+{
+ // get the table sizes
+ fSymbolCount = 0;
+ fStringTableSize = 0;
+ status_t error = _kern_read_kernel_image_symbols(fInfo.id,
+ NULL, &fSymbolCount, NULL, &fStringTableSize, NULL);
+ if (error != B_OK)
+ return error;
+
+ // allocate the tables
+ fSymbolTable = new(std::nothrow) Elf32_Sym[fSymbolCount];
+ fStringTable = new(std::nothrow) char[fStringTableSize];
+ if (fSymbolTable == NULL || fStringTable == NULL)
+ return B_NO_MEMORY;
+
+ // get the info
+ return _kern_read_kernel_image_symbols(fInfo.id,
+ fSymbolTable, &fSymbolCount, fStringTable, &fStringTableSize,
+ &fLoadDelta);
+}
+
+
const Elf32_Sym*
ImageFile::LookupSymbol(addr_t address, addr_t* _baseAddress,
const char** _symbolName, size_t *_symbolNameLen, bool *_exactMatch) const
@@ -474,8 +502,12 @@
if (imageFile == NULL)
break;
- if (imageFile->Load() != B_OK)
+ error = fTeam == B_SYSTEM_TEAM
+ ? imageFile->LoadKernel() : imageFile->Load();
+ if (error != B_OK) {
delete imageFile;
+ continue;
+ }
fImageFiles.Add(imageFile);
}
Modified: haiku/trunk/src/kits/debug/SymbolLookup.h
===================================================================
--- haiku/trunk/src/kits/debug/SymbolLookup.h 2008-09-22 11:13:38 UTC (rev 27687)
+++ haiku/trunk/src/kits/debug/SymbolLookup.h 2008-09-22 11:17:30 UTC (rev 27688)
@@ -132,6 +132,7 @@
const image_info& Info() const { return fInfo; }
status_t Load();
+ status_t LoadKernel();
const Elf32_Sym* LookupSymbol(addr_t address, addr_t* _baseAddress,
const char** _symbolName, size_t *_symbolNameLen,
@@ -149,8 +150,8 @@
off_t fFileSize;
uint8* fMappedFile;
addr_t fLoadDelta;
- const Elf32_Sym* fSymbolTable;
- const char* fStringTable;
+ Elf32_Sym* fSymbolTable;
+ char* fStringTable;
int32 fSymbolCount;
size_t fStringTableSize;
};
More information about the Haiku-commits
mailing list