Also load all kernel images and their symbols. They are not tracked, but

usually they won't change during the runtime of the profiled program
anyway.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27668 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-09-21 13:06:50 +00:00
parent d8b24b47e3
commit d73be01714
+48 -11
View File
@@ -80,9 +80,10 @@ struct HitSymbol {
class Image : public Referenceable { class Image : public Referenceable {
public: public:
Image(const image_info& info, int32 creationEvent) Image(const image_info& info, team_id owner, int32 creationEvent)
: :
fInfo(info), fInfo(info),
fOwner(owner),
fSymbols(NULL), fSymbols(NULL),
fSymbolCount(0), fSymbolCount(0),
fCreationEvent(creationEvent), fCreationEvent(creationEvent),
@@ -109,6 +110,11 @@ public:
return fInfo; return fInfo;
} }
team_id Owner() const
{
return fOwner;
}
int32 CreationEvent() const int32 CreationEvent() const
{ {
return fCreationEvent; return fCreationEvent;
@@ -218,6 +224,7 @@ public:
private: private:
image_info fInfo; image_info fInfo;
team_id fOwner;
Symbol** fSymbols; Symbol** fSymbols;
int32 fSymbolCount; int32 fSymbolCount;
int32 fCreationEvent; int32 fCreationEvent;
@@ -646,11 +653,34 @@ public:
return error; return error;
} }
error = _LoadSymbols(lookupContext); // load the team's images and their symbols
error = _LoadSymbols(lookupContext, ID());
debug_delete_symbol_lookup_context(lookupContext); debug_delete_symbol_lookup_context(lookupContext);
if (error != B_OK) if (error != B_OK)
return error; return error;
// also try to load the kernel images and symbols
{
// fake a debug context -- it's not really needed anyway
debug_context debugContext;
debugContext.team = B_SYSTEM_TEAM;
debugContext.nub_port = -1;
debugContext.reply_port = -1;
// create symbol lookup context
error = debug_create_symbol_lookup_context(&debugContext,
&lookupContext);
if (error != B_OK) {
fprintf(stderr, "%s: Failed to create symbol lookup context "
"for the kernel team: %s\n", kCommandName, strerror(error));
return error;
}
// load the kernel's images and their symbols
_LoadSymbols(lookupContext, B_SYSTEM_TEAM);
debug_delete_symbol_lookup_context(lookupContext);
}
// set team debugging flags // set team debugging flags
int32 teamDebugFlags = B_TEAM_DEBUG_THREADS int32 teamDebugFlags = B_TEAM_DEBUG_THREADS
| B_TEAM_DEBUG_TEAM_CREATION | B_TEAM_DEBUG_IMAGES; | B_TEAM_DEBUG_TEAM_CREATION | B_TEAM_DEBUG_IMAGES;
@@ -728,10 +758,13 @@ public:
void Exec(int32 event) void Exec(int32 event)
{ {
// remove all images // remove all non-kernel images
int32 imageCount = fImages.CountItems(); int32 imageCount = fImages.CountItems();
for (int32 i = imageCount - 1; i >= 0; i--) for (int32 i = imageCount - 1; i >= 0; i--) {
_RemoveImage(i, event); Image* image = fImages.ItemAt(i);
if (image->Owner() == ID())
_RemoveImage(i, event);
}
// update the main thread // update the main thread
ThreadList::Iterator it = fThreads.GetIterator(); ThreadList::Iterator it = fThreads.GetIterator();
@@ -756,7 +789,8 @@ public:
} }
Image* image; Image* image;
error = _LoadImageSymbols(lookupContext, imageInfo, event, &image); error = _LoadImageSymbols(lookupContext, imageInfo, ID(), event,
&image);
debug_delete_symbol_lookup_context(lookupContext); debug_delete_symbol_lookup_context(lookupContext);
// Although we generally synchronize the threads' images lazily, we have // Although we generally synchronize the threads' images lazily, we have
@@ -804,13 +838,15 @@ public:
} }
private: private:
status_t _LoadSymbols(debug_symbol_lookup_context* lookupContext) status_t _LoadSymbols(debug_symbol_lookup_context* lookupContext,
team_id owner)
{ {
// iterate through the team's images and collect the symbols // iterate through the team's images and collect the symbols
image_info imageInfo; image_info imageInfo;
int32 cookie = 0; int32 cookie = 0;
while (get_next_image_info(fInfo.team, &cookie, &imageInfo) == B_OK) { while (get_next_image_info(owner, &cookie, &imageInfo) == B_OK) {
status_t error = _LoadImageSymbols(lookupContext, imageInfo, 0); status_t error = _LoadImageSymbols(lookupContext, imageInfo,
owner, 0);
if (error == B_NO_MEMORY) if (error == B_NO_MEMORY)
return error; return error;
} }
@@ -819,9 +855,10 @@ private:
} }
status_t _LoadImageSymbols(debug_symbol_lookup_context* lookupContext, status_t _LoadImageSymbols(debug_symbol_lookup_context* lookupContext,
const image_info& imageInfo, int32 event, Image** _image = NULL) const image_info& imageInfo, team_id owner, int32 event,
Image** _image = NULL)
{ {
Image* image = new(std::nothrow) Image(imageInfo, event); Image* image = new(std::nothrow) Image(imageInfo, owner, event);
if (image == NULL) if (image == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;