1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
/*
* Copyright (C) 2019-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/string.h"
#include "level_zero/core/source/module/module.h"
#include <memory>
namespace L0 {
struct ModuleBuildLogImp : public ModuleBuildLog {
ModuleBuildLogImp() {}
~ModuleBuildLogImp() override {}
ze_result_t destroy() override {
delete this;
return ZE_RESULT_SUCCESS;
}
ze_result_t getString(size_t *pSize, char *pBuildLog) override {
const char *buildLog = this->buildLog.c_str();
if (buildLog != nullptr) {
auto szLog = this->buildLog.size();
if (pBuildLog) {
memcpy_s(pBuildLog, szLog, buildLog, szLog);
pBuildLog[szLog] = '\0';
}
*pSize = szLog + 1;
} else {
*pSize = 0;
}
return ZE_RESULT_SUCCESS;
}
void appendString(const char *pBuildLog, size_t size) override {
if ((pBuildLog == nullptr) || (size == 0) || (pBuildLog[0] == '\0'))
return;
if (pBuildLog[size - 1] == '\0')
--size;
if (this->buildLog.length() != 0)
this->buildLog.append("\n");
this->buildLog.append(pBuildLog, size);
}
protected:
std::string buildLog;
};
ModuleBuildLog *ModuleBuildLog::create() {
auto moduleBuildLog = new ModuleBuildLogImp();
UNRECOVERABLE_IF(moduleBuildLog == nullptr);
return moduleBuildLog;
}
} // namespace L0
|