Skip to content

Commit 7ac36ff

Browse files
Merge branch 'public' into installer_update
2 parents 58b0b0a + 504908d commit 7ac36ff

File tree

11 files changed

+84
-62
lines changed

11 files changed

+84
-62
lines changed

PresentData/Debug.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ void VerboseTraceEventImpl(PMTraceConsumer* pmConsumer, EVENT_RECORD* eventRecor
465465
if (hdr.ProviderId == Microsoft_Windows_Kernel_Process::GUID) {
466466
using namespace Microsoft_Windows_Kernel_Process;
467467
switch (hdr.EventDescriptor.Id) {
468-
case ProcessStart_Start::Id: PrintEventHeader(eventRecord, metadata, "ProcessStart", { L"ImageName", PrintWString }); break;
469-
case ProcessStop_Stop::Id: PrintEventHeader(eventRecord, metadata, "ProcessStop", { L"ImageName", PrintString }); break;
468+
case ProcessStart_Start::Id: PrintEventHeader(eventRecord, metadata, "ProcessStart", { L"ProcessID", PrintU32, L"ImageName", PrintWString }); break;
469+
case ProcessStop_Stop::Id: PrintEventHeader(eventRecord, metadata, "ProcessStop", { L"ProcessID", PrintU32, L"ImageName", PrintString }); break;
470470
}
471471
return;
472472
}

PresentMon/CommandLine.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,17 @@ bool ParseKeyName(KeyNameCode const* valid, size_t validCount, char* name, char
151151
}
152152
}
153153

154-
int col = PrintError("error: %s '%s'.\nValid options (case insensitive):", errorMessage, name);
154+
int col = PrintErrorNoNewLine("error: %s '%s'.\nValid options (case insensitive):", errorMessage, name);
155155

156156
size_t consoleWidth = GetConsoleWidth();
157157
for (size_t i = 0; i < validCount; ++i) {
158158
auto len = strlen(valid[i].mName);
159159
if (col + len + 1 > consoleWidth) {
160-
col = PrintError("\n ") - 1;
160+
col = PrintErrorNoNewLine("\n ") - 1;
161161
}
162-
col += PrintError(" %s", valid[i].mName);
162+
col += PrintErrorNoNewLine(" %s", valid[i].mName);
163163
}
164-
PrintError("\n");
164+
fprintf(stderr, "\n");
165165

166166
return false;
167167
}
@@ -193,11 +193,11 @@ bool AssignHotkey(char* key, CommandLineArgs* args)
193193
void SetCaptureAll(CommandLineArgs* args)
194194
{
195195
if (!args->mTargetProcessNames.empty()) {
196-
PrintWarning("warning: -captureall elides all previous -process_name arguments.\n");
196+
PrintWarning("warning: -captureall elides all previous -process_name arguments.");
197197
args->mTargetProcessNames.clear();
198198
}
199199
if (args->mTargetPid != 0) {
200-
PrintWarning("warning: -captureall elides all previous -process_id arguments.\n");
200+
PrintWarning("warning: -captureall elides all previous -process_id arguments.");
201201
args->mTargetPid = 0;
202202
}
203203
}
@@ -234,7 +234,7 @@ bool ParseValue(char** argv, int argc, int* i)
234234
*i += 1;
235235
return true;
236236
}
237-
PrintError("error: %s expecting argument.\n", argv[*i]);
237+
PrintError("error: %s expecting argument.", argv[*i]);
238238
return false;
239239
}
240240

@@ -413,7 +413,7 @@ bool ParseCommandLine(int argc, char** argv)
413413

414414
// Provided argument wasn't recognized
415415
else if (!(ParseArg(argv[i], "?") || ParseArg(argv[i], "h") || ParseArg(argv[i], "help"))) {
416-
PrintError("error: unrecognized argument '%s'.\n", argv[i]);
416+
PrintError("error: unrecognized argument '%s'.", argv[i]);
417417
}
418418

419419
PrintHelp();
@@ -422,32 +422,32 @@ bool ParseCommandLine(int argc, char** argv)
422422

