From 8f9a20738e8537aacd3b1d3c02f9f46ddd2cfdcf Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Wed, 21 Feb 2024 18:24:38 -0500 Subject: [PATCH] SWDEV-404889 - Don't report trap handler Trap handler shouldn't be reported for debugger and RGP Change-Id: I149dacfed49584503c1874120d5f552fdec323a7 --- rocclr/device/devprogram.hpp | 4 ++++ rocclr/device/pal/palprogram.cpp | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/rocclr/device/devprogram.hpp b/rocclr/device/devprogram.hpp index 6b71fb8360..3089b1827c 100644 --- a/rocclr/device/devprogram.hpp +++ b/rocclr/device/devprogram.hpp @@ -131,6 +131,7 @@ class Program : public amd::HeapObject { uint32_t hasGlobalStores_ : 1; //!< Program has writable program scope variables uint32_t isHIP_ : 1; //!< Determine if the program is for HIP uint32_t coLoaded_ : 1; //!< Has the code objected been loaded + uint32_t trapHandler_ : 1; //!< It is a trap handler for debugger }; uint32_t flags_; //!< Program flags }; @@ -263,6 +264,9 @@ class Program : public amd::HeapObject { //! Return TRUE if the program has been loaded bool isCodeObjectLoaded() const { return coLoaded_; } + //! Returns TRUE if the program is a trap handler for debugger support + bool isTrapHandler() const { return trapHandler_; } + #if defined(USE_COMGR_LIBRARY) amd_comgr_metadata_node_t metadata() const { return metadata_; } diff --git a/rocclr/device/pal/palprogram.cpp b/rocclr/device/pal/palprogram.cpp index 3415e3ddcf..d70e3df9cc 100644 --- a/rocclr/device/pal/palprogram.cpp +++ b/rocclr/device/pal/palprogram.cpp @@ -782,7 +782,13 @@ bool LightningProgram::createKernels(void* binary, size_t binSize, bool useUnifo return false; } - status = loader_->FreezeExecutable(executable_, nullptr); + if (isInternal() && (owner()->language() == amd::Program::Assembly)) { + // Don't register trap handler with the debugger, since user shouldn't see this kernel + status = executable_->Freeze(nullptr); + trapHandler_ = true; + } else { + status = loader_->FreezeExecutable(executable_, nullptr); + } if (status != HSA_STATUS_SUCCESS) { LogError("Error: Freezing the executable failed."); return false; @@ -795,8 +801,8 @@ bool LightningProgram::createKernels(void* binary, size_t binSize, bool useUnifo bool LightningProgram::setKernels(void* binary, size_t binSize, amd::Os::FileDesc fdesc, size_t foffset, std::string uri) { #if defined(USE_COMGR_LIBRARY) - // Collect the information about compiled binary - if (!isNull() && (palDevice().rgpCaptureMgr() != nullptr)) { + // Collect the information about compiled binary, except the trap handler + if (!isNull() && (palDevice().rgpCaptureMgr() != nullptr) && !isTrapHandler()) { apiHash_ = palDevice().rgpCaptureMgr()->AddElfBinary( binary, binSize, binary, binSize, codeSegGpu_->iMem(), codeSegGpu_->offset()); }