feature: Add capability to print debug messages with pid and timestamp

Controlled with the knob DebugMessagesBitmask (1 - pid, 2 - timestamp)

Related-To: NEO-12952

Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
Slawomir Milczarek
2025-06-21 18:05:09 +00:00
committed by Compute-Runtime-Automation
parent 59cb5098e7
commit 2720f2316c
8 changed files with 70 additions and 21 deletions

View File

@@ -83,6 +83,7 @@ WddmPagingFenceCpuWaitDelayTime = 0
PrintL0SetKernelArg = 0
UsePipeControlMultiKernelEventSync = -1
PrintDebugMessages = 0
DebugMessagesBitmask = 0
DumpZEBin = 0
DumpKernels = 0
DumpKernelArgs = 0

View File

@@ -6,6 +6,8 @@
*/
#include "shared/source/helpers/api_specific_config.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/gtest_helpers.h"
#include "shared/test/common/helpers/stream_capture.h"
#include "shared/test/common/mocks/mock_settings_reader.h"
#include "shared/test/common/test_macros/test.h"
@@ -101,4 +103,29 @@ TEST(SettingsReader, GivenFalseWhenPrintingDebugStringThenNoOutput) {
std::string output = capture.getCapturedStdout();
EXPECT_STREQ(output.c_str(), "");
}
TEST(SettingsReader, GivenDebugMessagesBitmaskWithPidWhenPrintingDebugStringThenPrintsPidToOutput) {
DebugManagerStateRestore restorer;
NEO::debugManager.flags.DebugMessagesBitmask.set(DebugMessagesBitmask::withPid);
int i = 4;
StreamCapture capture;
capture.captureStdout();
PRINT_DEBUG_STRING(true, stdout, "debug string %d", i);
std::string output = capture.getCapturedStdout();
EXPECT_TRUE(hasSubstr(output, "[PID: "));
}
TEST(SettingsReader, GivenDebugMessagesBitmaskWithTimestampWhenPrintingDebugStringThenPrintsTimestampToOutput) {
DebugManagerStateRestore restorer;
NEO::debugManager.flags.DebugMessagesBitmask.set(DebugMessagesBitmask::withTimestamp);
int i = 4;
StreamCapture capture;
capture.captureStdout();
PRINT_DEBUG_STRING(true, stdout, "debug string %d", i);
std::string output = capture.getCapturedStdout();
std::string dateRegex = R"(\[20\d{2}-\d{2}-\d{2})";
EXPECT_TRUE(containsRegex(output, dateRegex));
}
} // namespace SettingsReaderTests