423423
// Handle deprecated command line arguments
424424
if (DEPRECATED_simple) {
425-
PrintWarning("warning: -simple command line argument has been deprecated; using -no_track_display instead.\n");
425+
PrintWarning("warning: -simple command line argument has been deprecated; using -no_track_display instead.");
426426
args->mTrackDisplay = false;
427427
}
428428
if (DEPRECATED_verbose) {
429-
PrintWarning("warning: -verbose command line argument has been deprecated; using -track_debug instead.\n");
429+
PrintWarning("warning: -verbose command line argument has been deprecated; using -track_debug instead.");
430430
args->mTrackDebug = true;
431431
}
432432
if (DEPRECATED_wmr) {
433-
PrintWarning("warning: -include_mixed_reality command line argument has been deprecated; using -track_mixed_reality instead.\n");
433+
PrintWarning("warning: -include_mixed_reality command line argument has been deprecated; using -track_mixed_reality instead.");
434434
args->mTrackWMR = true;
435435
}
436436
if (DEPRECATED_dontRestart) {
437-
PrintWarning("warning: -dont_restart_as_admin command line argument has been deprecated; it is now the default behaviour.\n");
437+
PrintWarning("warning: -dont_restart_as_admin command line argument has been deprecated; it is now the default behaviour.");
438438
}
439439

440440
// Ignore -no_track_display if required for other requested tracking
441441
if (args->mTrackDebug && !args->mTrackDisplay) {
442-
PrintWarning("warning: -track_debug requires display tracking; ignoring -no_track_display.\n");
442+
PrintWarning("warning: -track_debug requires display tracking; ignoring -no_track_display.");
443443
args->mTrackDisplay = true;
444444
}
445445
if (args->mTrackGPU && !args->mTrackDisplay) {
446-
PrintWarning("warning: -track_gpu requires display tracking; ignoring -no_track_display.\n");
446+
PrintWarning("warning: -track_gpu requires display tracking; ignoring -no_track_display.");
447447
args->mTrackDisplay = true;
448448
}
449449
if (args->mTrackGPUVideo && !args->mTrackDisplay) {
450-
PrintWarning("warning: -track_gpu_video requires display tracking; ignoring -no_track_display.\n");
450+
PrintWarning("warning: -track_gpu_video requires display tracking; ignoring -no_track_display.");
451451
args->mTrackDisplay = true;
452452
}
453453

@@ -459,7 +459,7 @@ bool ParseCommandLine(int argc, char** argv)
459459

460460
// -date_time is mutually exclusive to -qpc_time and -qpc_time_s
461461
if (args->mOutputDateTime && (args->mOutputQpcTime || args->mOutputQpcTimeInSeconds)) {
462-
PrintError("error: -date_time and -qpc_time or -qpc_time_s cannot be used at the same time.\n");
462+
PrintError("error: -date_time and -qpc_time or -qpc_time_s cannot be used at the same time.");
463463
PrintHelp();
464464
return false;
465465
}
@@ -469,13 +469,13 @@ bool ParseCommandLine(int argc, char** argv)
469469
if ((args->mHotkeyModifiers & MOD_CONTROL) != 0 && (
470470
args->mHotkeyVirtualKeyCode == 0x44 /*C*/ ||
471471
args->mHotkeyVirtualKeyCode == VK_SCROLL)) {
472-
PrintError("error: CTRL+C or CTRL+SCROLL cannot be used as a -hotkey, they are reserved for terminating the trace.\n");
472+
PrintError("error: CTRL+C or CTRL+SCROLL cannot be used as a -hotkey, they are reserved for terminating the trace.");
473473
PrintHelp();
474474
return false;
475475
}
476476

477477
if (args->mHotkeyModifiers == MOD_NOREPEAT && args->mHotkeyVirtualKeyCode == VK_F12) {
478-
PrintError("error: 'F12' cannot be used as a -hotkey, it is reserved for the debugger.\n");
478+
PrintError("error: 'F12' cannot be used as a -hotkey, it is reserved for the debugger.");
479479
PrintHelp();
480480
return false;
481481
}
@@ -485,24 +485,24 @@ bool ParseCommandLine(int argc, char** argv)
485485
// -output_file, or -output_stdout if they are also used.
486486
if (!args->mOutputCsvToFile) {
487487
if (args->mOutputQpcTime) {
488-
PrintWarning("warning: -qpc_time and -qpc_time_s are only relevant for CSV output; ignoring due to -no_csv.\n");
488+
PrintWarning("warning: -qpc_time and -qpc_time_s are only relevant for CSV output; ignoring due to -no_csv.");
489489
args->mOutputQpcTime = false;
490490
args->mOutputQpcTimeInSeconds = false;
491491
}
492492
if (args->mOutputDateTime) {
493-
PrintWarning("warning: -date_time is only relevant for CSV output; ignoring due to -no_csv.\n");
493+
PrintWarning("warning: -date_time is only relevant for CSV output; ignoring due to -no_csv.");
494494
args->mOutputDateTime = false;
495495
}
496496
if (args->mMultiCsv) {
497-
PrintWarning("warning: -multi_csv and -no_csv arguments are not compatible; ignoring -multi_csv.\n");
497+
PrintWarning("warning: -multi_csv and -no_csv arguments are not compatible; ignoring -multi_csv.");
498498
args->mMultiCsv = false;
499499
}
500500
if (args->mOutputCsvFileName != nullptr) {
501-
PrintWarning("warning: -output_file and -no_csv arguments are not compatible; ignoring -output_file.\n");
501+
PrintWarning("warning: -output_file and -no_csv arguments are not compatible; ignoring -output_file.");
502502
args->mOutputCsvFileName = nullptr;
503503
}
504504
if (args->mOutputCsvToStdout) {
505-
PrintWarning("warning: -output_stdout and -no_csv arguments are not compatible; ignoring -output_stdout.\n");
505+
PrintWarning("warning: -output_stdout and -no_csv arguments are not compatible; ignoring -output_stdout.");
506506
args->mOutputCsvToStdout = false;
507507
}
508508
}
@@ -517,18 +517,18 @@ bool ParseCommandLine(int argc, char** argv)
517517
args->mConsoleOutputType = ConsoleOutput::None;
518518

