Skip to content

Commit 6f710bf

Browse files
L0Debug - disallow attaching to multiple pids
Resolves: NEO-7476 Signed-off-by: Mateusz Hoppe <[email protected]>
1 parent 9a4467f commit 6f710bf

File tree

7 files changed

+443
-348
lines changed

7 files changed

+443
-348
lines changed

level_zero/tools/source/debug/debug_handlers.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ ze_result_t debugAttach(zet_device_handle_t hDevice, const zet_debug_config_t *c
3838

3939
auto rootSession = L0::Device::fromHandle(hDevice)->getNEODevice()->getRootDevice()->getSpecializedDevice<DeviceImp>()->getDebugSession(*config);
4040

41+
if (session && session->isAttached()) {
42+
if (session->getDebugConfig().pid != config->pid) {
43+
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
44+
}
45+
}
46+
47+
if (rootSession) {
48+
if (rootSession->getDebugConfig().pid != config->pid) {
49+
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
50+
}
51+
}
52+
4153
// If root device with active TileSessions or
4254
// subdevice with root device attached - fail
4355
if ((!L0::Device::fromHandle(hDevice)->getNEODevice()->isSubDevice() && session && !session->areAllTileDebugSessionDetached()) ||

level_zero/tools/source/debug/debug_session.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct DebugSession : _zet_debug_session_handle_t {
4646
MOCKABLE_VIRTUAL bool areRequestedThreadsStopped(ze_device_thread_t thread);
4747

4848
Device *getConnectedDevice() { return connectedDevice; }
49+
zet_debug_config_t getDebugConfig() { return config; }
4950

5051
static bool isThreadAll(ze_device_thread_t thread) {
5152
return thread.slice == UINT32_MAX && thread.subslice == UINT32_MAX && thread.eu == UINT32_MAX && thread.thread == UINT32_MAX;
@@ -129,6 +130,7 @@ struct DebugSession : _zet_debug_session_handle_t {
129130
NEO::DebugAreaHeader debugArea;
130131

131132
Device *connectedDevice = nullptr;
133+
const zet_debug_config_t config;
132134
std::map<uint64_t, std::unique_ptr<EuThread>> allThreads;
133135
bool attached = false;
134136
};

level_zero/tools/source/debug/debug_session_imp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
namespace L0 {
2121

22-
DebugSession::DebugSession(const zet_debug_config_t &config, Device *device) : connectedDevice(device) {
22+
DebugSession::DebugSession(const zet_debug_config_t &config, Device *device) : connectedDevice(device), config(config) {
2323
}
2424

2525
const NEO::TopologyMap &DebugSession::getTopologyMap() {

level_zero/tools/source/debug/linux/prelim/debug_session.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ void DebugSessionLinux::createTileSessionsIfEnabled() {
297297
auto numTiles = connectedDevice->getNEODevice()->getNumSubDevices();
298298
if (numTiles > 0 && tileAttachEnabled) {
299299
tileSessions.resize(numTiles);
300-
zet_debug_config_t config = {};
301300

302301
for (uint32_t i = 0; i < numTiles; i++) {
303302
auto subDevice = connectedDevice->getNEODevice()->getSubDevice(i)->getSpecializedDevice<Device>();

0 commit comments

Comments
 (0)