Fix printf issue with printing pointers from 32bit kernel on 64bit system.

Change-Id: I77771b4ebe6c4335d51dc1834f0b8f9df2a069a4
This commit is contained in:
Zdunowski, Piotr
2018-04-03 16:06:37 +02:00
committed by sys_ocldev
parent 2e4a64f1e0
commit 5946a2cd15
7 changed files with 89 additions and 31 deletions

View File

@@ -749,7 +749,7 @@ TEST_F(PrintFormatterTest, GivenPrintfFormatWhenPointerThenInsertAddress) {
storeData(reinterpret_cast<void *>(&temp));
// on 32bit configurations add extra 4 bytes when storing pointers, IGC always stores pointers on 8 bytes
if (!is64bit) {
if (is32bit) {
uint32_t padding = 0;
storeData(padding);
}
@@ -764,6 +764,33 @@ TEST_F(PrintFormatterTest, GivenPrintfFormatWhenPointerThenInsertAddress) {
EXPECT_STREQ(referenceOutput, actualOutput);
}
TEST_F(PrintFormatterTest, GivenPrintfFormatWhenPointerWith32BitKernelThenPrint32BitPointer) {
auto stringIndex = injectFormatString("%p");
storeData(stringIndex);
kernelInfo->gpuPointerSize = 4;
storeData(PRINTF_DATA_TYPE::POINTER);
// store pointer
uint32_t addressValue = 0;
storeData(addressValue);
void *pointer = nullptr;
// store non zero padding
uint32_t padding = 0xdeadbeef;
storeData(padding);
char actualOutput[PrintFormatter::maxPrintfOutputLength];
char referenceOutput[PrintFormatter::maxPrintfOutputLength];
snprintf(referenceOutput, sizeof(referenceOutput), "%p", pointer);
printFormatter->printKernelOutput([&actualOutput](char *str) { strncpy_s(actualOutput, PrintFormatter::maxPrintfOutputLength, str, PrintFormatter::maxPrintfOutputLength); });
EXPECT_STREQ(referenceOutput, actualOutput);
}
TEST_F(PrintFormatterTest, GivenPrintfFormatWhen2ByteVectorsThenParseDataBufferProperly) {
int channelCount = 4;