519519
if (args->mOutputCsvFileName != nullptr) {
520-
PrintError("error: only one of -output_file or -output_stdout arguments can be used.\n");
520+
PrintError("error: only one of -output_file or -output_stdout arguments can be used.");
521521
PrintHelp();
522522
return false;
523523
}
524524

525525
if (args->mMultiCsv) {
526-
PrintWarning("warning: -multi_csv and -output_stdout are not compatible; ignoring -multi_csv.\n");
526+
PrintWarning("warning: -multi_csv and -output_stdout are not compatible; ignoring -multi_csv.");
527527
args->mMultiCsv = false;
528528
}
529529

530530
if (args->mTrackWMR) {
531-
PrintWarning("warning: -track_mixed_reality and -output_stdout are not compatible; ignoring -track_mixed_reality.\n");
531+
PrintWarning("warning: -track_mixed_reality and -output_stdout are not compatible; ignoring -track_mixed_reality.");
532532
args->mTrackWMR = false;
533533
}
534534
}
@@ -544,15 +544,15 @@ bool ParseCommandLine(int argc, char** argv)
544544
// Try to initialize the console, and warn if we're not going to be able to
545545
// do the advanced display as requested.
546546
if (args->mConsoleOutputType == ConsoleOutput::Full && !IsConsoleInitialized()) {
547-
PrintWarning("warning: could not initialize console display; continuing with -no_top.\n");
547+
PrintWarning("warning: could not initialize console display; continuing with -no_top.");
548548
args->mConsoleOutputType = ConsoleOutput::Simple;
549549
}
550550

551551
// If -terminate_existing, warn about any normal arguments since we'll just
552552
// be stopping an existing session and then exiting.
553553
if (args->mTerminateExisting && argc != 2) {
554554
PrintWarning("warning: -terminate_existing exits without capturing anything; ignoring all capture,\n"
555-
" output, and recording arguments.\n");
555+
" output, and recording arguments.");
556556
}
557557

558558
// Convert the provided process names into a canonical form used for comparison.

PresentMon/Console.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,30 @@ int PrintWarning(char const* format, ...)
258258
va_start(val, format);
259259
int c = PrintColor(FOREGROUND_RED | FOREGROUND_GREEN, format, val);
260260
va_end(val);
261+
c += fprintf(stderr, "\n");
261262
return c;
262263
}
263264

264265
int PrintError(char const* format, ...)
266+
{
267+
va_list val;
268+
va_start(val, format);
269+
int c = PrintColor(FOREGROUND_RED, format, val);
270+
va_end(val);
271+
c += fprintf(stderr, "\n");
272+
return c;
273+
}
274+
275+
int PrintWarningNoNewLine(char const* format, ...)
276+
{
277+
va_list val;
278+
va_start(val, format);
279+
int c = PrintColor(FOREGROUND_RED | FOREGROUND_GREEN, format, val);
280+
va_end(val);
281+
return c;
282+
}
283+
284+
int PrintErrorNoNewLine(char const* format, ...)
265285
{
266286
va_list val;
267287
va_start(val, format);

PresentMon/MainThread.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static bool EnableScrollLock(bool enable)
4646

4747
auto sendCount = SendInput(2, input, sizeof(INPUT));
4848
if (sendCount != 2) {
49-
PrintWarning("warning: could not toggle scroll lock.\n");
49+
PrintWarning("warning: could not toggle scroll lock.");
5050
}
5151
}
5252

