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
This commit is contained in:
@@ -167,12 +167,24 @@ void
|
|||||||
CallgrindThreadProfileResult::PrintResults()
|
CallgrindThreadProfileResult::PrintResults()
|
||||||
{
|
{
|
||||||
// create output file
|
// create output file
|
||||||
|
|
||||||
|
// create output dir
|
||||||
mkdir(gOptions.callgrind_directory, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
mkdir(gOptions.callgrind_directory, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||||
|
|
||||||
char fileName[B_PATH_NAME_LENGTH];
|
// get the thread name and replace slashes by hyphens
|
||||||
snprintf(fileName, sizeof(fileName), "%s/callgrind.out.%ld",
|
char threadName[B_OS_NAME_LENGTH];
|
||||||
gOptions.callgrind_directory, fThread->ID());
|
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+");
|
FILE* out = fopen(fileName, "w+");
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
fprintf(stderr, "%s: Failed to open output file \"%s\": %s\n",
|
fprintf(stderr, "%s: Failed to open output file \"%s\": %s\n",
|
||||||
|
|||||||
Reference in New Issue
Block a user