mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 21:27:04 +08:00
Fix Source Level Debugger scenario
- when Program is compiled and linked, kernel debug options must be added when linking - when linking by CompilerInterface, store debugData in Program Change-Id: Ie93a8fa7586681b94307a30c109c103f78ec861a
This commit is contained in:
committed by
sys_ocldev
parent
a39660de92
commit
3d35bf4291
@@ -260,6 +260,10 @@ cl_int CompilerInterface::link(
|
||||
|
||||
program.storeGenBinary(currOut->GetOutput()->GetMemory<char>(), currOut->GetOutput()->GetSizeRaw());
|
||||
program.updateBuildLog(&device, currOut->GetBuildLog()->GetMemory<char>(), currOut->GetBuildLog()->GetSizeRaw());
|
||||
|
||||
if (currOut->GetDebugData()->GetSizeRaw() != 0) {
|
||||
program.storeDebugData(currOut->GetDebugData()->GetMemory<char>(), currOut->GetDebugData()->GetSizeRaw());
|
||||
}
|
||||
}
|
||||
|
||||
return CL_SUCCESS;
|
||||
|
||||
@@ -65,24 +65,19 @@ cl_int Program::build(
|
||||
}
|
||||
|
||||
TranslationArgs inputArgs = {};
|
||||
|
||||
if (strcmp(sourceCode.c_str(), "") == 0) {
|
||||
retVal = CL_INVALID_PROGRAM;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isKernelDebugEnabled()) {
|
||||
internalOptions.append(CompilerOptions::debugKernelEnable);
|
||||
options.append(" -g ");
|
||||
if (pDevice->getSourceLevelDebugger()) {
|
||||
if (pDevice->getSourceLevelDebugger()->isOptimizationDisabled()) {
|
||||
options.append("-cl-opt-disable ");
|
||||
}
|
||||
std::string filename;
|
||||
pDevice->getSourceLevelDebugger()->notifySourceCode(sourceCode.c_str(), sourceCode.size(), filename);
|
||||
if (!filename.empty()) {
|
||||
// Add "-s" flag first so it will be ignored by clang in case the options already have this flag set.
|
||||
options = std::string("-s ") + filename + " " + options;
|
||||
}
|
||||
std::string filename;
|
||||
appendKernelDebugOptions();
|
||||
notifyDebuggerWithSourceCode(filename);
|
||||
if (!filename.empty()) {
|
||||
// Add "-s" flag first so it will be ignored by clang in case the options already have this flag set.
|
||||
options = std::string("-s ") + filename + " " + options;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +138,23 @@ cl_int Program::build(
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool Program::appendKernelDebugOptions() {
|
||||
internalOptions.append(CompilerOptions::debugKernelEnable);
|
||||
options.append(" -g ");
|
||||
if (pDevice->getSourceLevelDebugger()) {
|
||||
if (pDevice->getSourceLevelDebugger()->isOptimizationDisabled()) {
|
||||
options.append("-cl-opt-disable ");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Program::notifyDebuggerWithSourceCode(std::string &filename) {
|
||||
if (pDevice->getSourceLevelDebugger()) {
|
||||
pDevice->getSourceLevelDebugger()->notifySourceCode(sourceCode.c_str(), sourceCode.size(), filename);
|
||||
}
|
||||
}
|
||||
|
||||
cl_int Program::build(const cl_device_id device, const char *buildOptions, bool enableCaching,
|
||||
std::unordered_map<std::string, BuiltinDispatchInfoBuilder *> &builtinsMap) {
|
||||
auto ret = this->build(1, &device, buildOptions, nullptr, nullptr, enableCaching);
|
||||
|
||||
@@ -131,17 +131,11 @@ cl_int Program::compile(
|
||||
internalOptions.append(platform()->peekCompilerExtensions());
|
||||
|
||||
if (isKernelDebugEnabled()) {
|
||||
internalOptions.append(CompilerOptions::debugKernelEnable);
|
||||
options.append(" -g ");
|
||||
if (pDevice->getSourceLevelDebugger()) {
|
||||
if (pDevice->getSourceLevelDebugger()->isOptimizationDisabled()) {
|
||||
options.append("-cl-opt-disable ");
|
||||
}
|
||||
std::string filename;
|
||||
pDevice->getSourceLevelDebugger()->notifySourceCode(sourceCode.c_str(), sourceCode.size(), filename);
|
||||
if (!filename.empty()) {
|
||||
options = std::string("-s ") + filename + " " + options;
|
||||
}
|
||||
std::string filename;
|
||||
appendKernelDebugOptions();
|
||||
notifyDebuggerWithSourceCode(filename);
|
||||
if (!filename.empty()) {
|
||||
options = std::string("-s ") + filename + " " + options;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include "runtime/source_level_debugger/source_level_debugger.h"
|
||||
#include "program.h"
|
||||
#include "elf/writer.h"
|
||||
|
||||
#include "runtime/compiler_interface/compiler_options.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace OCLRT {
|
||||
@@ -59,6 +62,10 @@ cl_int Program::link(
|
||||
|
||||
options = (buildOptions != nullptr) ? buildOptions : "";
|
||||
|
||||
if (isKernelDebugEnabled()) {
|
||||
appendKernelDebugOptions();
|
||||
}
|
||||
|
||||
isCreateLibrary = (strstr(options.c_str(), "-create-library") != nullptr);
|
||||
|
||||
buildStatus = CL_BUILD_IN_PROGRESS;
|
||||
|
||||
@@ -267,6 +267,9 @@ class Program : public BaseObject<_cl_program> {
|
||||
|
||||
void extractInternalOptions(std::string &options);
|
||||
|
||||
MOCKABLE_VIRTUAL bool appendKernelDebugOptions();
|
||||
void notifyDebuggerWithSourceCode(std::string &filename);
|
||||
|
||||
static const std::string clOptNameClVer;
|
||||
static const std::string clOptNameUniformWgs;
|
||||
// clang-format off
|
||||
|
||||
Reference in New Issue
Block a user