@@ -196,8 +196,8 @@ int main(int argc, char** argv)
196196
auto status = TraceSession::StopNamedSession(args.mSessionName);
197197
switch (status) {
198198
case ERROR_SUCCESS: return 0;
199-
case ERROR_WMI_INSTANCE_NOT_FOUND: PrintError("error: no existing sessions found: %s\n", args.mSessionName); break;
200-
default: PrintError("error: failed to terminate existing session (%s): %lu\n", args.mSessionName, status); break;
199+
case ERROR_WMI_INSTANCE_NOT_FOUND: PrintError("error: no existing sessions found: %s", args.mSessionName); break;
200+
default: PrintError("error: failed to terminate existing session (%s): %lu", args.mSessionName, status); break;
201201
}
202202
return 7;
203203
}
@@ -223,28 +223,28 @@ int main(int argc, char** argv)
223223
"warning: PresentMon requires elevated privilege in order to query processes that are\n"
224224
" short-running or started on another account. Without it, those processes will\n"
225225
" be listed as '<error>' and they can't be targeted by -process_name nor trigger\n"
226-
" -terminate_on_proc_exit.\n");
226+
" -terminate_on_proc_exit.");
227227
}
228228

229229
// Create a message queue to handle the input messages.
230230
WNDCLASSEXW wndClass = { sizeof(wndClass) };
231231
wndClass.lpfnWndProc = HandleWindowMessage;
232232
wndClass.lpszClassName = L"PresentMon";
233233
if (!RegisterClassExW(&wndClass)) {
234-
PrintError("error: failed to register hotkey class.\n");
234+
PrintError("error: failed to register hotkey class.");
235235
return 3;
236236
}
237237

238238
gWnd = CreateWindowExW(0, wndClass.lpszClassName, L"PresentMonWnd", 0, 0, 0, 0, 0, HWND_MESSAGE, 0, 0, nullptr);
239239
if (!gWnd) {
240-
PrintError("error: failed to create hotkey window.\n");
240+
PrintError("error: failed to create hotkey window.");
241241
UnregisterClass(wndClass.lpszClassName, NULL);
242242
return 4;
243243
}
244244

