Source Level Debugger - disable support on BDW

- suppress Gmock warning in DeviceWithSourceLevelDebugger test

Change-Id: Iab9190d3fd7a17741baf87ebe1fbc7244631653b
This commit is contained in:
Hoppe, Mateusz
2018-05-22 13:22:56 +02:00
committed by sys_ocldev
parent 467738f791
commit c104db1d5e
13 changed files with 87 additions and 30 deletions

View File

@ -362,9 +362,13 @@ void Device::initializeCaps() {
deviceInfo.preferredLocalAtomicAlignment = MemoryConstants::cacheLineSize; deviceInfo.preferredLocalAtomicAlignment = MemoryConstants::cacheLineSize;
deviceInfo.preferredPlatformAtomicAlignment = MemoryConstants::cacheLineSize; deviceInfo.preferredPlatformAtomicAlignment = MemoryConstants::cacheLineSize;
deviceInfo.sourceLevelDebuggerActive = (sourceLevelDebugger) ? sourceLevelDebugger->isDebuggerActive() : false; if (hwInfo.capabilityTable.sourceLevelDebuggerSupported) {
if (deviceInfo.sourceLevelDebuggerActive) { deviceInfo.sourceLevelDebuggerActive = (sourceLevelDebugger) ? sourceLevelDebugger->isDebuggerActive() : false;
this->preemptionMode = PreemptionMode::Disabled; if (deviceInfo.sourceLevelDebuggerActive) {
this->preemptionMode = PreemptionMode::Disabled;
}
} else {
deviceInfo.sourceLevelDebuggerActive = false;
} }
} }
} // namespace OCLRT } // namespace OCLRT

View File

