From cd65e69b009cfb70d8a3805a73219b28183612bf Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 1 Nov 2008 21:06:44 +0000 Subject: [PATCH] Callgrind output: Encode the thread name and the total time the thread used into the file name. This makes it easier to find the thread(s) one is looking for. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28446 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../profile/CallgrindThreadProfileResult.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/bin/debug/profile/CallgrindThreadProfileResult.cpp b/src/bin/debug/profile/CallgrindThreadProfileResult.cpp index 818356e609..5124e46e19 100644 --- a/src/bin/debug/profile/CallgrindThreadProfileResult.cpp +++ b/src/bin/debug/profile/CallgrindThreadProfileResult.cpp @@ -167,12 +167,24 @@ void CallgrindThreadProfileResult::PrintResults() { // create output file + + // create output dir mkdir(gOptions.callgrind_directory, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); - char fileName[B_PATH_NAME_LENGTH]; - snprintf(fileName, sizeof(fileName), "%s/callgrind.out.%ld", - gOptions.callgrind_directory, fThread->ID()); + // get the thread name and replace slashes by hyphens + char threadName[B_OS_NAME_LENGTH]; + strlcpy(threadName, fThread->Name(), sizeof(threadName)); + char* slash = threadName; + while ((slash = strchr(slash, '/')) != NULL) + *slash = '-'; + // create the file name + char fileName[B_PATH_NAME_LENGTH]; + snprintf(fileName, sizeof(fileName), "%s/callgrind.out.%ld.%s.%lldms", + gOptions.callgrind_directory, fThread->ID(), threadName, + fTotalTicks * fInterval); + + // create the file FILE* out = fopen(fileName, "w+"); if (out == NULL) { fprintf(stderr, "%s: Failed to open output file \"%s\": %s\n",