2020-06-18 23:08:55 +08:00
|
|
|
/*
|
2024-04-19 22:20:27 +08:00
|
|
|
* Copyright (C) 2020-2024 Intel Corporation
|
2020-06-18 23:08:55 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2022-06-15 05:24:58 +08:00
|
|
|
#include "shared/source/debugger/debugger_l0.h"
|
2022-02-08 01:26:34 +08:00
|
|
|
#include "shared/source/kernel/debug_data.h"
|
|
|
|
|
2022-06-15 05:24:58 +08:00
|
|
|
extern NEO::DebugerL0CreateFn mockDebuggerL0HwFactory[];
|
2020-06-18 23:08:55 +08:00
|
|
|
|
2022-07-05 23:55:15 +08:00
|
|
|
namespace NEO {
|
2022-06-15 05:24:58 +08:00
|
|
|
template <class BaseClass>
|
|
|
|
struct WhiteBox;
|
2020-06-18 23:08:55 +08:00
|
|
|
|
2022-07-06 21:23:03 +08:00
|
|
|
class MockDebuggerL0 : public NEO::DebuggerL0 {
|
|
|
|
public:
|
2023-08-04 17:19:46 +08:00
|
|
|
MockDebuggerL0(NEO::Device *device) : DebuggerL0(device) {}
|
2022-07-06 21:23:03 +08:00
|
|
|
|
2022-11-23 04:07:45 +08:00
|
|
|
void captureStateBaseAddress(NEO::LinearStream &cmdStream, SbaAddresses sba, bool useFirstLevelBB) override{};
|
2022-07-06 21:23:03 +08:00
|
|
|
size_t getSbaTrackingCommandsSize(size_t trackedAddressCount) override {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t getSbaAddressLoadCommandsSize() override { return 0; };
|
2024-04-19 22:20:27 +08:00
|
|
|
void programSbaAddressLoad(NEO::LinearStream &cmdStream, uint64_t sbaGpuVa, bool isBcs) override{};
|
2022-07-06 21:23:03 +08:00
|
|
|
};
|
|
|
|
|
2020-07-27 23:37:51 +08:00
|
|
|
template <typename GfxFamily>
|
2022-06-15 05:24:58 +08:00
|
|
|
class MockDebuggerL0Hw : public NEO::DebuggerL0Hw<GfxFamily> {
|
2020-06-18 23:08:55 +08:00
|
|
|
public:
|
2022-06-15 05:24:58 +08:00
|
|
|
using NEO::DebuggerL0::perContextSbaAllocations;
|
|
|
|
using NEO::DebuggerL0::sbaTrackingGpuVa;
|
|
|
|
using NEO::DebuggerL0::singleAddressSpaceSbaTracking;
|
2022-07-22 20:07:36 +08:00
|
|
|
using NEO::DebuggerL0::uuidL0CommandQueueHandle;
|
2020-07-27 23:37:51 +08:00
|
|
|
|
2022-06-15 05:24:58 +08:00
|
|
|
MockDebuggerL0Hw(NEO::Device *device) : NEO::DebuggerL0Hw<GfxFamily>(device) {}
|
2020-07-27 23:37:51 +08:00
|
|
|
~MockDebuggerL0Hw() override = default;
|
|
|
|
|
2022-06-15 05:24:58 +08:00
|
|
|
static NEO::DebuggerL0 *allocate(NEO::Device *device) {
|
2020-07-27 23:37:51 +08:00
|
|
|
return new MockDebuggerL0Hw<GfxFamily>(device);
|
|
|
|
}
|
|
|
|
|
2022-11-23 04:07:45 +08:00
|
|
|
void captureStateBaseAddress(NEO::LinearStream &cmdStream, NEO::Debugger::SbaAddresses sba, bool useFirstLevelBB) override {
|
2020-07-27 23:37:51 +08:00
|
|
|
captureStateBaseAddressCount++;
|
2022-11-23 04:07:45 +08:00
|
|
|
NEO::DebuggerL0Hw<GfxFamily>::captureStateBaseAddress(cmdStream, sba, useFirstLevelBB);
|
2020-07-27 23:37:51 +08:00
|
|
|
}
|
2020-11-16 23:24:54 +08:00
|
|
|
|
|
|
|
size_t getSbaTrackingCommandsSize(size_t trackedAddressCount) override {
|
|
|
|
getSbaTrackingCommandsSizeCount++;
|
2022-06-15 05:24:58 +08:00
|
|
|
return NEO::DebuggerL0Hw<GfxFamily>::getSbaTrackingCommandsSize(trackedAddressCount);
|
2020-11-16 23:24:54 +08:00
|
|
|
}
|
|
|
|
|
2022-12-23 21:38:21 +08:00
|
|
|
void registerElfAndLinkWithAllocation(NEO::DebugData *debugData, NEO::GraphicsAllocation *isaAllocation) override {
|
|
|
|
registerElfAndLinkCount++;
|
|
|
|
lastReceivedElf = debugData->vIsa;
|
|
|
|
NEO::DebuggerL0Hw<GfxFamily>::registerElfAndLinkWithAllocation(debugData, isaAllocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t registerElf(NEO::DebugData *debugData) override {
|
2023-03-01 23:02:45 +08:00
|
|
|
registerElfCount++;
|
|
|
|
lastReceivedElf = debugData->vIsa;
|
2022-12-23 21:38:21 +08:00
|
|
|
if (elfHandleToReturn != std::numeric_limits<uint32_t>::max()) {
|
|
|
|
return elfHandleToReturn;
|
|
|
|
}
|
|
|
|
return NEO::DebuggerL0Hw<GfxFamily>::registerElf(debugData);
|
2021-12-29 00:44:13 +08:00
|
|
|
}
|
|
|
|
|
2022-12-23 21:38:21 +08:00
|
|
|
bool attachZebinModuleToSegmentAllocations(const StackVec<NEO::GraphicsAllocation *, 32> &allocs, uint32_t &moduleHandle, uint32_t elfHandle) override {
|
2022-02-10 00:07:36 +08:00
|
|
|
segmentCountWithAttachedModuleHandle = static_cast<uint32_t>(allocs.size());
|
|
|
|
if (std::numeric_limits<uint32_t>::max() != moduleHandleToReturn) {
|
|
|
|
moduleHandle = moduleHandleToReturn;
|
|
|
|
return true;
|
|
|
|
}
|
2022-12-23 21:38:21 +08:00
|
|
|
return NEO::DebuggerL0Hw<GfxFamily>::attachZebinModuleToSegmentAllocations(allocs, moduleHandle, elfHandle);
|
2022-02-10 00:07:36 +08:00
|
|
|
}
|
2022-02-10 19:13:59 +08:00
|
|
|
|
2022-02-10 00:07:36 +08:00
|
|
|
bool removeZebinModule(uint32_t moduleHandle) override {
|
|
|
|
removedZebinModuleHandle = moduleHandle;
|
2022-06-15 05:24:58 +08:00
|
|
|
return NEO::DebuggerL0Hw<GfxFamily>::removeZebinModule(moduleHandle);
|
2022-02-10 00:07:36 +08:00
|
|
|
}
|
|
|
|
|
2022-07-22 20:07:36 +08:00
|
|
|
void notifyCommandQueueCreated(NEO::Device *device) override {
|
2022-02-10 19:13:59 +08:00
|
|
|
commandQueueCreatedCount++;
|
2022-07-22 20:07:36 +08:00
|
|
|
NEO::DebuggerL0Hw<GfxFamily>::notifyCommandQueueCreated(device);
|
2022-02-10 19:13:59 +08:00
|
|
|
}
|
|
|
|
|
2022-07-22 20:07:36 +08:00
|
|
|
void notifyCommandQueueDestroyed(NEO::Device *device) override {
|
2022-02-10 19:13:59 +08:00
|
|
|
commandQueueDestroyedCount++;
|
2022-07-22 20:07:36 +08:00
|
|
|
NEO::DebuggerL0Hw<GfxFamily>::notifyCommandQueueDestroyed(device);
|
2022-02-10 19:13:59 +08:00
|
|
|
}
|
|
|
|
|
2022-07-05 21:40:15 +08:00
|
|
|
void registerAllocationType(NEO::GraphicsAllocation *allocation) override {
|
|
|
|
registerAllocationTypeCount++;
|
|
|
|
NEO::DebuggerL0Hw<GfxFamily>::registerAllocationType(allocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
void notifyModuleCreate(void *module, uint32_t moduleSize, uint64_t moduleLoadAddress) override {
|
|
|
|
notifyModuleCreateCount++;
|
|
|
|
NEO::DebuggerL0Hw<GfxFamily>::notifyModuleCreate(module, moduleSize, moduleLoadAddress);
|
|
|
|
}
|
|
|
|
|
2022-07-26 18:48:22 +08:00
|
|
|
void notifyModuleDestroy(uint64_t moduleLoadAddress) override {
|
|
|
|
notifyModuleDestroyCount++;
|
|
|
|
NEO::DebuggerL0Hw<GfxFamily>::notifyModuleDestroy(moduleLoadAddress);
|
|
|
|
}
|
|
|
|
|
2022-08-31 02:06:04 +08:00
|
|
|
void notifyModuleLoadAllocations(NEO::Device *device, const StackVec<NEO::GraphicsAllocation *, 32> &allocs) override {
|
|
|
|
notifyModuleLoadAllocationsCapturedDevice = device;
|
|
|
|
NEO::DebuggerL0Hw<GfxFamily>::notifyModuleLoadAllocations(device, allocs);
|
|
|
|
}
|
|
|
|
|
2020-07-27 23:37:51 +08:00
|
|
|
uint32_t captureStateBaseAddressCount = 0;
|
2020-11-16 23:24:54 +08:00
|
|
|
uint32_t getSbaTrackingCommandsSizeCount = 0;
|
2021-12-29 00:44:13 +08:00
|
|
|
uint32_t registerElfCount = 0;
|
2022-12-23 21:38:21 +08:00
|
|
|
uint32_t registerElfAndLinkCount = 0;
|
2022-02-10 19:13:59 +08:00
|
|
|
uint32_t commandQueueCreatedCount = 0;
|
|
|
|
uint32_t commandQueueDestroyedCount = 0;
|
2022-07-05 21:40:15 +08:00
|
|
|
uint32_t registerAllocationTypeCount = 0;
|
|
|
|
uint32_t notifyModuleCreateCount = 0;
|
2022-07-26 18:48:22 +08:00
|
|
|
uint32_t notifyModuleDestroyCount = 0;
|
2022-02-08 01:26:34 +08:00
|
|
|
const char *lastReceivedElf = nullptr;
|
2022-02-10 00:07:36 +08:00
|
|
|
|
|
|
|
uint32_t segmentCountWithAttachedModuleHandle = 0;
|
|
|
|
uint32_t removedZebinModuleHandle = 0;
|
|
|
|
uint32_t moduleHandleToReturn = std::numeric_limits<uint32_t>::max();
|
2022-12-23 21:38:21 +08:00
|
|
|
uint32_t elfHandleToReturn = std::numeric_limits<uint32_t>::max();
|
2022-08-31 02:06:04 +08:00
|
|
|
NEO::Device *notifyModuleLoadAllocationsCapturedDevice = nullptr;
|
2020-07-27 23:37:51 +08:00
|
|
|
};
|
|
|
|
|
2022-06-15 05:24:58 +08:00
|
|
|
template <>
|
|
|
|
struct WhiteBox<NEO::DebuggerL0> : public NEO::DebuggerL0 {
|
|
|
|
using BaseClass = NEO::DebuggerL0;
|
|
|
|
using BaseClass::initDebuggingInOs;
|
|
|
|
};
|
|
|
|
|
2020-07-27 23:37:51 +08:00
|
|
|
template <uint32_t productFamily, typename GfxFamily>
|
|
|
|
struct MockDebuggerL0HwPopulateFactory {
|
|
|
|
MockDebuggerL0HwPopulateFactory() {
|
2022-07-05 23:55:15 +08:00
|
|
|
mockDebuggerL0HwFactory[productFamily] = MockDebuggerL0Hw<GfxFamily>::allocate;
|
2020-07-27 23:37:51 +08:00
|
|
|
}
|
2020-06-18 23:08:55 +08:00
|
|
|
};
|
2022-07-05 21:40:15 +08:00
|
|
|
} // namespace NEO
|