@ -73,7 +73,8 @@ const RuntimeCapabilityTable BDW::capabilityTable{
false, // ftr64KBpages false, // ftr64KBpages
EngineType::ENGINE_RCS, // defaultEngineType EngineType::ENGINE_RCS, // defaultEngineType
MemoryConstants::pageSize, //requiredPreemptionSurfaceSize MemoryConstants::pageSize, //requiredPreemptionSurfaceSize
true // isCore true, // isCore
false // sourceLevelDebuggerSupported
}; };
const HardwareInfo BDW_1x2x6::hwInfo = { const HardwareInfo BDW_1x2x6::hwInfo = {

View File

@ -70,7 +70,8 @@ const RuntimeCapabilityTable BXT::capabilityTable{
false, // ftr64KBpages false, // ftr64KBpages
EngineType::ENGINE_RCS, // defaultEngineType EngineType::ENGINE_RCS, // defaultEngineType
MemoryConstants::pageSize, //requiredPreemptionSurfaceSize MemoryConstants::pageSize, //requiredPreemptionSurfaceSize
false // isCore false, // isCore
true // sourceLevelDebuggerSupported
}; };
const HardwareInfo BXT_1x2x6::hwInfo = { const HardwareInfo BXT_1x2x6::hwInfo = {

View File

@ -65,7 +65,8 @@ const RuntimeCapabilityTable CFL::capabilityTable{
true, // ftr64KBpages true, // ftr64KBpages
EngineType::ENGINE_RCS, // defaultEngineType EngineType::ENGINE_RCS, // defaultEngineType
MemoryConstants::pageSize, //requiredPreemptionSurfaceSize MemoryConstants::pageSize, //requiredPreemptionSurfaceSize
true // isCore true, // isCore
true // sourceLevelDebuggerSupported
}; };
const HardwareInfo CFL_1x2x6::hwInfo = { const HardwareInfo CFL_1x2x6::hwInfo = {

View File

@ -65,7 +65,8 @@ const RuntimeCapabilityTable GLK::capabilityTable{
false, // ftr64KBpages false, // ftr64KBpages
EngineType::ENGINE_RCS, // defaultEngineType EngineType::ENGINE_RCS, // defaultEngineType
MemoryConstants::pageSize, //requiredPreemptionSurfaceSize MemoryConstants::pageSize, //requiredPreemptionSurfaceSize
false // isCore false, // isCore
true // sourceLevelDebuggerSupported
}; };
const HardwareInfo GLK_1x3x6::hwInfo = { const HardwareInfo GLK_1x3x6::hwInfo = {

View File

@ -65,7 +65,8 @@ const RuntimeCapabilityTable KBL::capabilityTable{
true, // ftr64KBpages true, // ftr64KBpages
EngineType::ENGINE_RCS, // defaultEngineType EngineType::ENGINE_RCS, // defaultEngineType
MemoryConstants::pageSize, //requiredPreemptionSurfaceSize MemoryConstants::pageSize, //requiredPreemptionSurfaceSize
true // isCore true, // isCore
true // sourceLevelDebuggerSupported
}; };
const HardwareInfo KBL_1x2x6::hwInfo = { const HardwareInfo KBL_1x2x6::hwInfo = {

View File

@ -73,7 +73,8 @@ const RuntimeCapabilityTable SKL::capabilityTable{
true, // ftr64KBpages true, // ftr64KBpages
EngineType::ENGINE_RCS, // defaultEngineType EngineType::ENGINE_RCS, // defaultEngineType
MemoryConstants::pageSize, //requiredPreemptionSurfaceSize MemoryConstants::pageSize, //requiredPreemptionSurfaceSize
true // isCore true, // isCore
true // sourceLevelDebuggerSupported
}; };
const HardwareInfo SKL_1x2x6::hwInfo = { const HardwareInfo SKL_1x2x6::hwInfo = {

View File

@ -73,6 +73,7 @@ struct RuntimeCapabilityTable {
size_t requiredPreemptionSurfaceSize; size_t requiredPreemptionSurfaceSize;
bool isCore; bool isCore;
bool sourceLevelDebuggerSupported;
}; };
struct HardwareCapabilities { struct HardwareCapabilities {

View File

@ -29,10 +29,13 @@
#include "runtime/os_interface/32bit_memory.h" #include "runtime/os_interface/32bit_memory.h"
#include "runtime/os_interface/debug_settings_manager.h" #include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/os_interface/os_interface.h" #include "runtime/os_interface/os_interface.h"
#include "runtime/source_level_debugger/source_level_debugger.h"
#include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/hw_helper_tests.h"
#include "unit_tests/mocks/mock_builtins.h" #include "unit_tests/mocks/mock_builtins.h"
#include "unit_tests/mocks/mock_device.h"
#include "hw_cmds.h" #include "hw_cmds.h"
#include "test.h" #include "test.h"
@ -742,3 +745,24 @@ TEST(Device_GetCaps, GivenFlagEnabled64kbPagesWhenSetThenReturnCorrectValue) {
OSInterface::osEnabled64kbPages = orgOsEnabled64kbPages; OSInterface::osEnabled64kbPages = orgOsEnabled64kbPages;
hwInfo.capabilityTable.ftr64KBpages = orgftr64KBpages; hwInfo.capabilityTable.ftr64KBpages = orgftr64KBpages;
} }
TEST(Device_GetCaps, givenDeviceWithNullSourceLevelDebuggerWhenCapsAreInitializedThenSourceLevelDebuggerActiveIsSetToFalse) {
std::unique_ptr<Device> device(Device::create<OCLRT::MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo();
EXPECT_EQ(nullptr, device->getSourceLevelDebugger());
EXPECT_FALSE(caps.sourceLevelDebuggerActive);
}
typedef HwHelperTest DeviceCapsWithModifiedHwInfoTest;
TEST_F(DeviceCapsWithModifiedHwInfoTest, givenPlatformWithSourceLevelDebuggerNotSupportedWhenDeviceIsCreatedThenSourceLevelDebuggerActiveIsSetToFalse) {
hwInfo.capabilityTable.sourceLevelDebuggerSupported = false;
std::unique_ptr<MockDeviceWithSourceLevelDebugger<>> device(Device::create<MockDeviceWithSourceLevelDebugger<>>(&hwInfo));
const auto &caps = device->getDeviceInfo();
EXPECT_NE(nullptr, device->getSourceLevelDebugger());
EXPECT_FALSE(caps.sourceLevelDebuggerActive);
}

View File

@ -21,6 +21,8 @@
*/ */
#include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/mocks/mock_device.h"
#include "unit_tests/mocks/mock_source_level_debugger.h"
#include "test.h" #include "test.h"
using namespace OCLRT; using namespace OCLRT;
@ -39,3 +41,10 @@ BDWTEST_F(Gen8DeviceTest, givenGen8DeviceWhenAskedForClVersionThenReport21) {
auto version = pDevice->getSupportedClVersion(); auto version = pDevice->getSupportedClVersion();
EXPECT_EQ(21u, version); EXPECT_EQ(21u, version);
} }
BDWTEST_F(Gen8DeviceTest, givenSourceLevelDebuggerAvailableWhenDeviceIsCreatedThenSourceLevelDebuggerIsDisabled) {
auto device = std::unique_ptr<MockDeviceWithSourceLevelDebugger<MockActiveSourceLevelDebugger>>(Device::create<MockDeviceWithSourceLevelDebugger<MockActiveSourceLevelDebugger>>(nullptr));
const auto &caps = device->getDeviceInfo();
EXPECT_NE(nullptr, device->getSourceLevelDebugger());
EXPECT_FALSE(caps.sourceLevelDebuggerActive);
}

View File

@ -216,4 +216,13 @@ class MockAlignedMallocManagerDevice : public MockDevice {
MockAlignedMallocManagerDevice(const HardwareInfo &hwInfo, bool isRootDevice = true); MockAlignedMallocManagerDevice(const HardwareInfo &hwInfo, bool isRootDevice = true);
}; };
template <typename T = SourceLevelDebugger>
class MockDeviceWithSourceLevelDebugger : public MockDevice {
public:
MockDeviceWithSourceLevelDebugger(const HardwareInfo &hwInfo, bool isRootDevice = true) : MockDevice(hwInfo, isRootDevice) {
T *sourceLevelDebuggerCreated = new T(nullptr);
sourceLevelDebugger.reset(sourceLevelDebuggerCreated);
}
};
} // namespace OCLRT } // namespace OCLRT

View File

@ -107,7 +107,7 @@ TEST(DeviceCreation, givenDeviceWithDisabledPreemptionAndDebuggingActiveWhenDevi
} }
TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsDestructedThenSourceLevelDebuggerIsNotified) { TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsDestructedThenSourceLevelDebuggerIsNotified) {
auto device = std::unique_ptr<MockDeviceWithActiveDebugger<GMockSourceLevelDebugger>>(Device::create<MockDeviceWithActiveDebugger<GMockSourceLevelDebugger>>(nullptr)); auto device = std::unique_ptr<MockDeviceWithActiveDebugger<::testing::NiceMock<GMockSourceLevelDebugger>>>(Device::create<MockDeviceWithActiveDebugger<::testing::NiceMock<GMockSourceLevelDebugger>>>(nullptr));
GMockSourceLevelDebugger *gmock = device->getSourceLevelDebugger(); GMockSourceLevelDebugger *gmock = device->getSourceLevelDebugger();
EXPECT_CALL(*gmock, notifyDeviceDestruction()).Times(1); EXPECT_CALL(*gmock, notifyDeviceDestruction()).Times(1);
} }

View File

@ -403,35 +403,39 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceIsConstructe
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreatedThenDebuggerIsNotified) { TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreatedThenDebuggerIsNotified) {
DebuggerLibraryRestorer restorer; DebuggerLibraryRestorer restorer;
DebuggerLibraryInterceptor interceptor; if (platformDevices[0]->capabilityTable.sourceLevelDebuggerSupported) {
DebuggerLibrary::setLibraryAvailable(true); DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setDebuggerActive(true); DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor); DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
unique_ptr<MockDevice> device(new MockDevice(*platformDevices[0])); unique_ptr<MockDevice> device(new MockDevice(*platformDevices[0]));
MockDevice::createDeviceImpl(platformDevices[0], true, *device.get()); MockDevice::createDeviceImpl(platformDevices[0], true, *device.get());
EXPECT_TRUE(interceptor.newDeviceCalled); EXPECT_TRUE(interceptor.newDeviceCalled);
uint32_t deviceHandleExpected = device->getCommandStreamReceiver().getOSInterface() != nullptr ? device->getCommandStreamReceiver().getOSInterface()->getDeviceHandle() : 0; uint32_t deviceHandleExpected = device->getCommandStreamReceiver().getOSInterface() != nullptr ? device->getCommandStreamReceiver().getOSInterface()->getDeviceHandle() : 0;
EXPECT_EQ(reinterpret_cast<GfxDeviceHandle>(static_cast<uint64_t>(deviceHandleExpected)), interceptor.newDeviceArgIn.dh); EXPECT_EQ(reinterpret_cast<GfxDeviceHandle>(static_cast<uint64_t>(deviceHandleExpected)), interceptor.newDeviceArgIn.dh);
}
} }
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreatedWithOsCsrThenDebuggerIsNotifiedWithCorrectDeviceHandle) { TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreatedWithOsCsrThenDebuggerIsNotifiedWithCorrectDeviceHandle) {
DebuggerLibraryRestorer restorer; DebuggerLibraryRestorer restorer;
DebuggerLibraryInterceptor interceptor; if (platformDevices[0]->capabilityTable.sourceLevelDebuggerSupported) {
DebuggerLibrary::setLibraryAvailable(true); DebuggerLibraryInterceptor interceptor;
DebuggerLibrary::setDebuggerActive(true); DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor); DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
overrideCommandStreamReceiverCreation = true; overrideCommandStreamReceiverCreation = true;
// Device::create must be used to create correct OS memory manager // Device::create must be used to create correct OS memory manager
unique_ptr<Device> device(Device::create<Device>(platformDevices[0])); unique_ptr<Device> device(Device::create<Device>(platformDevices[0]));
ASSERT_NE(nullptr, device->getCommandStreamReceiver().getOSInterface()); ASSERT_NE(nullptr, device->getCommandStreamReceiver().getOSInterface());
EXPECT_TRUE(interceptor.newDeviceCalled); EXPECT_TRUE(interceptor.newDeviceCalled);
uint32_t deviceHandleExpected = device->getCommandStreamReceiver().getOSInterface()->getDeviceHandle(); uint32_t deviceHandleExpected = device->getCommandStreamReceiver().getOSInterface()->getDeviceHandle();
EXPECT_EQ(reinterpret_cast<GfxDeviceHandle>(static_cast<uint64_t>(deviceHandleExpected)), interceptor.newDeviceArgIn.dh); EXPECT_EQ(reinterpret_cast<GfxDeviceHandle>(static_cast<uint64_t>(deviceHandleExpected)), interceptor.newDeviceArgIn.dh);
}
} }
TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenDeviceIsCreatedThenDebuggerIsNotCreatedInitializedAndNotNotified) { TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenDeviceIsCreatedThenDebuggerIsNotCreatedInitializedAndNotNotified) {