@@ -343,14 +343,18 @@ bool DebugSessionImp::writeResumeCommand(const std::vector<EuThread::ThreadId> &
343343 dword = 4 ;
344344 }
345345
346+ const auto regSize = std::max (getRegisterSize (registerType), hwInfo.capabilityTable .grfSize );
347+ auto reg = std::make_unique<uint32_t []>(regSize / sizeof (uint32_t ));
348+
346349 for (auto &threadID : threadIds) {
347- uint32_t reg[8 ] = {};
348350 auto apiThread = convertToApi (threadID);
349- if (readRegistersImp (apiThread, registerType, 0 , 1 , reg) != ZE_RESULT_SUCCESS) {
351+ memset (reg.get (), 0 , regSize);
352+
353+ if (readRegistersImp (apiThread, registerType, 0 , 1 , reg.get ()) != ZE_RESULT_SUCCESS) {
350354 success = false ;
351355 } else {
352356 reg[dword] |= sipResumeValue;
353- if (writeRegistersImp (apiThread, registerType, 0 , 1 , reg) != ZE_RESULT_SUCCESS) {
357+ if (writeRegistersImp (apiThread, registerType, 0 , 1 , reg. get () ) != ZE_RESULT_SUCCESS) {
354358 success = false ;
355359 }
356360 }
@@ -626,14 +630,16 @@ bool DebugSessionImp::isForceExceptionOrForceExternalHaltOnlyExceptionReason(uin
626630
627631void DebugSessionImp::fillResumeAndStoppedThreadsFromNewlyStopped (std::vector<EuThread::ThreadId> &resumeThreads, std::vector<EuThread::ThreadId> &stoppedThreadsToReport) {
628632
633+ const auto regSize = std::max (getRegisterSize (ZET_DEBUG_REGSET_TYPE_CR_INTEL_GPU), 64u );
634+ auto reg = std::make_unique<uint32_t []>(regSize / sizeof (uint32_t ));
635+
629636 for (auto &newlyStopped : newlyStoppedThreads) {
630637 if (allThreads[newlyStopped]->isStopped ()) {
631- uint32_t reg[8 ] = {};
632-
638+ memset (reg.get (), 0 , regSize);
633639 ze_device_thread_t apiThread = convertToApi (newlyStopped);
634- readRegistersImp (apiThread, ZET_DEBUG_REGSET_TYPE_CR_INTEL_GPU, 0 , 1 , reg);
640+ readRegistersImp (apiThread, ZET_DEBUG_REGSET_TYPE_CR_INTEL_GPU, 0 , 1 , reg. get () );
635641
636- if (isForceExceptionOrForceExternalHaltOnlyExceptionReason (reg)) {
642+ if (isForceExceptionOrForceExternalHaltOnlyExceptionReason (reg. get () )) {
637643 PRINT_DEBUGGER_THREAD_LOG (" RESUME accidentally stopped thread = %s\n " , allThreads[newlyStopped]->toString ().c_str ());
638644 resumeThreads.push_back (newlyStopped);
639645 } else {
@@ -727,7 +733,10 @@ const SIP::regset_desc *DebugSessionImp::getSbaRegsetDesc() {
727733const SIP::regset_desc *DebugSessionImp::typeToRegsetDesc (uint32_t type) {
728734 auto pStateSaveAreaHeader = getStateSaveAreaHeader ();
729735
730- UNRECOVERABLE_IF (pStateSaveAreaHeader == nullptr );
736+ DEBUG_BREAK_IF (pStateSaveAreaHeader == nullptr );
737+ if (pStateSaveAreaHeader == nullptr ) {
738+ return nullptr ;
739+ }
731740
732741 switch (type) {
733742 case ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU:
@@ -757,6 +766,14 @@ const SIP::regset_desc *DebugSessionImp::typeToRegsetDesc(uint32_t type) {
757766 }
758767}
759768
769+ uint32_t DebugSessionImp::getRegisterSize (uint32_t type) {
770+ auto regset = typeToRegsetDesc (type);
771+ if (regset) {
772+ return regset->bytes ;
773+ }
774+ return 0 ;
775+ }
776+
760777uint32_t DebugSessionImp::typeToRegsetFlags (uint32_t type) {
761778 switch (type) {
762779 case ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU:
@@ -806,8 +823,11 @@ ze_result_t DebugSessionImp::readSbaRegisters(ze_device_thread_t thread, uint32_
806823 return ret;
807824 }
808825
809- uint32_t r0[8 ];
810- ret = readRegistersImp (thread, ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU, 0 , 1 , r0);
826+ const auto &hwInfo = connectedDevice->getHwInfo ();
827+ const auto regSize = std::max (getRegisterSize (ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU), hwInfo.capabilityTable .grfSize );
828+ auto r0 = std::make_unique<uint32_t []>(regSize / sizeof (uint32_t ));
829+
830+ ret = readRegistersImp (thread, ZET_DEBUG_REGSET_TYPE_GRF_INTEL_GPU, 0 , 1 , r0.get ());
811831 if (ret != ZE_RESULT_SUCCESS) {
812832 return ret;
813833 }
0 commit comments