Printf zebin: accept string type pointer

In zebin type POINTER and address of strings
are written into print buffer.
This change allows the type to be POINTER=7,
before only STRING=5 type was accepted.

Signed-off-by: Krystian Chmielewski <krystian.chmielewski@intel.com>
This commit is contained in:
Krystian Chmielewski
2022-01-26 14:18:16 +00:00
committed by Compute-Runtime-Automation
parent 6f62a784e1
commit ca5a8162eb
3 changed files with 13 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -149,7 +149,7 @@ size_t PrintFormatter::printToken(char *output, size_t size, const char *formatS
}
size_t PrintFormatter::printStringToken(char *output, size_t size, const char *formatString) {
int type = 0;
PRINTF_DATA_TYPE type = PRINTF_DATA_TYPE::INVALID;
read(&type);
const char *string = nullptr;
@@ -158,18 +158,16 @@ size_t PrintFormatter::printStringToken(char *output, size_t size, const char *f
read(&index);
string = queryPrintfString(index);
} else {
char *str = nullptr;
read(&str);
string = str;
read(&string);
}
if (type == static_cast<int>(PRINTF_DATA_TYPE::STRING)) {
return simple_sprintf(output, size, formatString, string);
} else {
switch (type) {
default:
return simple_sprintf(output, size, formatString, 0);
case PRINTF_DATA_TYPE::STRING:
case PRINTF_DATA_TYPE::POINTER:
return simple_sprintf(output, size, formatString, string);
}
return 0;
}
size_t PrintFormatter::printPointerToken(char *output, size_t size, const char *formatString) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -41,6 +41,7 @@ enum class PRINTF_DATA_TYPE : int {
VECTOR_FLOAT,
VECTOR_DOUBLE
};
static_assert(sizeof(PRINTF_DATA_TYPE) == sizeof(int));
class PrintFormatter {
public: