diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 2810fc39ef..c6509550fe 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -57,6 +57,7 @@ set(CORE_SOURCES ${CORE_SRCS_GENX_ALL_BASE}) append_sources_from_properties(CORE_SOURCES NEO_CORE_COMMAND_CONTAINER NEO_CORE_DEBUG_SETTINGS + NEO_CORE_DEBUGGER NEO_CORE_EXECUTION_ENVIRONMENT NEO_CORE_HELPERS NEO_CORE_INDIRECT_HEAP diff --git a/core/command_stream/preemption.inl b/core/command_stream/preemption.inl index 34833bdbc3..1814194514 100644 --- a/core/command_stream/preemption.inl +++ b/core/command_stream/preemption.inl @@ -30,10 +30,10 @@ void PreemptionHelper::programCsrBaseAddress(LinearStream &preambleCmdStream, De template void PreemptionHelper::programStateSip(LinearStream &preambleCmdStream, Device &device) { using STATE_SIP = typename GfxFamily::STATE_SIP; - bool sourceLevelDebuggerActive = device.isSourceLevelDebuggerActive(); + bool debuggerActive = device.isDebuggerActive(); bool isMidThreadPreemption = device.getPreemptionMode() == PreemptionMode::MidThread; - if (isMidThreadPreemption || sourceLevelDebuggerActive) { + if (isMidThreadPreemption || debuggerActive) { auto sip = reinterpret_cast(preambleCmdStream.getSpace(sizeof(STATE_SIP))); *sip = GfxFamily::cmdInitStateSip; auto sipAllocation = SipKernel::getSipKernelAllocation(device); @@ -81,7 +81,7 @@ size_t PreemptionHelper::getRequiredStateSipCmdSize(const Device &device) { size_t size = 0; bool isMidThreadPreemption = device.getPreemptionMode() == PreemptionMode::MidThread; - if (isMidThreadPreemption || device.isSourceLevelDebuggerActive()) { + if (isMidThreadPreemption || device.isDebuggerActive()) { size += sizeof(typename GfxFamily::STATE_SIP); } return size; diff --git a/core/debugger/CMakeLists.txt b/core/debugger/CMakeLists.txt new file mode 100644 index 0000000000..32545a7895 --- /dev/null +++ b/core/debugger/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright (C) 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +set(NEO_CORE_DEBUGGER + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/debugger.h + +) + +set_property(GLOBAL PROPERTY NEO_CORE_DEBUGGER ${NEO_CORE_DEBUGGER}) diff --git a/core/debugger/debugger.h b/core/debugger/debugger.h new file mode 100644 index 0000000000..3cafe1972d --- /dev/null +++ b/core/debugger/debugger.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include +namespace NEO { +struct HardwareInfo; +class Debugger { + public: + static std::unique_ptr create(HardwareInfo *hwInfo); + virtual ~Debugger() = default; + virtual bool isDebuggerActive() = 0; +}; +} // namespace NEO \ No newline at end of file diff --git a/core/device/device.cpp b/core/device/device.cpp index f23b48d28e..279b332105 100644 --- a/core/device/device.cpp +++ b/core/device/device.cpp @@ -32,8 +32,8 @@ Device::Device(ExecutionEnvironment *executionEnvironment) auto &hwInfo = getHardwareInfo(); preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfo); - if (!getSourceLevelDebugger()) { - this->executionEnvironment->initSourceLevelDebugger(); + if (!getDebugger()) { + this->executionEnvironment->initDebugger(); } this->executionEnvironment->incRefInternal(); auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); @@ -50,9 +50,6 @@ Device::~Device() { engine.commandStreamReceiver->flushBatchedSubmissions(); } - if (deviceInfo.sourceLevelDebuggerActive && executionEnvironment->sourceLevelDebugger) { - executionEnvironment->sourceLevelDebugger->notifyDeviceDestruction(); - } commandStreamReceivers.clear(); executionEnvironment->memoryManager->waitForDeletions(); executionEnvironment->decRefInternal(); @@ -82,15 +79,6 @@ bool Device::createDeviceImpl() { } } - uint32_t deviceHandle = 0; - if (osInterface) { - deviceHandle = osInterface->getDeviceHandle(); - } - - if (deviceInfo.sourceLevelDebuggerActive) { - executionEnvironment->sourceLevelDebugger->notifyNewDevice(deviceHandle); - } - executionEnvironment->memoryManager->setForce32BitAllocations(getDeviceInfo().force32BitAddressess); if (DebugManager.flags.EnableExperimentalCommandBuffer.get() > 0) { @@ -149,7 +137,7 @@ bool Device::createEngine(uint32_t deviceCsrIndex, aub_stream::EngineType engine defaultEngineIndex = deviceCsrIndex; } - if ((preemptionMode == PreemptionMode::MidThread || isSourceLevelDebuggerActive()) && !commandStreamReceiver->createPreemptionAllocation()) { + if ((preemptionMode == PreemptionMode::MidThread || isDebuggerActive()) && !commandStreamReceiver->createPreemptionAllocation()) { return false; } @@ -201,8 +189,8 @@ GFXCORE_FAMILY Device::getRenderCoreFamily() const { return this->getHardwareInfo().platform.eRenderCoreFamily; } -bool Device::isSourceLevelDebuggerActive() const { - return deviceInfo.sourceLevelDebuggerActive; +bool Device::isDebuggerActive() const { + return deviceInfo.debuggerActive; } EngineControl &Device::getEngine(aub_stream::EngineType engineType, bool lowPriority) { diff --git a/core/device/device.h b/core/device/device.h index 5be2562463..4f3f7720d8 100644 --- a/core/device/device.h +++ b/core/device/device.h @@ -51,8 +51,8 @@ class Device : public ReferenceTrackedObject { GFXCORE_FAMILY getRenderCoreFamily() const; PerformanceCounters *getPerformanceCounters() { return performanceCounters.get(); } PreemptionMode getPreemptionMode() const { return preemptionMode; } - MOCKABLE_VIRTUAL bool isSourceLevelDebuggerActive() const; - SourceLevelDebugger *getSourceLevelDebugger() { return executionEnvironment->sourceLevelDebugger.get(); } + MOCKABLE_VIRTUAL bool isDebuggerActive() const; + Debugger *getDebugger() { return executionEnvironment->debugger.get(); } ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; } const RootDeviceEnvironment &getRootDeviceEnvironment() const { return *executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]; } const HardwareCapabilities &getHardwareCapabilities() const { return hardwareCapabilities; } diff --git a/core/execution_environment/execution_environment.cpp b/core/execution_environment/execution_environment.cpp index e4de7cb7ef..370ac09edc 100644 --- a/core/execution_environment/execution_environment.cpp +++ b/core/execution_environment/execution_environment.cpp @@ -9,12 +9,12 @@ #include "core/compiler_interface/compiler_interface.h" #include "core/compiler_interface/default_cache_config.h" +#include "core/debugger/debugger.h" #include "core/execution_environment/root_device_environment.h" #include "core/gmm_helper/gmm_helper.h" #include "core/helpers/hw_helper.h" #include "runtime/built_ins/built_ins.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h" -#include "runtime/source_level_debugger/source_level_debugger.h" namespace NEO { ExecutionEnvironment::ExecutionEnvironment() { @@ -22,7 +22,7 @@ ExecutionEnvironment::ExecutionEnvironment() { }; ExecutionEnvironment::~ExecutionEnvironment() { - sourceLevelDebugger.reset(); + debugger.reset(); compilerInterface.reset(); builtins.reset(); rootDeviceEnvironments.clear(); @@ -63,14 +63,8 @@ void ExecutionEnvironment::initializeMemoryManager() { DEBUG_BREAK_IF(!this->memoryManager); } -void ExecutionEnvironment::initSourceLevelDebugger() { - if (hwInfo->capabilityTable.sourceLevelDebuggerSupported) { - sourceLevelDebugger.reset(SourceLevelDebugger::create()); - } - if (sourceLevelDebugger) { - bool localMemorySipAvailable = (SipKernelType::DbgCsrLocal == SipKernel::getSipKernelType(hwInfo->platform.eRenderCoreFamily, true)); - sourceLevelDebugger->initialize(localMemorySipAvailable); - } +void ExecutionEnvironment::initDebugger() { + debugger = Debugger::create(hwInfo.get()); } void ExecutionEnvironment::calculateMaxOsContextCount() { diff --git a/core/execution_environment/execution_environment.h b/core/execution_environment/execution_environment.h index 1c9be7d05a..b4e4b289ab 100644 --- a/core/execution_environment/execution_environment.h +++ b/core/execution_environment/execution_environment.h @@ -18,7 +18,7 @@ class CompilerInterface; class GmmClientContext; class GmmHelper; class MemoryManager; -class SourceLevelDebugger; +class Debugger; struct RootDeviceEnvironment; struct HardwareInfo; @@ -37,7 +37,7 @@ class ExecutionEnvironment : public ReferenceTrackedObject void initGmm(); void initializeMemoryManager(); - void initSourceLevelDebugger(); + void initDebugger(); void calculateMaxOsContextCount(); void setHwInfo(const HardwareInfo *hwInfo); const HardwareInfo *getHardwareInfo() const { return hwInfo.get(); } @@ -54,6 +54,6 @@ class ExecutionEnvironment : public ReferenceTrackedObject std::vector> rootDeviceEnvironments; std::unique_ptr builtins; std::unique_ptr compilerInterface; - std::unique_ptr sourceLevelDebugger; + std::unique_ptr debugger; }; } // namespace NEO diff --git a/core/gen11/preamble_gen11.cpp b/core/gen11/preamble_gen11.cpp index d511cd326e..616c4fbf99 100644 --- a/core/gen11/preamble_gen11.cpp +++ b/core/gen11/preamble_gen11.cpp @@ -87,7 +87,7 @@ size_t PreambleHelper::getThreadArbitrationCommandsSize() { template <> size_t PreambleHelper::getAdditionalCommandsSize(const Device &device) { size_t totalSize = PreemptionHelper::getRequiredPreambleSize(device); - totalSize += getKernelDebuggingCommandsSize(device.isSourceLevelDebuggerActive()); + totalSize += getKernelDebuggingCommandsSize(device.isDebuggerActive()); return totalSize; } diff --git a/core/gen8/preamble_gen8.cpp b/core/gen8/preamble_gen8.cpp index b40d0467de..bfb7320ca3 100644 --- a/core/gen8/preamble_gen8.cpp +++ b/core/gen8/preamble_gen8.cpp @@ -50,7 +50,7 @@ void PreambleHelper::programPipelineSelect(LinearStream *pCommandStre template <> size_t PreambleHelper::getAdditionalCommandsSize(const Device &device) { - return getKernelDebuggingCommandsSize(device.isSourceLevelDebuggerActive()); + return getKernelDebuggingCommandsSize(device.isDebuggerActive()); } template struct PreambleHelper; diff --git a/core/helpers/hw_info.h b/core/helpers/hw_info.h index d68b9adcac..212a4f8586 100644 --- a/core/helpers/hw_info.h +++ b/core/helpers/hw_info.h @@ -47,7 +47,7 @@ struct RuntimeCapabilityTable { bool instrumentationEnabled; bool forceStatelessCompilationFor32Bit; const char *platformType; - bool sourceLevelDebuggerSupported; + bool debuggerSupported; bool supportsVme; bool supportCacheFlushAfterWalker; bool supportsImages; diff --git a/core/helpers/preamble_base.inl b/core/helpers/preamble_base.inl index e4d291676e..684297bb0d 100644 --- a/core/helpers/preamble_base.inl +++ b/core/helpers/preamble_base.inl @@ -50,7 +50,7 @@ size_t PreambleHelper::getPerDssBackedBufferCommandsSize(const Hardwa template size_t PreambleHelper::getAdditionalCommandsSize(const Device &device) { size_t totalSize = PreemptionHelper::getRequiredPreambleSize(device); - totalSize += getKernelDebuggingCommandsSize(device.isSourceLevelDebuggerActive()); + totalSize += getKernelDebuggingCommandsSize(device.isDebuggerActive()); return totalSize; } @@ -71,7 +71,7 @@ void PreambleHelper::programPreamble(LinearStream *pCommandStream, De programL3(pCommandStream, l3Config); programThreadArbitration(pCommandStream, requiredThreadArbitrationPolicy); programPreemption(pCommandStream, device, preemptionCsr); - if (device.isSourceLevelDebuggerActive()) { + if (device.isDebuggerActive()) { programKernelDebugging(pCommandStream); } programGenSpecificPreambleWorkArounds(pCommandStream, device.getHardwareInfo()); diff --git a/core/unit_tests/gen9/test_preemption_gen9.cpp b/core/unit_tests/gen9/test_preemption_gen9.cpp index 98add0b597..f4ce4cc993 100644 --- a/core/unit_tests/gen9/test_preemption_gen9.cpp +++ b/core/unit_tests/gen9/test_preemption_gen9.cpp @@ -529,6 +529,6 @@ GEN9TEST_F(Gen9PreemptionTests, givenMidThreadPreemptionModeWhenStateSipIsProgra auto cmd = hwParserOnlyPreemption.getCommand(); EXPECT_NE(nullptr, cmd); - auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isSourceLevelDebuggerActive()); + auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isDebuggerActive()); EXPECT_EQ(mockDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), cmd->getSystemInstructionPointer()); } diff --git a/core/unit_tests/helpers/memory_management.h b/core/unit_tests/helpers/memory_management.h index 25b6db1a06..33f5b983c0 100644 --- a/core/unit_tests/helpers/memory_management.h +++ b/core/unit_tests/helpers/memory_management.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2019 Intel Corporation + * Copyright (C) 2017-2020 Intel Corporation * * SPDX-License-Identifier: MIT * diff --git a/core/unit_tests/preamble/preamble_tests.cpp b/core/unit_tests/preamble/preamble_tests.cpp index 6d9f7acd5b..39c2aa8f20 100644 --- a/core/unit_tests/preamble/preamble_tests.cpp +++ b/core/unit_tests/preamble/preamble_tests.cpp @@ -136,7 +136,7 @@ HWTEST_F(PreambleTest, givenKernelDebuggingActiveWhenPreambleIsProgrammedThenPro auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setPreemptionMode(PreemptionMode::Disabled); - mockDevice->setSourceLevelDebuggerActive(false); + mockDevice->setDebuggerActive(false); StackVec preambleBuffer(8192); LinearStream preambleStream(&*preambleBuffer.begin(), preambleBuffer.size()); @@ -150,7 +150,7 @@ HWTEST_F(PreambleTest, givenKernelDebuggingActiveWhenPreambleIsProgrammedThenPro auto miLoadRegImmCountWithoutDebugging = cmdList.size(); - mockDevice->setSourceLevelDebuggerActive(true); + mockDevice->setDebuggerActive(true); auto preemptionAllocation = mockDevice->getGpgpuCommandStreamReceiver().getPreemptionAllocation(); StackVec preambleBuffer2(8192); @@ -170,9 +170,9 @@ HWTEST_F(PreambleTest, givenKernelDebuggingActiveAndMidThreadPreemptionWhenGetAd auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setPreemptionMode(PreemptionMode::MidThread); - mockDevice->setSourceLevelDebuggerActive(false); + mockDevice->setDebuggerActive(false); size_t withoutDebugging = PreambleHelper::getAdditionalCommandsSize(*mockDevice); - mockDevice->setSourceLevelDebuggerActive(true); + mockDevice->setDebuggerActive(true); size_t withDebugging = PreambleHelper::getAdditionalCommandsSize(*mockDevice); EXPECT_LT(withoutDebugging, withDebugging); diff --git a/core/unit_tests/preemption/preemption_tests.cpp b/core/unit_tests/preemption/preemption_tests.cpp index 919094d914..54b93196a5 100644 --- a/core/unit_tests/preemption/preemption_tests.cpp +++ b/core/unit_tests/preemption/preemption_tests.cpp @@ -496,7 +496,7 @@ HWTEST_P(PreemptionTest, whenFailToCreatePreemptionAllocationThenFailToCreateDev public: MockDeviceReturnedDebuggerActive(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex) : MockDevice(executionEnvironment, deviceIndex) {} - bool isSourceLevelDebuggerActive() const override { + bool isDebuggerActive() const override { return true; } std::unique_ptr createCommandStreamReceiver() const override { diff --git a/core/unit_tests/source_level_debugger/source_level_debugger_preamble_test.inl b/core/unit_tests/source_level_debugger/source_level_debugger_preamble_test.inl index 7237924596..2b4fb35af9 100644 --- a/core/unit_tests/source_level_debugger/source_level_debugger_preamble_test.inl +++ b/core/unit_tests/source_level_debugger/source_level_debugger_preamble_test.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 Intel Corporation + * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -12,7 +12,7 @@ void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDebu using STATE_SIP = typename GfxFamily::STATE_SIP; auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); - mockDevice->setSourceLevelDebuggerActive(true); + mockDevice->setDebuggerActive(true); mockDevice->setPreemptionMode(PreemptionMode::MidThread); auto cmdSizePreemptionMidThread = PreemptionHelper::getRequiredStateSipCmdSize(*mockDevice); @@ -29,7 +29,7 @@ void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDebu STATE_SIP *stateSipCmd = (STATE_SIP *)*itorStateSip; auto sipAddress = stateSipCmd->getSystemInstructionPointer(); - auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isSourceLevelDebuggerActive()); + auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isDebuggerActive()); EXPECT_EQ(mockDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), sipAddress); } @@ -38,7 +38,7 @@ void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDisa using STATE_SIP = typename GfxFamily::STATE_SIP; auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); - mockDevice->setSourceLevelDebuggerActive(false); + mockDevice->setDebuggerActive(false); mockDevice->setPreemptionMode(PreemptionMode::MidThread); auto cmdSizePreemptionMidThread = PreemptionHelper::getRequiredStateSipCmdSize(*mockDevice); @@ -55,7 +55,7 @@ void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDisa STATE_SIP *stateSipCmd = (STATE_SIP *)*itorStateSip; auto sipAddress = stateSipCmd->getSystemInstructionPointer(); - auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isSourceLevelDebuggerActive()); + auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isDebuggerActive()); EXPECT_EQ(mockDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), sipAddress); } @@ -64,7 +64,7 @@ void SourceLevelDebuggerPreambleTest::givenPreemptionDisabledAndDebug using STATE_SIP = typename GfxFamily::STATE_SIP; auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); - mockDevice->setSourceLevelDebuggerActive(true); + mockDevice->setDebuggerActive(true); mockDevice->setPreemptionMode(PreemptionMode::Disabled); auto cmdSizePreemptionMidThread = PreemptionHelper::getRequiredStateSipCmdSize(*mockDevice); @@ -81,14 +81,14 @@ void SourceLevelDebuggerPreambleTest::givenPreemptionDisabledAndDebug STATE_SIP *stateSipCmd = (STATE_SIP *)*itorStateSip; auto sipAddress = stateSipCmd->getSystemInstructionPointer(); - auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isSourceLevelDebuggerActive()); + auto sipType = SipKernel::getSipKernelType(mockDevice->getHardwareInfo().platform.eRenderCoreFamily, mockDevice->isDebuggerActive()); EXPECT_EQ(mockDevice->getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, *mockDevice).getSipAllocation()->getGpuAddressToPatch(), sipAddress); } template void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() { auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); - mockDevice->setSourceLevelDebuggerActive(true); + mockDevice->setDebuggerActive(true); mockDevice->setPreemptionMode(PreemptionMode::MidThread); size_t requiredPreambleSize = PreemptionHelper::getRequiredStateSipCmdSize(*mockDevice); auto sizeExpected = sizeof(typename GfxFamily::STATE_SIP); @@ -98,7 +98,7 @@ void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDebu template void SourceLevelDebuggerPreambleTest::givenPreemptionDisabledAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() { auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); - mockDevice->setSourceLevelDebuggerActive(true); + mockDevice->setDebuggerActive(true); mockDevice->setPreemptionMode(PreemptionMode::Disabled); size_t requiredPreambleSize = PreemptionHelper::getRequiredStateSipCmdSize(*mockDevice); auto sizeExpected = sizeof(typename GfxFamily::STATE_SIP); @@ -108,7 +108,7 @@ void SourceLevelDebuggerPreambleTest::givenPreemptionDisabledAndDebug template void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() { auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); - mockDevice->setSourceLevelDebuggerActive(false); + mockDevice->setDebuggerActive(false); mockDevice->setPreemptionMode(PreemptionMode::MidThread); size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize(*mockDevice); auto sizeExpected = sizeof(typename GfxFamily::GPGPU_CSR_BASE_ADDRESS); @@ -118,7 +118,7 @@ void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDisa template void SourceLevelDebuggerPreambleTest::givenDisabledPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() { auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); - mockDevice->setSourceLevelDebuggerActive(false); + mockDevice->setDebuggerActive(false); mockDevice->setPreemptionMode(PreemptionMode::Disabled); size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize(*mockDevice); size_t sizeExpected = 0u; @@ -131,9 +131,9 @@ void SourceLevelDebuggerPreambleTest::givenKernelDebuggingActiveAndDi DebugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::Disabled)); auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); - mockDevice->setSourceLevelDebuggerActive(false); + mockDevice->setDebuggerActive(false); size_t withoutDebugging = PreambleHelper::getAdditionalCommandsSize(*mockDevice); - mockDevice->setSourceLevelDebuggerActive(true); + mockDevice->setDebuggerActive(true); size_t withDebugging = PreambleHelper::getAdditionalCommandsSize(*mockDevice); EXPECT_LT(withoutDebugging, withDebugging); diff --git a/runtime/built_ins/sip.cpp b/runtime/built_ins/sip.cpp index f74f7c8750..99aec2f004 100644 --- a/runtime/built_ins/sip.cpp +++ b/runtime/built_ins/sip.cpp @@ -94,7 +94,7 @@ SipKernelType SipKernel::getSipKernelType(GFXCORE_FAMILY family, bool debuggingA } GraphicsAllocation *SipKernel::getSipKernelAllocation(Device &device) { - auto sipType = SipKernel::getSipKernelType(device.getHardwareInfo().platform.eRenderCoreFamily, device.isSourceLevelDebuggerActive()); + auto sipType = SipKernel::getSipKernelType(device.getHardwareInfo().platform.eRenderCoreFamily, device.isDebuggerActive()); return device.getExecutionEnvironment()->getBuiltIns()->getSipKernel(sipType, device).getSipAllocation(); } diff --git a/runtime/command_stream/command_stream_receiver_hw_base.inl b/runtime/command_stream/command_stream_receiver_hw_base.inl index 03c1a5a3a0..9e958d3d11 100644 --- a/runtime/command_stream/command_stream_receiver_hw_base.inl +++ b/runtime/command_stream/command_stream_receiver_hw_base.inl @@ -296,7 +296,7 @@ CompletionStamp CommandStreamReceiverHw::flushTask( } //Reprogram state base address if required - if (isStateBaseAddressDirty || device.isSourceLevelDebuggerActive()) { + if (isStateBaseAddressDirty || device.isDebuggerActive()) { addPipeControlBeforeStateBaseAddress(commandStreamCSR); uint64_t newGSHbase = 0; @@ -393,7 +393,7 @@ CompletionStamp CommandStreamReceiverHw::flushTask( makeResident(*preemptionAllocation); } - if (dispatchFlags.preemptionMode == PreemptionMode::MidThread || device.isSourceLevelDebuggerActive()) { + if (dispatchFlags.preemptionMode == PreemptionMode::MidThread || device.isDebuggerActive()) { makeResident(*SipKernel::getSipKernelAllocation(device)); if (debugSurface) { makeResident(*debugSurface); @@ -635,7 +635,7 @@ template size_t CommandStreamReceiverHw::getRequiredCmdStreamSize(const DispatchFlags &dispatchFlags, Device &device) { size_t size = getRequiredCmdSizeForPreamble(device); size += getRequiredStateBaseAddressSize(); - if (!this->isStateSipSent || device.isSourceLevelDebuggerActive()) { + if (!this->isStateSipSent || device.isDebuggerActive()) { size += PreemptionHelper::getRequiredStateSipCmdSize(device); } size += PipeControlHelper::getSizeForSinglePipeControl(); @@ -727,7 +727,7 @@ inline size_t CommandStreamReceiverHw::getCmdSizeForPreemption(const template inline void CommandStreamReceiverHw::programStateSip(LinearStream &cmdStream, Device &device) { - if (!this->isStateSipSent || device.isSourceLevelDebuggerActive()) { + if (!this->isStateSipSent || device.isDebuggerActive()) { PreemptionHelper::programStateSip(cmdStream, device); this->isStateSipSent = true; } diff --git a/runtime/device/cl_device.cpp b/runtime/device/cl_device.cpp index 37374e9546..f7b989ca12 100644 --- a/runtime/device/cl_device.cpp +++ b/runtime/device/cl_device.cpp @@ -8,9 +8,12 @@ #include "runtime/device/cl_device.h" #include "core/device/device.h" +#include "core/execution_environment/root_device_environment.h" +#include "core/os_interface/os_interface.h" #include "core/program/sync_buffer_handler.h" #include "runtime/platform/extensions.h" #include "runtime/platform/platform.h" +#include "runtime/source_level_debugger/source_level_debugger.h" namespace NEO { @@ -26,9 +29,18 @@ ClDevice::ClDevice(Device &device, Platform *platform) : device(device), platfor device.getDeviceById(i)->setSpecializedDevice(subDevices[i].get()); } } + if (device.getDeviceInfo().debuggerActive) { + auto osInterface = device.getRootDeviceEnvironment().osInterface.get(); + getSourceLevelDebugger()->notifyNewDevice(osInterface ? osInterface->getDeviceHandle() : 0); + } } ClDevice::~ClDevice() { + + if (device.getDeviceInfo().debuggerActive && getSourceLevelDebugger()) { + getSourceLevelDebugger()->notifyDeviceDestruction(); + } + syncBufferHandler.reset(); for (auto &subDevice : subDevices) { subDevice.reset(); @@ -86,8 +98,8 @@ bool ClDevice::isSimulation() const { return device.isSimulation(); } GFXCORE_FAMILY ClDevice::getRenderCoreFamily() const { return device.getRenderCoreFamily(); } PerformanceCounters *ClDevice::getPerformanceCounters() { return device.getPerformanceCounters(); } PreemptionMode ClDevice::getPreemptionMode() const { return device.getPreemptionMode(); } -bool ClDevice::isSourceLevelDebuggerActive() const { return device.isSourceLevelDebuggerActive(); } -SourceLevelDebugger *ClDevice::getSourceLevelDebugger() { return device.getSourceLevelDebugger(); } +bool ClDevice::isDebuggerActive() const { return device.isDebuggerActive(); } +SourceLevelDebugger *ClDevice::getSourceLevelDebugger() { return reinterpret_cast(device.getDebugger()); } ExecutionEnvironment *ClDevice::getExecutionEnvironment() const { return device.getExecutionEnvironment(); } const RootDeviceEnvironment &ClDevice::getRootDeviceEnvironment() const { return device.getRootDeviceEnvironment(); } const HardwareCapabilities &ClDevice::getHardwareCapabilities() const { return device.getHardwareCapabilities(); } diff --git a/runtime/device/cl_device.h b/runtime/device/cl_device.h index e23554f32d..46dcd053cd 100644 --- a/runtime/device/cl_device.h +++ b/runtime/device/cl_device.h @@ -68,7 +68,7 @@ class ClDevice : public BaseObject<_cl_device_id> { void allocateSyncBufferHandler(); PerformanceCounters *getPerformanceCounters(); PreemptionMode getPreemptionMode() const; - bool isSourceLevelDebuggerActive() const; + bool isDebuggerActive() const; SourceLevelDebugger *getSourceLevelDebugger(); ExecutionEnvironment *getExecutionEnvironment() const; const RootDeviceEnvironment &getRootDeviceEnvironment() const; diff --git a/runtime/device/device_caps.cpp b/runtime/device/device_caps.cpp index 8ac16c18e3..04311a0981 100644 --- a/runtime/device/device_caps.cpp +++ b/runtime/device/device_caps.cpp @@ -370,8 +370,8 @@ void Device::initializeCaps() { deviceInfo.preferredLocalAtomicAlignment = MemoryConstants::cacheLineSize; deviceInfo.preferredPlatformAtomicAlignment = MemoryConstants::cacheLineSize; - deviceInfo.sourceLevelDebuggerActive = (executionEnvironment->sourceLevelDebugger) ? executionEnvironment->sourceLevelDebugger->isDebuggerActive() : false; - if (deviceInfo.sourceLevelDebuggerActive) { + deviceInfo.debuggerActive = (executionEnvironment->debugger) ? executionEnvironment->debugger->isDebuggerActive() : false; + if (deviceInfo.debuggerActive) { this->preemptionMode = PreemptionMode::Disabled; } diff --git a/runtime/device/device_info.h b/runtime/device/device_info.h index f139369a32..5724f7903f 100644 --- a/runtime/device/device_info.h +++ b/runtime/device/device_info.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2019 Intel Corporation + * Copyright (C) 2017-2020 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -135,7 +135,7 @@ struct DeviceInfo { bool vmeExtension; bool platformLP; bool packedYuvExtension; - bool sourceLevelDebuggerActive; + bool debuggerActive; /*Unified Shared Memory Capabilites*/ cl_unified_shared_memory_capabilities_intel hostMemCapabilities; cl_unified_shared_memory_capabilities_intel deviceMemCapabilities; diff --git a/runtime/dll/CMakeLists.txt b/runtime/dll/CMakeLists.txt index e733307fc8..a8bd095641 100644 --- a/runtime/dll/CMakeLists.txt +++ b/runtime/dll/CMakeLists.txt @@ -16,6 +16,7 @@ set(RUNTIME_SRCS_DLL_BASE ${CMAKE_CURRENT_SOURCE_DIR}/create_deferred_deleter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/create_tbx_sockets.cpp ${CMAKE_CURRENT_SOURCE_DIR}/debug_manager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/debugger.cpp ${CMAKE_CURRENT_SOURCE_DIR}/options_dll.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source_level_debugger.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/get_devices.cpp diff --git a/runtime/dll/debugger.cpp b/runtime/dll/debugger.cpp new file mode 100644 index 0000000000..45ab27a710 --- /dev/null +++ b/runtime/dll/debugger.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "core/debugger/debugger.h" + +#include "core/built_ins/sip_kernel_type.h" +#include "core/helpers/hw_info.h" +#include "runtime/built_ins/sip.h" +#include "runtime/source_level_debugger/source_level_debugger.h" + +namespace NEO { +std::unique_ptr Debugger::create(HardwareInfo *hwInfo) { + std::unique_ptr sourceLevelDebugger; + if (hwInfo->capabilityTable.debuggerSupported) { + sourceLevelDebugger.reset(SourceLevelDebugger::create()); + } + if (sourceLevelDebugger) { + bool localMemorySipAvailable = (SipKernelType::DbgCsrLocal == SipKernel::getSipKernelType(hwInfo->platform.eRenderCoreFamily, true)); + sourceLevelDebugger->initialize(localMemorySipAvailable); + } + return sourceLevelDebugger; +} +} // namespace NEO \ No newline at end of file diff --git a/runtime/platform/platform.cpp b/runtime/platform/platform.cpp index d1af7c603f..b13a9bc744 100644 --- a/runtime/platform/platform.cpp +++ b/runtime/platform/platform.cpp @@ -185,9 +185,9 @@ bool Platform::initialize() { auto hwInfo = executionEnvironment.getHardwareInfo(); - const bool sourceLevelDebuggerActive = executionEnvironment.sourceLevelDebugger && executionEnvironment.sourceLevelDebugger->isDebuggerActive(); - if (clDevices[0]->getPreemptionMode() == PreemptionMode::MidThread || sourceLevelDebuggerActive) { - auto sipType = SipKernel::getSipKernelType(hwInfo->platform.eRenderCoreFamily, clDevices[0]->isSourceLevelDebuggerActive()); + const bool debuggerActive = executionEnvironment.debugger && executionEnvironment.debugger->isDebuggerActive(); + if (clDevices[0]->getPreemptionMode() == PreemptionMode::MidThread || debuggerActive) { + auto sipType = SipKernel::getSipKernelType(hwInfo->platform.eRenderCoreFamily, clDevices[0]->isDebuggerActive()); initSipKernel(sipType, *clDevices[0]); } diff --git a/runtime/program/build.cpp b/runtime/program/build.cpp index 15040408b1..df0a605583 100644 --- a/runtime/program/build.cpp +++ b/runtime/program/build.cpp @@ -172,8 +172,8 @@ cl_int Program::build( bool Program::appendKernelDebugOptions() { CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::debugKernelEnable); CompilerOptions::concatenateAppend(options, CompilerOptions::generateDebugInfo); - auto sourceLevelDebugger = pDevice->getSourceLevelDebugger(); - if (sourceLevelDebugger && sourceLevelDebugger->isOptimizationDisabled()) { + auto debugger = pDevice->getSourceLevelDebugger(); + if (debugger && debugger->isOptimizationDisabled()) { CompilerOptions::concatenateAppend(options, CompilerOptions::optDisable); } return true; diff --git a/runtime/program/program.cpp b/runtime/program/program.cpp index fa7e7cc2ba..71de3dfe92 100644 --- a/runtime/program/program.cpp +++ b/runtime/program/program.cpp @@ -77,7 +77,7 @@ Program::Program(ExecutionEnvironment &executionEnvironment, Context *context, b CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::bindlessImages); } - kernelDebugEnabled = pDevice->isSourceLevelDebuggerActive(); + kernelDebugEnabled = pDevice->isDebuggerActive(); auto enableStatelessToStatefullWithOffset = pDevice->getHardwareCapabilities().isStatelesToStatefullWithOffsetSupported; if (DebugManager.flags.EnableStatelessToStatefulBufferOffsetOpt.get() != -1) { diff --git a/runtime/source_level_debugger/source_level_debugger.cpp b/runtime/source_level_debugger/source_level_debugger.cpp index a9b0bffc25..b5a5bee54e 100644 --- a/runtime/source_level_debugger/source_level_debugger.cpp +++ b/runtime/source_level_debugger/source_level_debugger.cpp @@ -7,6 +7,7 @@ #include "runtime/source_level_debugger/source_level_debugger.h" +#include "core/debugger/debugger.h" #include "core/helpers/debug_helpers.h" #include "core/os_interface/os_interface.h" #include "runtime/program/kernel_info.h" @@ -17,6 +18,7 @@ #define IGFXDBG_CURRENT_VERSION 4 namespace NEO { + const char *SourceLevelDebugger::notifyNewDeviceSymbol = "notifyNewDevice"; const char *SourceLevelDebugger::notifySourceCodeSymbol = "notifySourceCode"; const char *SourceLevelDebugger::getDebuggerOptionSymbol = "getDebuggerOption"; diff --git a/runtime/source_level_debugger/source_level_debugger.h b/runtime/source_level_debugger/source_level_debugger.h index 5394585d4b..c75113eeb3 100644 --- a/runtime/source_level_debugger/source_level_debugger.h +++ b/runtime/source_level_debugger/source_level_debugger.h @@ -1,11 +1,12 @@ /* - * Copyright (C) 2018-2019 Intel Corporation + * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once +#include "core/debugger/debugger.h" #include "core/os_interface/os_library.h" #include @@ -14,15 +15,15 @@ namespace NEO { struct KernelInfo; -class SourceLevelDebugger { +class SourceLevelDebugger : public Debugger { public: SourceLevelDebugger(OsLibrary *library); - virtual ~SourceLevelDebugger(); + ~SourceLevelDebugger() override; SourceLevelDebugger(const SourceLevelDebugger &ref) = delete; SourceLevelDebugger &operator=(const SourceLevelDebugger &) = delete; static SourceLevelDebugger *create(); - MOCKABLE_VIRTUAL bool isDebuggerActive(); + bool isDebuggerActive() override; MOCKABLE_VIRTUAL bool notifyNewDevice(uint32_t deviceHandle); MOCKABLE_VIRTUAL bool notifyDeviceDestruction(); MOCKABLE_VIRTUAL bool notifySourceCode(const char *sourceCode, size_t size, std::string &filename) const; diff --git a/unit_tests/command_queue/enqueue_debug_kernel_tests.cpp b/unit_tests/command_queue/enqueue_debug_kernel_tests.cpp index a6719716a5..96b25b3a37 100644 --- a/unit_tests/command_queue/enqueue_debug_kernel_tests.cpp +++ b/unit_tests/command_queue/enqueue_debug_kernel_tests.cpp @@ -32,10 +32,10 @@ class EnqueueDebugKernelTest : public ProgramSimpleFixture, void SetUp() override { ProgramSimpleFixture::SetUp(); device = pClDevice; - pDevice->executionEnvironment->sourceLevelDebugger.reset(new SourceLevelDebugger(nullptr)); + pDevice->executionEnvironment->debugger.reset(new SourceLevelDebugger(nullptr)); if (pDevice->getHardwareInfo().platform.eRenderCoreFamily >= IGFX_GEN9_CORE) { - pDevice->deviceInfo.sourceLevelDebuggerActive = true; + pDevice->deviceInfo.debuggerActive = true; std::string filename; std::string kernelOption(CompilerOptions::debugKernelEnable); KernelFilenameHelper::getKernelFilenameFromInternalOption(kernelOption, filename); @@ -88,7 +88,7 @@ class EnqueueDebugKernelTest : public ProgramSimpleFixture, }; HWTEST_F(EnqueueDebugKernelTest, givenDebugKernelWhenEnqueuedThenSSHAndBtiAreCorrectlySet) { - if (pDevice->isSourceLevelDebuggerActive()) { + if (pDevice->isDebuggerActive()) { using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE; using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; std::unique_ptr> mockCmdQ(new MockCommandQueueHw(&context, pClDevice, 0)); diff --git a/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp b/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp index 443656d509..97ec1f4678 100644 --- a/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_flush_task_3_tests.cpp @@ -674,7 +674,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenCsrInBatchingModeWhenTotalRes executionEnvironment->memoryManager.reset(mockedMemoryManager); auto mockCsr = std::make_unique>(*executionEnvironment, 0); - if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isSourceLevelDebuggerActive()) { + if (pDevice->getPreemptionMode() == PreemptionMode::MidThread || pDevice->isDebuggerActive()) { mockCsr->createPreemptionAllocation(); } diff --git a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp index 74ce9d4d70..276a13ff1b 100644 --- a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp @@ -133,7 +133,7 @@ HWTEST_F(UltCommandStreamReceiverTest, givenSentStateSipFlagSetAndSourceLevelDeb commandStreamReceiver.isStateSipSent = true; auto sizeWithoutSourceKernelDebugging = commandStreamReceiver.getRequiredCmdStreamSize(dispatchFlags, *pDevice); - pDevice->setSourceLevelDebuggerActive(true); + pDevice->setDebuggerActive(true); commandStreamReceiver.isStateSipSent = true; auto sizeWithSourceKernelDebugging = commandStreamReceiver.getRequiredCmdStreamSize(dispatchFlags, *pDevice); diff --git a/unit_tests/device/device_caps_tests.cpp b/unit_tests/device/device_caps_tests.cpp index 33bd4576be..399e6f4291 100644 --- a/unit_tests/device/device_caps_tests.cpp +++ b/unit_tests/device/device_caps_tests.cpp @@ -1058,8 +1058,8 @@ TEST_F(DeviceGetCapsTest, givenDeviceWithNullSourceLevelDebuggerWhenCapsAreIniti std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); const auto &caps = device->getDeviceInfo(); - EXPECT_EQ(nullptr, device->getSourceLevelDebugger()); - EXPECT_FALSE(caps.sourceLevelDebuggerActive); + EXPECT_EQ(nullptr, device->getDebugger()); + EXPECT_FALSE(caps.debuggerActive); } TEST(Device_UseCaps, givenCapabilityTableWhenDeviceInitializeCapsThenVmeVersionsAreSetProperly) { @@ -1097,11 +1097,11 @@ typedef HwHelperTest DeviceCapsWithModifiedHwInfoTest; TEST_F(DeviceCapsWithModifiedHwInfoTest, givenPlatformWithSourceLevelDebuggerNotSupportedWhenDeviceIsCreatedThenSourceLevelDebuggerActiveIsSetToFalse) { - hardwareInfo.capabilityTable.sourceLevelDebuggerSupported = false; + hardwareInfo.capabilityTable.debuggerSupported = false; std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(&hardwareInfo)); const auto &caps = device->getDeviceInfo(); - EXPECT_EQ(nullptr, device->getSourceLevelDebugger()); - EXPECT_FALSE(caps.sourceLevelDebuggerActive); + EXPECT_EQ(nullptr, device->getDebugger()); + EXPECT_FALSE(caps.debuggerActive); } diff --git a/unit_tests/execution_environment/execution_environment_tests.cpp b/unit_tests/execution_environment/execution_environment_tests.cpp index bd2a7cffa6..99bd790dc3 100644 --- a/unit_tests/execution_environment/execution_environment_tests.cpp +++ b/unit_tests/execution_environment/execution_environment_tests.cpp @@ -194,7 +194,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe executionEnvironment->rootDeviceEnvironments[0]->aubCenter = std::make_unique(destructorId); executionEnvironment->builtins = std::make_unique(destructorId); executionEnvironment->compilerInterface = std::make_unique(destructorId); - executionEnvironment->sourceLevelDebugger = std::make_unique(destructorId); + executionEnvironment->debugger = std::make_unique(destructorId); executionEnvironment.reset(nullptr); EXPECT_EQ(8u, destructorId); diff --git a/unit_tests/gen9/command_stream_receiver_hw_tests_gen9.cpp b/unit_tests/gen9/command_stream_receiver_hw_tests_gen9.cpp index 5a2c008979..066615fcdd 100644 --- a/unit_tests/gen9/command_stream_receiver_hw_tests_gen9.cpp +++ b/unit_tests/gen9/command_stream_receiver_hw_tests_gen9.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2019 Intel Corporation + * Copyright (C) 2018-2020 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -36,7 +36,7 @@ GEN9TEST_F(UltCommandStreamReceiverTest, whenPreambleIsProgrammedThenStateSipCmd commandStreamReceiver.isPreambleSent = false; pDevice->setPreemptionMode(PreemptionMode::Disabled); - pDevice->setSourceLevelDebuggerActive(true); + pDevice->setDebuggerActive(true); uint32_t newL3Config; DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags(); diff --git a/unit_tests/libult/CMakeLists.txt b/unit_tests/libult/CMakeLists.txt index 5ca113d476..eb0499d61e 100644 --- a/unit_tests/libult/CMakeLists.txt +++ b/unit_tests/libult/CMakeLists.txt @@ -26,6 +26,7 @@ set(IGDRCL_SRCS_LIB_ULT ${NEO_SOURCE_DIR}/core/helpers/allow_deferred_deleter.cpp ${NEO_SOURCE_DIR}/core/unit_tests/utilities/cpuintrinsics.cpp ${NEO_SOURCE_DIR}/runtime/compiler_interface/default_cache_config.cpp + ${NEO_SOURCE_DIR}/runtime/dll/debugger.cpp ${NEO_SOURCE_DIR}/unit_tests/abort.cpp ${NEO_SOURCE_DIR}/unit_tests/helpers/built_ins_helper.cpp ${NEO_SOURCE_DIR}/unit_tests/helpers/debug_helpers.cpp diff --git a/unit_tests/mocks/mock_device.cpp b/unit_tests/mocks/mock_device.cpp index 684594cf1a..a1d36b2c83 100644 --- a/unit_tests/mocks/mock_device.cpp +++ b/unit_tests/mocks/mock_device.cpp @@ -103,7 +103,7 @@ void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr, uint3 commandStreamReceivers[engineIndex]->initializeTagAllocation(); commandStreamReceivers[engineIndex]->createGlobalFenceAllocation(); - if (preemptionMode == PreemptionMode::MidThread || isSourceLevelDebuggerActive()) { + if (preemptionMode == PreemptionMode::MidThread || isDebuggerActive()) { commandStreamReceivers[engineIndex]->createPreemptionAllocation(); } } diff --git a/unit_tests/mocks/mock_device.h b/unit_tests/mocks/mock_device.h index fb81542df8..f92a448475 100644 --- a/unit_tests/mocks/mock_device.h +++ b/unit_tests/mocks/mock_device.h @@ -86,8 +86,8 @@ class MockDevice : public RootDevice { void resetCommandStreamReceiver(CommandStreamReceiver *newCsr); void resetCommandStreamReceiver(CommandStreamReceiver *newCsr, uint32_t engineIndex); - void setSourceLevelDebuggerActive(bool active) { - this->deviceInfo.sourceLevelDebuggerActive = active; + void setDebuggerActive(bool active) { + this->deviceInfo.debuggerActive = active; } template @@ -145,7 +145,7 @@ class MockClDevice : public ClDevice { CommandStreamReceiver &getGpgpuCommandStreamReceiver() const { return device.getGpgpuCommandStreamReceiver(); } void resetCommandStreamReceiver(CommandStreamReceiver *newCsr) { device.resetCommandStreamReceiver(newCsr); } void resetCommandStreamReceiver(CommandStreamReceiver *newCsr, uint32_t engineIndex) { device.resetCommandStreamReceiver(newCsr, engineIndex); } - void setSourceLevelDebuggerActive(bool active) { device.setSourceLevelDebuggerActive(active); } + void setSourceLevelDebuggerActive(bool active) { device.setDebuggerActive(active); } template static T *createWithExecutionEnvironment(const HardwareInfo *pHwInfo, ExecutionEnvironment *executionEnvironment, uint32_t rootDeviceIndex) { return MockDevice::createWithExecutionEnvironment(pHwInfo, executionEnvironment, rootDeviceIndex); diff --git a/unit_tests/platform/platform_tests.cpp b/unit_tests/platform/platform_tests.cpp index 09f8db028d..8fc5324f5c 100644 --- a/unit_tests/platform/platform_tests.cpp +++ b/unit_tests/platform/platform_tests.cpp @@ -152,7 +152,7 @@ TEST_F(PlatformTest, givenDisabledPreemptionInactiveSourceLevelDebuggerWhenIniti pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns); auto sourceLevelDebugger = new MockSourceLevelDebugger(); sourceLevelDebugger->setActive(false); - pPlatform->peekExecutionEnvironment()->sourceLevelDebugger.reset(sourceLevelDebugger); + pPlatform->peekExecutionEnvironment()->debugger.reset(sourceLevelDebugger); EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType); EXPECT_FALSE(MockSipData::called); @@ -167,7 +167,7 @@ TEST_F(PlatformTest, givenDisabledPreemptionActiveSourceLevelDebuggerWhenInitial auto builtIns = new MockBuiltins(); pPlatform->peekExecutionEnvironment()->builtins.reset(builtIns); - pPlatform->peekExecutionEnvironment()->sourceLevelDebugger.reset(new MockActiveSourceLevelDebugger()); + pPlatform->peekExecutionEnvironment()->debugger.reset(new MockActiveSourceLevelDebugger()); EXPECT_EQ(SipKernelType::COUNT, MockSipData::calledType); EXPECT_FALSE(MockSipData::called); diff --git a/unit_tests/program/program_with_kernel_debug_tests.cpp b/unit_tests/program/program_with_kernel_debug_tests.cpp index 0a7158d30a..e1abc88e37 100644 --- a/unit_tests/program/program_with_kernel_debug_tests.cpp +++ b/unit_tests/program/program_with_kernel_debug_tests.cpp @@ -41,7 +41,7 @@ class ProgramWithKernelDebuggingTest : public ProgramSimpleFixture, void SetUp() override { ProgramSimpleFixture::SetUp(); device = pClDevice; - if (!pDevice->getHardwareInfo().capabilityTable.sourceLevelDebuggerSupported) { + if (!pDevice->getHardwareInfo().capabilityTable.debuggerSupported) { GTEST_SKIP(); } @@ -102,7 +102,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugAndOptDisabledWhen MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger; sourceLevelDebugger->isOptDisabled = true; - pDevice->executionEnvironment->sourceLevelDebugger.reset(sourceLevelDebugger); + pDevice->executionEnvironment->debugger.reset(sourceLevelDebugger); cl_int retVal = pProgram->compile(1, &device, nullptr, 0, nullptr, nullptr, @@ -117,7 +117,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsCompi if (pDevice->getHardwareInfo().platform.eRenderCoreFamily >= IGFX_GEN9_CORE) { MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger; sourceLevelDebugger->sourceCodeFilename = "debugFileName"; - pDevice->executionEnvironment->sourceLevelDebugger.reset(sourceLevelDebugger); + pDevice->executionEnvironment->debugger.reset(sourceLevelDebugger); cl_int retVal = pProgram->compile(1, &device, nullptr, 0, nullptr, nullptr, @@ -157,7 +157,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugAndOptDisabledWhen MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger; sourceLevelDebugger->isOptDisabled = true; - pDevice->executionEnvironment->sourceLevelDebugger.reset(sourceLevelDebugger); + pDevice->executionEnvironment->debugger.reset(sourceLevelDebugger); cl_int retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false); EXPECT_EQ(CL_SUCCESS, retVal); @@ -170,7 +170,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsBuilt MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger; sourceLevelDebugger->sourceCodeFilename = "debugFileName"; - pDevice->executionEnvironment->sourceLevelDebugger.reset(sourceLevelDebugger); + pDevice->executionEnvironment->debugger.reset(sourceLevelDebugger); cl_int retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false); EXPECT_EQ(CL_SUCCESS, retVal); @@ -182,7 +182,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsLinke if (pDevice->getHardwareInfo().platform.eRenderCoreFamily >= IGFX_GEN9_CORE) { MockActiveSourceLevelDebugger *sourceLevelDebugger = new MockActiveSourceLevelDebugger; - pDevice->executionEnvironment->sourceLevelDebugger.reset(sourceLevelDebugger); + pDevice->executionEnvironment->debugger.reset(sourceLevelDebugger); cl_int retVal = pProgram->compile(1, &device, nullptr, 0, nullptr, nullptr, nullptr, nullptr); EXPECT_EQ(CL_SUCCESS, retVal); @@ -210,7 +210,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsBuilt EXPECT_CALL(*sourceLevelDebugger, notifyKernelDebugData(::testing::_)).Times(1); sourceLevelDebugger->setActive(true); - pDevice->executionEnvironment->sourceLevelDebugger.reset(sourceLevelDebugger); + pDevice->executionEnvironment->debugger.reset(sourceLevelDebugger); cl_int retVal = pProgram->build(1, &device, nullptr, nullptr, nullptr, false); EXPECT_EQ(CL_SUCCESS, retVal); @@ -229,7 +229,7 @@ TEST_F(ProgramWithKernelDebuggingTest, givenEnabledKernelDebugWhenProgramIsLinke EXPECT_CALL(*sourceLevelDebugger, notifyKernelDebugData(::testing::_)).Times(1); sourceLevelDebugger->setActive(true); - pDevice->executionEnvironment->sourceLevelDebugger.reset(sourceLevelDebugger); + pDevice->executionEnvironment->debugger.reset(sourceLevelDebugger); cl_int retVal = pProgram->compile(1, &device, nullptr, 0, nullptr, nullptr, diff --git a/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp b/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp index f0fec0873f..237467e0f5 100644 --- a/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp +++ b/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp @@ -29,7 +29,7 @@ class CommandStreamReceiverWithActiveDebuggerTest : public ::testing::Test { environment.setCsrType>(); executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1); hwInfo->capabilityTable = platformDevices[0]->capabilityTable; - hwInfo->capabilityTable.sourceLevelDebuggerSupported = true; + hwInfo->capabilityTable.debuggerSupported = true; auto mockMemoryManager = new MockMemoryManager(*executionEnvironment); executionEnvironment->memoryManager.reset(mockMemoryManager); diff --git a/unit_tests/source_level_debugger/source_level_debugger_device_tests.cpp b/unit_tests/source_level_debugger/source_level_debugger_device_tests.cpp index 327f414843..7d4c6d0ff0 100644 --- a/unit_tests/source_level_debugger/source_level_debugger_device_tests.cpp +++ b/unit_tests/source_level_debugger/source_level_debugger_device_tests.cpp @@ -32,22 +32,24 @@ class MockDeviceWithDebuggerActive : public MockDevice { MockDeviceWithDebuggerActive(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex) : MockDevice(executionEnvironment, deviceIndex) {} void initializeCaps() override { MockDevice::initializeCaps(); - this->setSourceLevelDebuggerActive(true); + this->setDebuggerActive(true); } }; TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsDestructedThenSourceLevelDebuggerIsNotified) { ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); auto gmock = new ::testing::NiceMock(new MockOsLibrary); - executionEnvironment->sourceLevelDebugger.reset(gmock); + executionEnvironment->debugger.reset(gmock); auto device = std::unique_ptr(MockDevice::create(executionEnvironment, 0u)); + std::unique_ptr pClDevice(new MockClDevice{device.get()}); EXPECT_CALL(*gmock, notifyDeviceDestruction()).Times(1); + device.release(); } TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsCreatedThenPreemptionIsDisabled) { ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); - executionEnvironment->sourceLevelDebugger.reset(new MockActiveSourceLevelDebugger(new MockOsLibrary)); + executionEnvironment->debugger.reset(new MockActiveSourceLevelDebugger(new MockOsLibrary)); auto device = std::unique_ptr(MockDevice::create(executionEnvironment, 0u)); EXPECT_EQ(PreemptionMode::Disabled, device->getPreemptionMode()); diff --git a/unit_tests/source_level_debugger/source_level_debugger_tests.cpp b/unit_tests/source_level_debugger/source_level_debugger_tests.cpp index 739ee72e7b..4fc2d0e817 100644 --- a/unit_tests/source_level_debugger/source_level_debugger_tests.cpp +++ b/unit_tests/source_level_debugger/source_level_debugger_tests.cpp @@ -44,14 +44,14 @@ class DebuggerLibraryRestorer { TEST(SourceLevelDebugger, givenPlatformWhenItIsCreatedThenSourceLevelDebuggerIsCreatedInExecutionEnvironment) { DebuggerLibraryRestorer restorer; - if (platformDevices[0]->capabilityTable.sourceLevelDebuggerSupported) { + if (platformDevices[0]->capabilityTable.debuggerSupported) { DebuggerLibrary::setLibraryAvailable(true); DebuggerLibrary::setDebuggerActive(true); auto executionEnvironment = new ExecutionEnvironment(); Platform platform(*executionEnvironment); platform.initialize(); - EXPECT_NE(nullptr, executionEnvironment->sourceLevelDebugger); + EXPECT_NE(nullptr, executionEnvironment->debugger); } } @@ -452,7 +452,7 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenInitializeIsCal TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceIsConstructedThenDebuggerIsInitialized) { DebuggerLibraryRestorer restorer; - if (platformDevices[0]->capabilityTable.sourceLevelDebuggerSupported) { + if (platformDevices[0]->capabilityTable.debuggerSupported) { DebuggerLibraryInterceptor interceptor; DebuggerLibrary::setLibraryAvailable(true); DebuggerLibrary::setDebuggerActive(true); @@ -466,23 +466,26 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceIsConstructe TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreatedThenDebuggerIsNotified) { DebuggerLibraryRestorer restorer; - if (platformDevices[0]->capabilityTable.sourceLevelDebuggerSupported) { + if (platformDevices[0]->capabilityTable.debuggerSupported) { DebuggerLibraryInterceptor interceptor; DebuggerLibrary::setLibraryAvailable(true); DebuggerLibrary::setDebuggerActive(true); DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor); unique_ptr device(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); + unique_ptr pClDevice(new MockClDevice{device.get()}); EXPECT_TRUE(interceptor.newDeviceCalled); uint32_t deviceHandleExpected = device->getGpgpuCommandStreamReceiver().getOSInterface() != nullptr ? device->getGpgpuCommandStreamReceiver().getOSInterface()->getDeviceHandle() : 0; EXPECT_EQ(reinterpret_cast(static_cast(deviceHandleExpected)), interceptor.newDeviceArgIn.dh); + pClDevice.reset(); + device.release(); } } TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreatedWithOsCsrThenDebuggerIsNotifiedWithCorrectDeviceHandle) { DebuggerLibraryRestorer restorer; - if (platformDevices[0]->capabilityTable.sourceLevelDebuggerSupported) { + if (platformDevices[0]->capabilityTable.debuggerSupported) { DebuggerLibraryInterceptor interceptor; DebuggerLibrary::setLibraryAvailable(true); DebuggerLibrary::setDebuggerActive(true); @@ -496,12 +499,14 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreate hwInfo->capabilityTable.instrumentationEnabled = true; unique_ptr device(Device::create(executionEnvironment, 0)); + unique_ptr pClDevice(new MockClDevice{device.get()}); ASSERT_NE(nullptr, device->getGpgpuCommandStreamReceiver().getOSInterface()); EXPECT_TRUE(interceptor.newDeviceCalled); uint32_t deviceHandleExpected = device->getGpgpuCommandStreamReceiver().getOSInterface()->getDeviceHandle(); EXPECT_EQ(reinterpret_cast(static_cast(deviceHandleExpected)), interceptor.newDeviceArgIn.dh); + device.release(); } } @@ -515,7 +520,7 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenDeviceIsCreated unique_ptr device(MockDevice::createWithNewExecutionEnvironment(nullptr)); - EXPECT_EQ(nullptr, device->getSourceLevelDebugger()); + EXPECT_EQ(nullptr, device->getDebugger()); EXPECT_FALSE(interceptor.initCalled); EXPECT_FALSE(interceptor.newDeviceCalled); } @@ -523,7 +528,7 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryNotActiveWhenDeviceIsCreated TEST(SourceLevelDebugger, givenTwoRootDevicesWhenSecondIsCreatedThenNotCreatingNewSourceLevelDebugger) { DebuggerLibraryRestorer restorer; - if (platformDevices[0]->capabilityTable.sourceLevelDebuggerSupported) { + if (platformDevices[0]->capabilityTable.debuggerSupported) { DebuggerLibraryInterceptor interceptor; DebuggerLibrary::setLibraryAvailable(true); DebuggerLibrary::setDebuggerActive(true); @@ -546,15 +551,15 @@ TEST(SourceLevelDebugger, givenTwoRootDevicesWhenSecondIsCreatedThenNotCreatingN TEST(SourceLevelDebugger, givenMultipleRootDevicesWhenTheyAreCreatedTheyAllReuseTheSameSourceLevelDebugger) { DebuggerLibraryRestorer restorer; - if (platformDevices[0]->capabilityTable.sourceLevelDebuggerSupported) { + if (platformDevices[0]->capabilityTable.debuggerSupported) { DebuggerLibrary::setLibraryAvailable(true); DebuggerLibrary::setDebuggerActive(true); ExecutionEnvironment *executionEnvironment = platform()->peekExecutionEnvironment(); executionEnvironment->prepareRootDeviceEnvironments(2); std::unique_ptr device1(Device::create(executionEnvironment, 0u)); - auto sourceLevelDebugger = device1->getSourceLevelDebugger(); + auto sourceLevelDebugger = device1->getDebugger(); std::unique_ptr device2(Device::create(executionEnvironment, 1u)); - EXPECT_EQ(sourceLevelDebugger, device2->getSourceLevelDebugger()); + EXPECT_EQ(sourceLevelDebugger, device2->getDebugger()); } }