Check SourceLevelDebugger is non-nullptr before use
Change-Id: I0c270158e743ee8d301903d4ad3b6b9815a758b8 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
parent
29821b5a25
commit
da3c9dba0e
|
@ -52,7 +52,7 @@ ClDevice::ClDevice(Device &device, Platform *platform) : device(device), platfor
|
|||
subDevices.push_back(std::move(pClSubDevice));
|
||||
}
|
||||
}
|
||||
if (getSharedDeviceInfo().debuggerActive) {
|
||||
if (getSharedDeviceInfo().debuggerActive && getSourceLevelDebugger()) {
|
||||
auto osInterface = device.getRootDeviceEnvironment().osInterface.get();
|
||||
getSourceLevelDebugger()->notifyNewDevice(osInterface ? osInterface->getDeviceHandle() : 0);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ ClDevice::ClDevice(Device &device, Platform *platform) : device(device), platfor
|
|||
|
||||
ClDevice::~ClDevice() {
|
||||
|
||||
if (getSharedDeviceInfo().debuggerActive) {
|
||||
if (getSharedDeviceInfo().debuggerActive && getSourceLevelDebugger()) {
|
||||
getSourceLevelDebugger()->notifyDeviceDestruction();
|
||||
}
|
||||
|
||||
|
|
|
@ -87,4 +87,13 @@ class MockClDevice : public ClDevice {
|
|||
std::vector<EngineControl> &engines;
|
||||
};
|
||||
|
||||
class MockDeviceWithDebuggerActive : public MockDevice {
|
||||
public:
|
||||
MockDeviceWithDebuggerActive(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex) : MockDevice(executionEnvironment, deviceIndex) {}
|
||||
void initializeCaps() override {
|
||||
MockDevice::initializeCaps();
|
||||
this->setDebuggerActive(true);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
|
|
@ -18,15 +18,6 @@
|
|||
using PreambleTest = ::testing::Test;
|
||||
using namespace NEO;
|
||||
|
||||
class MockDeviceWithDebuggerActive : public MockDevice {
|
||||
public:
|
||||
MockDeviceWithDebuggerActive(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex) : MockDevice(executionEnvironment, deviceIndex) {}
|
||||
void initializeCaps() override {
|
||||
MockDevice::initializeCaps();
|
||||
this->setDebuggerActive(true);
|
||||
}
|
||||
};
|
||||
|
||||
TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsDestructedThenSourceLevelDebuggerIsNotified) {
|
||||
ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment();
|
||||
auto gmock = new ::testing::NiceMock<GMockSourceLevelDebugger>(new MockOsLibrary);
|
||||
|
|
|
@ -542,6 +542,22 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenGettingSourceLe
|
|||
EXPECT_EQ(nullptr, device->getSourceLevelDebugger());
|
||||
}
|
||||
|
||||
TEST(SourceLevelDebugger, givenDeviceWithDebuggerActiveSetWhenSourceLevelDebuggerIsNotCreatedThenNotificationsAreNotCalled) {
|
||||
DebuggerLibraryRestorer restorer;
|
||||
|
||||
DebuggerLibraryInterceptor interceptor;
|
||||
DebuggerLibrary::setLibraryAvailable(false);
|
||||
DebuggerLibrary::setDebuggerActive(false);
|
||||
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
|
||||
|
||||
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDeviceWithDebuggerActive>(nullptr));
|
||||
|
||||
EXPECT_TRUE(device->isDebuggerActive());
|
||||
EXPECT_EQ(nullptr, device->getDebugger());
|
||||
EXPECT_FALSE(interceptor.newDeviceCalled);
|
||||
EXPECT_FALSE(interceptor.deviceDestructionCalled);
|
||||
}
|
||||
|
||||
TEST(SourceLevelDebugger, givenTwoRootDevicesWhenSecondIsCreatedThenCreatingNewSourceLevelDebugger) {
|
||||
DebuggerLibraryRestorer restorer;
|
||||
|
||||
|
|
Loading…
Reference in New Issue