feature(debugger): Implement zetDebugGetThreadRegisterSetProperties (1/n)
Current SIP implementation has constant reg descs for all threads. Initial implementation of this API always returns same reg descs as the non-thread version of API. When SIP exposes per-thread reg descs, this API will be updated to expose them. Related-to: NEO-7370 Signed-off-by: Brandon Yates <brandon.yates@intel.com>
This commit is contained in:
parent
a5765a9d8c
commit
713f166d17
|
@ -217,6 +217,7 @@ zetGetDebugProcAddrTable(
|
|||
pDdiTable->pfnGetRegisterSetProperties = L0::zetDebugGetRegisterSetProperties;
|
||||
pDdiTable->pfnReadRegisters = L0::zetDebugReadRegisters;
|
||||
pDdiTable->pfnWriteRegisters = L0::zetDebugWriteRegisters;
|
||||
pDdiTable->pfnGetThreadRegisterSetProperties = L0::zetDebugGetThreadRegisterSetProperties;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -99,9 +99,27 @@ ze_result_t zetDebugWriteRegisters(
|
|||
void *pRegisterValues) {
|
||||
return L0::DebugApiHandlers::debugWriteRegisters(hDebug, thread, type, start, count, pRegisterValues);
|
||||
}
|
||||
|
||||
ze_result_t zetDebugGetThreadRegisterSetProperties(
|
||||
zet_debug_session_handle_t hDebug,
|
||||
ze_device_thread_t thread,
|
||||
uint32_t *pCount,
|
||||
zet_debug_regset_properties_t *pRegisterSetProperties) {
|
||||
return L0::DebugApiHandlers::debugGetThreadRegisterSetProperties(hDebug, thread, pCount, pRegisterSetProperties);
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
|
||||
extern "C" {
|
||||
|
||||
ZE_APIEXPORT ze_result_t ZE_APICALL zetDebugGetThreadRegisterSetProperties(
|
||||
zet_debug_session_handle_t hDebug,
|
||||
ze_device_thread_t thread,
|
||||
uint32_t *pCount,
|
||||
zet_debug_regset_properties_t *pRegisterSetProperties) {
|
||||
return L0::zetDebugGetThreadRegisterSetProperties(hDebug, thread, pCount, pRegisterSetProperties);
|
||||
}
|
||||
|
||||
ZE_APIEXPORT ze_result_t ZE_APICALL zetDeviceGetDebugProperties(
|
||||
zet_device_handle_t hDevice,
|
||||
zet_device_debug_properties_t *pDebugProperties) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -120,6 +120,10 @@ ze_result_t debugGetRegisterSetProperties(zet_device_handle_t hDevice, uint32_t
|
|||
return L0::DebugSession::getRegisterSetProperties(L0::Device::fromHandle(hDevice), pCount, pRegisterSetProperties);
|
||||
}
|
||||
|
||||
ze_result_t debugGetThreadRegisterSetProperties(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties) {
|
||||
return L0::DebugSession::fromHandle(hDebug)->getThreadRegisterSetProperties(thread, pCount, pRegisterSetProperties);
|
||||
}
|
||||
|
||||
ze_result_t debugReadRegisters(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) {
|
||||
return L0::DebugSession::fromHandle(hDebug)->readRegisters(thread, type, start, count, pRegisterValues);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -19,6 +19,7 @@ ze_result_t debugReadMemory(zet_debug_session_handle_t hDebug, ze_device_thread_
|
|||
ze_result_t debugWriteMemory(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, const zet_debug_memory_space_desc_t *desc, size_t size, const void *buffer);
|
||||
ze_result_t debugAcknowledgeEvent(zet_debug_session_handle_t hDebug, const zet_debug_event_t *event);
|
||||
ze_result_t debugGetRegisterSetProperties(zet_device_handle_t hDevice, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties);
|
||||
ze_result_t debugGetThreadRegisterSetProperties(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties);
|
||||
ze_result_t debugReadRegisters(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues);
|
||||
ze_result_t debugWriteRegisters(zet_debug_session_handle_t hDebug, ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues);
|
||||
} // namespace DebugApiHandlers
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -43,6 +43,7 @@ struct DebugSession : _zet_debug_session_handle_t {
|
|||
virtual ze_result_t readRegisters(ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) = 0;
|
||||
virtual ze_result_t writeRegisters(ze_device_thread_t thread, uint32_t type, uint32_t start, uint32_t count, void *pRegisterValues) = 0;
|
||||
static ze_result_t getRegisterSetProperties(Device *device, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties);
|
||||
virtual ze_result_t getThreadRegisterSetProperties(ze_device_thread_t thread, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties);
|
||||
MOCKABLE_VIRTUAL bool areRequestedThreadsStopped(ze_device_thread_t thread);
|
||||
|
||||
Device *getConnectedDevice() { return connectedDevice; }
|
||||
|
|
|
@ -1159,6 +1159,19 @@ ze_result_t DebugSessionImp::readSbaRegisters(EuThread::ThreadId threadId, uint3
|
|||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DebugSession::getThreadRegisterSetProperties(ze_device_thread_t thread, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties) {
|
||||
if (!isSingleThread(thread)) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
auto threadId = convertToThreadId(thread);
|
||||
|
||||
if (!allThreads[threadId]->isReportedAsStopped()) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return getRegisterSetProperties(this->connectedDevice, pCount, pRegisterSetProperties);
|
||||
}
|
||||
|
||||
ze_result_t DebugSession::getRegisterSetProperties(Device *device, uint32_t *pCount, zet_debug_regset_properties_t *pRegisterSetProperties) {
|
||||
if (nullptr == pCount) {
|
||||
return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
|
||||
|
|
|
@ -2241,6 +2241,38 @@ TEST_F(DebugSessionRegistersAccessTest, givenInvalidRegisterWhenGettingSizeThenZ
|
|||
EXPECT_EQ(0u, session->getRegisterSize(ZET_DEBUG_REGSET_TYPE_INVALID_INTEL_GPU));
|
||||
}
|
||||
|
||||
TEST_F(DebugSessionRegistersAccessTest, givenGetThreadRegisterSetPropertiesCalledWithInvalidThreadThenErrorIsReturned) {
|
||||
|
||||
uint32_t threadCount = 0;
|
||||
ze_device_thread_t thread = {UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX};
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, zetDebugGetThreadRegisterSetProperties(session->toHandle(), thread, &threadCount, nullptr));
|
||||
session->areRequestedThreadsStoppedReturnValue = 0;
|
||||
session->allThreads[stoppedThreadId]->resumeThread();
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, zetDebugGetThreadRegisterSetProperties(session->toHandle(), stoppedThread, &threadCount, nullptr));
|
||||
}
|
||||
|
||||
TEST_F(DebugSessionRegistersAccessTest, givenGetThreadRegisterSetPropertiesCalledPropertieAreTheSameAsgetRegisterSetProperties) {
|
||||
|
||||
auto mockBuiltins = new MockBuiltins();
|
||||
mockBuiltins->stateSaveAreaHeader = MockSipData::createStateSaveAreaHeader(2);
|
||||
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltins);
|
||||
|
||||
uint32_t count = 0;
|
||||
uint32_t threadCount = 0;
|
||||
ze_device_thread_t thread = stoppedThread;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zetDebugGetRegisterSetProperties(session->getConnectedDevice(), &count, nullptr));
|
||||
EXPECT_EQ(12u, count);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, zetDebugGetThreadRegisterSetProperties(session->toHandle(), thread, &threadCount, nullptr));
|
||||
ASSERT_EQ(threadCount, count);
|
||||
|
||||
std::vector<zet_debug_regset_properties_t> regsetProps(count);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, zetDebugGetRegisterSetProperties(session->getConnectedDevice(), &count, regsetProps.data()));
|
||||
std::vector<zet_debug_regset_properties_t> threadRegsetProps(count);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, zetDebugGetThreadRegisterSetProperties(session->toHandle(), thread, &count, threadRegsetProps.data()));
|
||||
|
||||
EXPECT_EQ(0, memcmp(regsetProps.data(), threadRegsetProps.data(), count * sizeof(zet_debug_regset_properties_t)));
|
||||
}
|
||||
|
||||
TEST_F(DebugSessionRegistersAccessTest, givenUnsupportedRegisterTypeWhenReadRegistersCalledThenErrorInvalidArgumentIsReturned) {
|
||||
session->areRequestedThreadsStoppedReturnValue = 1;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, zetDebugReadRegisters(session->toHandle(), stoppedThread, 0x12345, 0, 1, nullptr));
|
||||
|
|
Loading…
Reference in New Issue