245245
// Register the hotkey.
246246
if (args.mHotkeySupport && !RegisterHotKey(gWnd, HOTKEY_ID, args.mHotkeyModifiers, args.mHotkeyVirtualKeyCode)) {
247-
PrintError("error: failed to register hotkey.\n");
247+
PrintError("error: failed to register hotkey.");
248248
DestroyWindow(gWnd);
249249
UnregisterClass(wndClass.lpszClassName, NULL);
250250
return 5;

PresentMon/OutputThread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,10 @@ void Output()
571571
ULONG buffersLost = 0;
572572
CheckLostReports(&eventsLost, &buffersLost);
573573
if (buffersLost > 0) {
574-
PrintWarning("warning: %lu ETW buffers were lost.\n", buffersLost);
574+
PrintWarning("warning: %lu ETW buffers were lost.", buffersLost);
575575
}
576576
if (eventsLost > 0) {
577-
PrintWarning("warning: %lu ETW events were lost.\n", eventsLost);
577+
PrintWarning("warning: %lu ETW events were lost.", eventsLost);
578578
}
579579

580580
// Close all CSV and process handles

PresentMon/PresentMon.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ bool InitializeConsole();
112112
bool IsConsoleInitialized();
113113
int PrintWarning(char const* format, ...);
114114
int PrintError(char const* format, ...);
115+
int PrintWarningNoNewLine(char const* format, ...);
116+
int PrintErrorNoNewLine(char const* format, ...);
115117
void ConsolePrint(char const* format, ...);
116118
void ConsolePrintLn(char const* format, ...);
117119
void CommitConsole();

PresentMon/Privilege.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,17 @@ int RestartAsAdministrator(
111111
GetExitCodeProcess(info.hProcess, &code);
112112
CloseHandle(info.hProcess);
113113
} else {
114-
PrintError("error: failed to elevate privilege ");
114+
PrintErrorNoNewLine("error: failed to elevate privilege: ");
115115
int e = GetLastError();
116116
switch (e) {
117-
case ERROR_FILE_NOT_FOUND: PrintError("(file not found).\n"); break;
118-
case ERROR_PATH_NOT_FOUND: PrintError("(path not found).\n"); break;
119-
case ERROR_DLL_NOT_FOUND: PrintError("(dll not found).\n"); break;
120-
case ERROR_ACCESS_DENIED: PrintError("(access denied).\n"); break;
121-
case ERROR_CANCELLED: PrintError("(cancelled).\n"); break;
122-
case ERROR_NOT_ENOUGH_MEMORY: PrintError("(out of memory).\n"); break;
123-
case ERROR_SHARING_VIOLATION: PrintError("(sharing violation).\n"); break;
124-
default: PrintError("(%u).\n", e); break;
117+
case ERROR_FILE_NOT_FOUND: PrintError("file not found"); break;
118+
case ERROR_PATH_NOT_FOUND: PrintError("path not found"); break;
119+
case ERROR_DLL_NOT_FOUND: PrintError("dll not found"); break;
120+
case ERROR_ACCESS_DENIED: PrintError("access denied"); break;
121+
case ERROR_CANCELLED: PrintError("cancelled"); break;
122+
case ERROR_NOT_ENOUGH_MEMORY: PrintError("out of memory"); break;
123+
case ERROR_SHARING_VIOLATION: PrintError("sharing violation"); break;
124+
default: PrintError("error code %u", e); break;
125125
}
126126
}
127127

PresentMon/TraceSession.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ bool StartTraceSession()
4444
if (args.mStopExistingSession) {
4545
PrintWarning(
4646
"warning: a trace session named \"%s\" is already running and it will be stopped.\n"
47-
" Use -session_name with a different name to start a new session.\n",
47+
" Use -session_name with a different name to start a new session.",
4848
args.mSessionName);
4949
} else {
5050
PrintError(
5151
"error: a trace session named \"%s\" is already running. Use -stop_existing_session\n"
5252
" to stop the existing session, or use -session_name with a different name to\n"
53-
" start a new session.\n",
53+
" start a new session.",
5454
args.mSessionName);
5555
delete gPMConsumer;
5656
delete gMRConsumer;
@@ -67,21 +67,20 @@ bool StartTraceSession()
6767

6868
// Report error if we failed to start a new session
6969
if (status != ERROR_SUCCESS) {
70-
PrintError("error: failed to start trace session");
70+
PrintErrorNoNewLine("error: failed to start trace session: ");
7171
switch (status) {
72-
case ERROR_FILE_NOT_FOUND: PrintError(" (file not found)"); break;
73-
case ERROR_PATH_NOT_FOUND: PrintError(" (path not found)"); break;
74-
case ERROR_BAD_PATHNAME: PrintError(" (invalid --session_name)"); break;
75-
case ERROR_ACCESS_DENIED: PrintError(" (access denied)"); break;
76-
case ERROR_FILE_CORRUPT: PrintError(" (invalid --etl_file)"); break;
77-
default: PrintError(" (error=%lu)", status); break;
72+
case ERROR_FILE_NOT_FOUND: PrintError(" file not found"); break;
73+
case ERROR_PATH_NOT_FOUND: PrintError(" path not found"); break;
74+
case ERROR_BAD_PATHNAME: PrintError(" invalid --session_name"); break;
75+
case ERROR_ACCESS_DENIED: PrintError(" access denied"); break;
76+
case ERROR_FILE_CORRUPT: PrintError(" invalid --etl_file"); break;
77+
default: PrintError(" error code %lu", status); break;
7878
}
79-
PrintError(".\n");
8079

8180
if (status == ERROR_ACCESS_DENIED && !InPerfLogUsersGroup()) {
8281
PrintError(
8382
" PresentMon requires either administrative privileges or to be run by a user in the\n"
84-
" \"Performance Log Users\" user group. View the readme for more details.\n");
83+
" \"Performance Log Users\" user group. View the readme for more details.");
8584
}
8685

8786
delete gPMConsumer;

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ There are also several other programs that build on this functionality and/or he
2424
- [Microsoft PIX on Windows System Monitor](https://devblogs.microsoft.com/pix/system-monitor/)
2525
- [NVIDIA FrameView](https://www.nvidia.com/en-us/geforce/technologies/frameview/)
2626

27-
Binaries for the main releases of PresentMon are provided on [intel.com](game.intel.com/story/intel-presentmon/) or [github.com](https://github.com/GameTechDev/PresentMon/releases/latest) ([list of all releases](https://github.com/GameTechDev/PresentMon/releases)).
27+
Binaries for the main releases of PresentMon are provided on [intel.com](https://game.intel.com/story/intel-presentmon/) or [github.com](https://github.com/GameTechDev/PresentMon/releases/latest) ([list of all releases](https://github.com/GameTechDev/PresentMon/releases)).
2828

2929
See [CONTRIBUTING.md](CONTRIBUTING.md) for information on how to request features, report issues, or contribute code changes.
3030

Tools/PresentBench.exe

2 KB
Binary file not shown.

0 commit comments

Comments
 (0)