Skip to content

Commit 25fc9e3

Browse files
committed
minor logging improvements
1 parent ae1ea2e commit 25fc9e3

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

IntelPresentMon/Interprocess/source/metadata/EnumStatus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
X_(STATUS, INVALID_ETL_FILE, "Invalid ETL File", "", "") \
1111
X_(STATUS, DATA_LOSS, "Data Loss", "", "Data was overwritten before being read by client") \
1212
X_(STATUS, NO_DATA, "No Data", "", "No data is available") \
13-
X_(STATUS, INVALID_PID, "Invalid PID", "", "PID does not match a process being tracked") \
13+
X_(STATUS, INVALID_PID, "Invalid PID", "", "PID does not exist or does not match a process being tracked") \
1414
X_(STATUS, STREAM_ALREADY_EXISTS, "Stream Already Exists", "", "Tried to open stream for a process already being tracked") \
1515
X_(STATUS, UNABLE_TO_CREATE_NSM, "Unable to Create NSM", "", "Service failed to create shrared memory for data transfer") \
1616
X_(STATUS, INVALID_ADAPTER_ID, "Invalid Adapter ID", "", "Graphics adapter ID provided does not match any ID in service") \

IntelPresentMon/PresentMonAPIWrapperCommon/Introspection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ namespace pmapi::intro
524524
MetricView Root::FindMetric(PM_METRIC metricId) const
525525
{
526526
if (auto i = metricMap.find(metricId); i == metricMap.end()) {
527-
pmlog_error(std::format(L"Cannot find metric id={} in introspection data", (int)metricId)).diag();
527+
pmlog_error(std::format(L"Cannot find metric id={} in introspection database", (int)metricId)).diag();
528528
throw LookupException{ std::format("unable to find metric ID={}", (int)metricId) };
529529
}
530530
else {

IntelPresentMon/PresentMonMiddleware/ConcreteMiddleware.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <cstdlib>
1111
#include <Shlwapi.h>
1212
#include <numeric>
13+
#include <algorithm>
1314
#include "../PresentMonUtils/NamedPipeHelper.h"
1415
#include "../PresentMonUtils/QPCUtils.h"
1516
#include "../PresentMonAPI2/Internal.h"
@@ -36,6 +37,8 @@ namespace pmon::mid
3637
{
3738
using namespace ipc::intro;
3839
using namespace util;
40+
namespace rn = std::ranges;
41+
namespace vi = std::views;
3942

4043
static const uint32_t kMaxRespBufferSize = 4096;
4144
static const uint64_t kClientFrameDeltaQPCThreshold = 50000000;
@@ -205,6 +208,7 @@ namespace pmon::mid
205208

206209
PM_STATUS status = CallPmService(&requestBuffer, &responseBuffer);
207210
if (status != PM_STATUS::PM_STATUS_SUCCESS) {
211+
pmlog_error(L"Failed to call PmService");
208212
return status;
209213
}
210214

@@ -213,6 +217,13 @@ namespace pmon::mid
213217
status = NamedPipeHelper::DecodeStartStreamingResponse(
214218
&responseBuffer, &startStreamResponse);
215219
if (status != PM_STATUS::PM_STATUS_SUCCESS) {
220+
if (status == PM_STATUS_INVALID_PID) {
221+
pmlog_error(std::format(L"failed to begin tracking process: pid [{}] does not exist",
222+
processId)).diag();
223+
}
224+
else {
225+
pmlog_error(std::format(L"failed to begin tracking pid [{}]", processId)).diag();
226+
}
216227
return status;
217228
}
218229

@@ -232,7 +243,7 @@ namespace pmon::mid
232243
}
233244
}
234245

235-
pmlog_info(std::format(L"Streaming started for pid [{}]", processId)).diag();
246+
pmlog_info(std::format(L"Started tracking pid [{}]", processId)).diag();
236247

237248
return PM_STATUS_SUCCESS;
238249
}
@@ -386,11 +397,13 @@ namespace pmon::mid
386397
else {
387398
// Go through the cached Gpus and see which device the client
388399
// wants
389-
for (int i = 0; i < cachedGpuInfo.size(); i++) {
390-
if (qe.deviceId == cachedGpuInfo[i].deviceId) {
391-
cachedGpuInfoIndex = i;
392-
break;
393-
}
400+
if (auto i = rn::find(cachedGpuInfo, qe.deviceId, &DeviceInfo::deviceId);
401+
i != cachedGpuInfo.end()) {
402+
cachedGpuInfoIndex = uint32_t(i - cachedGpuInfo.begin());
403+
}
404+
else {
405+
pmlog_error(std::format(L"unable to find device id [{}] while building dynamic query", qe.deviceId)).diag();
406+
// TODO: shouldn't we throw here?
394407
}
395408
}
396409
}

IntelPresentMon/SampleClient/DiagnosticDemo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ void RunDiagnosticDemo(int mode)
5959
// silently fail to register dynamic query properly
6060
{
6161
PM_QUERY_ELEMENT elements[]{
62-
{ .metric = PM_METRIC_CPU_START_TIME, .stat = PM_STAT_AVG }
62+
{ .metric = PM_METRIC_CPU_START_TIME, .stat = PM_STAT_AVG },
63+
{ .metric = PM_METRIC_GPU_FREQUENCY, .stat = PM_STAT_AVG, .deviceId = 42 },
6364
};
6465
sesh.RegisterDyanamicQuery(elements);
6566
}
6667
// hard fail to register dynamic query with bogus metric id
6768
try {
6869
PM_QUERY_ELEMENT elements[]{
69-
{.metric = PM_METRIC(42069), .stat = PM_STAT_AVG}
70+
{ .metric = PM_METRIC(42069), .stat = PM_STAT_AVG }
7071
};
7172
sesh.RegisterDyanamicQuery(elements);
7273
}

IntelPresentMon/SampleClient/SampleClient.args.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
},
3737
{
3838
"Id": "78f46a64-b667-4d83-91f5-48b1332ca0c0",
39-
"Command": "--diag-demo 14436"
39+
"Command": "--diag-demo 32612"
4040
},
4141
{
4242
"Id": "edf9d064-e8f2-4c3c-8ab3-a70ae989a245",

0 commit comments

Comments
 (0)