profile: Emit paths only in the callgrind output.

The callgrind information should contain a path to an ELF file,
not an identifier. We thus only add the identifer when we don't
have something that looks like a path (or is the commpage.)

This allows applications that analyze callgrind output to merge
images with the same ELF file.
This commit is contained in:
Augustin Cavalier
2024-07-17 13:31:54 -04:00
parent ed79e85ae0
commit 58d9ba9035
@@ -302,9 +302,17 @@ CallgrindProfileResult::_PrintFunction(FILE* out,
// need to print the image name
int32 index = fNextImageOutputIndex++;
image->SetOutputIndex(index);
fprintf(out,
"%sob=(%" B_PRId32 ") %s:%" B_PRId32 "\n", called ? "c" : "",
index, image->GetImage()->Name(), image->ID());
const char* name = image->GetImage()->Name();
if (name[0] == '/' || strcmp(name, "commpage") == 0) {
fprintf(out,
"%sob=(%" B_PRId32 ") %s\n", called ? "c" : "",
index, name);
} else {
// add ID to image name
fprintf(out,
"%sob=(%" B_PRId32 ") %s:%" B_PRId32 "\n", called ? "c" : "",
index, name, image->ID());
}
} else {
// image is already known
// TODO: We may not need to print it at all!