From 58d9ba9035c056b1162403dd49e750f21b842f3f Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 17 Jul 2024 13:31:54 -0400 Subject: [PATCH] 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. --- src/bin/debug/profile/CallgrindProfileResult.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/bin/debug/profile/CallgrindProfileResult.cpp b/src/bin/debug/profile/CallgrindProfileResult.cpp index ce5e0f0e55..fb39a54e3d 100644 --- a/src/bin/debug/profile/CallgrindProfileResult.cpp +++ b/src/bin/debug/profile/CallgrindProfileResult.cpp @@ -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!