bin/debug/profile: Fix -Wformat=

Change-Id: I94f9e4e68b75a7b84883d1bb7fe3f4e0aa7c6b8a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1563
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Murai Takashi 2019-07-06 09:06:33 +09:00 committed by Adrien Destugues
parent 7f58661749
commit 4de612c9b5
5 changed files with 51 additions and 30 deletions

View File

@ -175,15 +175,19 @@ BasicProfileResult::PrintResults(ImageProfileResultContainer* container)
fprintf(gOptions.output, "\nprofiling results for %s \"%s\" "
"(%" B_PRId32 "):\n", fEntity->EntityType(), fEntity->EntityName(),
fEntity->EntityID());
fprintf(gOptions.output, " tick interval: %lld us\n", fInterval);
fprintf(gOptions.output, " total ticks: %lld (%lld us)\n",
fprintf(gOptions.output, " tick interval: %" B_PRIdBIGTIME " us\n",
fInterval);
fprintf(gOptions.output,
" total ticks: %" B_PRId64 " (%" B_PRId64 " us)\n",
totalTicks, totalTicks * fInterval);
if (totalTicks == 0)
totalTicks = 1;
fprintf(gOptions.output, " unknown ticks: %lld (%lld us, %6.2f%%)\n",
fprintf(gOptions.output,
" unknown ticks: %" B_PRId64 " (%" B_PRId64 " us, %6.2f%%)\n",
fUnkownTicks, fUnkownTicks * fInterval,
100.0 * fUnkownTicks / totalTicks);
fprintf(gOptions.output, " dropped ticks: %lld (%lld us, %6.2f%%)\n",
fprintf(gOptions.output,
" dropped ticks: %" B_PRId64 " (%" B_PRId64 " us, %6.2f%%)\n",
fDroppedTicks, fDroppedTicks * fInterval,
100.0 * fDroppedTicks / totalTicks);
if (gOptions.analyze_full_stack) {
@ -198,7 +202,8 @@ BasicProfileResult::PrintResults(ImageProfileResultContainer* container)
"---------------------------------------\n");
for (int32 k = 0; k < imageCount; k++) {
BasicImageProfileResult* image = images[k];
fprintf(gOptions.output, " %10lld %10lld %7ld %s\n",
fprintf(gOptions.output,
" %10" B_PRId64 " %10" B_PRId64 " %7" B_PRId32 " %s\n",
image->TotalHits(), image->UnknownHits(),
image->ID(), image->GetImage()->Name());
}
@ -222,8 +227,9 @@ BasicProfileResult::PrintResults(ImageProfileResultContainer* container)
#else
const char* symbolName = symbol->Name();
#endif
fprintf(gOptions.output, " %10lld %10lld %6.2f %6ld %s\n",
hitSymbol.hits, hitSymbol.hits * fInterval,
fprintf(gOptions.output,
" %10" B_PRId64 " %10" B_PRId64 " %6.2f %6" B_PRId32
" %s\n", hitSymbol.hits, hitSymbol.hits * fInterval,
100.0 * hitSymbol.hits / totalTicks, hitSymbol.imageID,
symbolName);
#if __GNUC__ > 2

View File

@ -187,7 +187,8 @@ CallgrindProfileResult::PrintResults(ImageProfileResultContainer* container)
// create the file name
char fileName[B_PATH_NAME_LENGTH];
snprintf(fileName, sizeof(fileName), "%s/callgrind.out.%ld.%s.%lldms",
snprintf(fileName, sizeof(fileName),
"%s/callgrind.out.%" B_PRId32 ".%s.%" B_PRId64 "ms",
gOptions.callgrind_directory, fEntity->EntityID(), entityName,
fTotalTicks * fInterval);
@ -202,13 +203,14 @@ CallgrindProfileResult::PrintResults(ImageProfileResultContainer* container)
// write the header
fprintf(out, "version: 1\n");
fprintf(out, "creator: Haiku profile\n");
fprintf(out, "pid: %ld\n", fEntity->EntityID());
fprintf(out, "pid: %" B_PRId32 "\n", fEntity->EntityID());
fprintf(out, "cmd: %s\n", fEntity->EntityName());
fprintf(out, "part: 1\n\n");
fprintf(out, "positions: line\n");
fprintf(out, "events: Ticks Time\n");
fprintf(out, "summary: %lld %lld\n", fTotalTicks, fTotalTicks * fInterval);
fprintf(out, "summary: %" B_PRId64 " %" B_PRId64 "\n",
fTotalTicks, fTotalTicks * fInterval);
// get hit images
CallgrindImageProfileResult* images[container->CountImages()];
@ -226,16 +228,16 @@ CallgrindProfileResult::PrintResults(ImageProfileResultContainer* container)
fprintf(out, "\n");
_PrintFunction(out, image, k, false);
fprintf(out, "0 %lld %lld\n", function.hits,
fprintf(out, "0 %" B_PRId64 " %" B_PRId64 "\n", function.hits,
function.hits * fInterval);
CallgrindCalledFunction* calledFunction = function.calledFunctions;
while (calledFunction != NULL) {
_PrintFunction(out, calledFunction->image,
calledFunction->function, true);
fprintf(out, "calls=%lld 0\n", calledFunction->hits);
fprintf(out, "0 %lld %lld\n", calledFunction->hits,
calledFunction->hits * fInterval);
fprintf(out, "calls=%" B_PRId64 " 0\n", calledFunction->hits);
fprintf(out, "0 %" B_PRId64 " %" B_PRId64 "\n",
calledFunction->hits, calledFunction->hits * fInterval);
calledFunction = calledFunction->next;
}
}
@ -247,16 +249,17 @@ CallgrindProfileResult::PrintResults(ImageProfileResultContainer* container)
if (fUnkownTicks > 0) {
fprintf(out, "\nfn=unknown\n");
fprintf(out, "0 %lld\n", fUnkownTicks);
fprintf(out, "0 %" B_PRId64 "\n", fUnkownTicks);
}
if (fDroppedTicks > 0) {
fprintf(out, "\nfn=dropped\n");
fprintf(out, "0 %lld\n", fDroppedTicks);
fprintf(out, "0 %" B_PRId64 "\n", fDroppedTicks);
}
}
fprintf(out, "\ntotals: %lld %lld\n", fTotalTicks, fTotalTicks * fInterval);
fprintf(out, "\ntotals: %" B_PRId64 " %" B_PRId64 "\n",
fTotalTicks, fTotalTicks * fInterval);
fclose(out);
}
@ -290,22 +293,27 @@ CallgrindProfileResult::_PrintFunction(FILE* out,
// need to print the image name
int32 index = fNextImageOutputIndex++;
image->SetOutputIndex(index);
fprintf(out, "%sob=(%ld) %s:%ld\n", called ? "c" : "", index,
image->GetImage()->Name(), image->ID());
fprintf(out,
"%sob=(%" B_PRId32 ") %s:%" B_PRId32 "\n", called ? "c" : "",
index, image->GetImage()->Name(), image->ID());
} else {
// image is already known
// TODO: We may not need to print it at all!
fprintf(out, "%sob=(%ld)\n", called ? "c" : "", image->OutputIndex());
fprintf(out,
"%sob=(%" B_PRId32 ")\n", called ? "c" : "", image->OutputIndex());
}
CallgrindFunction& function = image->Functions()[functionIndex];
if (function.outputIndex == 0) {
// need to print the function name
function.outputIndex = fNextFunctionOutputIndex++;
fprintf(out, "%sfn=(%ld) %s\n", called ? "c" : "", function.outputIndex,
fprintf(out,
"%sfn=(%" B_PRId32 ") %s\n", called ? "c" : "",
function.outputIndex,
image->GetImage()->Symbols()[functionIndex]->Name());
} else {
// function is already known
fprintf(out, "%sfn=(%ld)\n", called ? "c" : "", function.outputIndex);
fprintf(out,
"%sfn=(%" B_PRId32 ")\n", called ? "c" : "", function.outputIndex);
}
}

View File

@ -44,7 +44,8 @@ SharedImage::Init(team_id owner, image_id imageID)
&lookupContext);
if (error != B_OK) {
fprintf(stderr, "%s: Failed to create symbol lookup context "
"for team %ld: %s\n", kCommandName, owner, strerror(error));
"for team %" B_PRId32 ": %s\n",
kCommandName, owner, strerror(error));
return error;
}
@ -56,7 +57,8 @@ SharedImage::Init(team_id owner, image_id imageID)
error = debug_create_image_symbol_iterator(lookupContext, imageID,
&iterator);
if (error != B_OK) {
fprintf(stderr, "Failed to init symbol iterator for image %ld: %s\n",
fprintf(stderr,
"Failed to init symbol iterator for image %" B_PRId32 ": %s\n",
imageID, strerror(error));
debug_delete_symbol_lookup_context(lookupContext);
return error;

View File

@ -71,7 +71,8 @@ Team::Init(team_id teamID, port_id debuggerPort)
// install ourselves as the team debugger
fNubPort = install_team_debugger(teamID, debuggerPort);
if (fNubPort < 0) {
fprintf(stderr, "%s: Failed to install as debugger for team %ld: "
fprintf(stderr,
"%s: Failed to install as debugger for team %" B_PRId32 ": "
"%s\n", kCommandName, teamID, strerror(fNubPort));
return fNubPort;
}
@ -79,7 +80,8 @@ Team::Init(team_id teamID, port_id debuggerPort)
// init debug context
error = init_debug_context(&fDebugContext, teamID, fNubPort);
if (error != B_OK) {
fprintf(stderr, "%s: Failed to init debug context for team %ld: "
fprintf(stderr,
"%s: Failed to init debug context for team %" B_PRId32 ": "
"%s\n", kCommandName, teamID, strerror(error));
return error;
}
@ -112,13 +114,14 @@ Team::InitThread(Thread* thread)
// create the sample area
char areaName[B_OS_NAME_LENGTH];
snprintf(areaName, sizeof(areaName), "profiling samples %ld",
snprintf(areaName, sizeof(areaName), "profiling samples %" B_PRId32,
thread->ID());
void* samples;
area_id sampleArea = create_area(areaName, &samples, B_ANY_ADDRESS,
SAMPLE_AREA_SIZE, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
if (sampleArea < 0) {
fprintf(stderr, "%s: Failed to create sample area for thread %ld: "
fprintf(stderr,
"%s: Failed to create sample area for thread %" B_PRId32 ": "
"%s\n", kCommandName, thread->ID(), strerror(sampleArea));
return sampleArea;
}
@ -160,7 +163,8 @@ Team::InitThread(Thread* thread)
B_DEBUG_START_PROFILER, &message, sizeof(message), &reply,
sizeof(reply));
if (error != B_OK || (error = reply.error) != B_OK) {
fprintf(stderr, "%s: Failed to start profiler for thread %ld: %s\n",
fprintf(stderr,
"%s: Failed to start profiler for thread %" B_PRId32 ": %s\n",
kCommandName, thread->ID(), strerror(error));
return error;
}

View File

@ -858,7 +858,8 @@ profile_single(const char* const* programArgs, int programArgCount)
thread_info threadInfo;
status_t error = get_thread_info(threadID, &threadInfo);
if (error != B_OK) {
fprintf(stderr, "%s: Failed to get info for thread %ld: %s\n",
fprintf(stderr,
"%s: Failed to get info for thread %" B_PRId32 ": %s\n",
kCommandName, threadID, strerror(error));
exit(1);
}