bin/debug/profile: Fix -Wformat=

Change-Id: I94f9e4e68b75a7b84883d1bb7fe3f4e0aa7c6b8a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1563
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Murai Takashi
2019-12-07 16:06:50 +00:00
committed by Adrien Destugues
parent 7f58661749
commit 4de612c9b5
5 changed files with 51 additions and 30 deletions
+13 -7
View File
@@ -175,15 +175,19 @@ BasicProfileResult::PrintResults(ImageProfileResultContainer* container)
fprintf(gOptions.output, "\nprofiling results for %s \"%s\" " fprintf(gOptions.output, "\nprofiling results for %s \"%s\" "
"(%" B_PRId32 "):\n", fEntity->EntityType(), fEntity->EntityName(), "(%" B_PRId32 "):\n", fEntity->EntityType(), fEntity->EntityName(),
fEntity->EntityID()); fEntity->EntityID());
fprintf(gOptions.output, " tick interval: %lld us\n", fInterval); fprintf(gOptions.output, " tick interval: %" B_PRIdBIGTIME " us\n",
fprintf(gOptions.output, " total ticks: %lld (%lld us)\n", fInterval);
fprintf(gOptions.output,
" total ticks: %" B_PRId64 " (%" B_PRId64 " us)\n",
totalTicks, totalTicks * fInterval); totalTicks, totalTicks * fInterval);
if (totalTicks == 0) if (totalTicks == 0)
totalTicks = 1; 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, fUnkownTicks, fUnkownTicks * fInterval,
100.0 * fUnkownTicks / totalTicks); 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, fDroppedTicks, fDroppedTicks * fInterval,
100.0 * fDroppedTicks / totalTicks); 100.0 * fDroppedTicks / totalTicks);
if (gOptions.analyze_full_stack) { if (gOptions.analyze_full_stack) {
@@ -198,7 +202,8 @@ BasicProfileResult::PrintResults(ImageProfileResultContainer* container)
"---------------------------------------\n"); "---------------------------------------\n");
for (int32 k = 0; k < imageCount; k++) { for (int32 k = 0; k < imageCount; k++) {
BasicImageProfileResult* image = images[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->TotalHits(), image->UnknownHits(),
image->ID(), image->GetImage()->Name()); image->ID(), image->GetImage()->Name());
} }
@@ -222,8 +227,9 @@ BasicProfileResult::PrintResults(ImageProfileResultContainer* container)
#else #else
const char* symbolName = symbol->Name(); const char* symbolName = symbol->Name();
#endif #endif
fprintf(gOptions.output, " %10lld %10lld %6.2f %6ld %s\n", fprintf(gOptions.output,
hitSymbol.hits, hitSymbol.hits * fInterval, " %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, 100.0 * hitSymbol.hits / totalTicks, hitSymbol.imageID,
symbolName); symbolName);
#if __GNUC__ > 2 #if __GNUC__ > 2
@@ -187,7 +187,8 @@ CallgrindProfileResult::PrintResults(ImageProfileResultContainer* container)
// create the file name // create the file name
char fileName[B_PATH_NAME_LENGTH]; 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, gOptions.callgrind_directory, fEntity->EntityID(), entityName,
fTotalTicks * fInterval); fTotalTicks * fInterval);
@@ -202,13 +203,14 @@ CallgrindProfileResult::PrintResults(ImageProfileResultContainer* container)
// write the header // write the header
fprintf(out, "version: 1\n"); fprintf(out, "version: 1\n");
fprintf(out, "creator: Haiku profile\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, "cmd: %s\n", fEntity->EntityName());
fprintf(out, "part: 1\n\n"); fprintf(out, "part: 1\n\n");
fprintf(out, "positions: line\n"); fprintf(out, "positions: line\n");
fprintf(out, "events: Ticks Time\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 // get hit images
CallgrindImageProfileResult* images[container->CountImages()]; CallgrindImageProfileResult* images[container->CountImages()];
@@ -226,16 +228,16 @@ CallgrindProfileResult::PrintResults(ImageProfileResultContainer* container)
fprintf(out, "\n"); fprintf(out, "\n");
_PrintFunction(out, image, k, false); _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); function.hits * fInterval);
CallgrindCalledFunction* calledFunction = function.calledFunctions; CallgrindCalledFunction* calledFunction = function.calledFunctions;
while (calledFunction != NULL) { while (calledFunction != NULL) {
_PrintFunction(out, calledFunction->image, _PrintFunction(out, calledFunction->image,
calledFunction->function, true); calledFunction->function, true);
fprintf(out, "calls=%lld 0\n", calledFunction->hits); fprintf(out, "calls=%" B_PRId64 " 0\n", calledFunction->hits);
fprintf(out, "0 %lld %lld\n", calledFunction->hits, fprintf(out, "0 %" B_PRId64 " %" B_PRId64 "\n",
calledFunction->hits * fInterval); calledFunction->hits, calledFunction->hits * fInterval);
calledFunction = calledFunction->next; calledFunction = calledFunction->next;
} }
} }
@@ -247,16 +249,17 @@ CallgrindProfileResult::PrintResults(ImageProfileResultContainer* container)
if (fUnkownTicks > 0) { if (fUnkownTicks > 0) {
fprintf(out, "\nfn=unknown\n"); fprintf(out, "\nfn=unknown\n");
fprintf(out, "0 %lld\n", fUnkownTicks); fprintf(out, "0 %" B_PRId64 "\n", fUnkownTicks);
} }
if (fDroppedTicks > 0) { if (fDroppedTicks > 0) {
fprintf(out, "\nfn=dropped\n"); 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); fclose(out);
} }
@@ -290,22 +293,27 @@ CallgrindProfileResult::_PrintFunction(FILE* out,
// need to print the image name // need to print the image name
int32 index = fNextImageOutputIndex++; int32 index = fNextImageOutputIndex++;
image->SetOutputIndex(index); image->SetOutputIndex(index);
fprintf(out, "%sob=(%ld) %s:%ld\n", called ? "c" : "", index, fprintf(out,
image->GetImage()->Name(), image->ID()); "%sob=(%" B_PRId32 ") %s:%" B_PRId32 "\n", called ? "c" : "",
index, image->GetImage()->Name(), image->ID());
} else { } else {
// image is already known // image is already known
// TODO: We may not need to print it at all! // 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]; CallgrindFunction& function = image->Functions()[functionIndex];
if (function.outputIndex == 0) { if (function.outputIndex == 0) {
// need to print the function name // need to print the function name
function.outputIndex = fNextFunctionOutputIndex++; 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()); image->GetImage()->Symbols()[functionIndex]->Name());
} else { } else {
// function is already known // function is already known
fprintf(out, "%sfn=(%ld)\n", called ? "c" : "", function.outputIndex); fprintf(out,
"%sfn=(%" B_PRId32 ")\n", called ? "c" : "", function.outputIndex);
} }
} }
+4 -2
View File
@@ -44,7 +44,8 @@ SharedImage::Init(team_id owner, image_id imageID)
&lookupContext); &lookupContext);
if (error != B_OK) { if (error != B_OK) {
fprintf(stderr, "%s: Failed to create symbol lookup context " 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; return error;
} }
@@ -56,7 +57,8 @@ SharedImage::Init(team_id owner, image_id imageID)
error = debug_create_image_symbol_iterator(lookupContext, imageID, error = debug_create_image_symbol_iterator(lookupContext, imageID,
&iterator); &iterator);
if (error != B_OK) { 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)); imageID, strerror(error));
debug_delete_symbol_lookup_context(lookupContext); debug_delete_symbol_lookup_context(lookupContext);
return error; return error;
+9 -5
View File
@@ -71,7 +71,8 @@ Team::Init(team_id teamID, port_id debuggerPort)
// install ourselves as the team debugger // install ourselves as the team debugger
fNubPort = install_team_debugger(teamID, debuggerPort); fNubPort = install_team_debugger(teamID, debuggerPort);
if (fNubPort < 0) { 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)); "%s\n", kCommandName, teamID, strerror(fNubPort));
return fNubPort; return fNubPort;
} }
@@ -79,7 +80,8 @@ Team::Init(team_id teamID, port_id debuggerPort)
// init debug context // init debug context
error = init_debug_context(&fDebugContext, teamID, fNubPort); error = init_debug_context(&fDebugContext, teamID, fNubPort);
if (error != B_OK) { 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)); "%s\n", kCommandName, teamID, strerror(error));
return error; return error;
} }
@@ -112,13 +114,14 @@ Team::InitThread(Thread* thread)
// create the sample area // create the sample area
char areaName[B_OS_NAME_LENGTH]; char areaName[B_OS_NAME_LENGTH];
snprintf(areaName, sizeof(areaName), "profiling samples %ld", snprintf(areaName, sizeof(areaName), "profiling samples %" B_PRId32,
thread->ID()); thread->ID());
void* samples; void* samples;
area_id sampleArea = create_area(areaName, &samples, B_ANY_ADDRESS, area_id sampleArea = create_area(areaName, &samples, B_ANY_ADDRESS,
SAMPLE_AREA_SIZE, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA); SAMPLE_AREA_SIZE, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
if (sampleArea < 0) { 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)); "%s\n", kCommandName, thread->ID(), strerror(sampleArea));
return sampleArea; return sampleArea;
} }
@@ -160,7 +163,8 @@ Team::InitThread(Thread* thread)
B_DEBUG_START_PROFILER, &message, sizeof(message), &reply, B_DEBUG_START_PROFILER, &message, sizeof(message), &reply,
sizeof(reply)); sizeof(reply));
if (error != B_OK || (error = reply.error) != B_OK) { 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)); kCommandName, thread->ID(), strerror(error));
return error; return error;
} }
+2 -1
View File
@@ -858,7 +858,8 @@ profile_single(const char* const* programArgs, int programArgCount)
thread_info threadInfo; thread_info threadInfo;
status_t error = get_thread_info(threadID, &threadInfo); status_t error = get_thread_info(threadID, &threadInfo);
if (error != B_OK) { 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)); kCommandName, threadID, strerror(error));
exit(1); exit(1);
} }