SWDEV-517078 - Update 2nd level trap handlers (#148)
* SWDEV-517078 - Maintain the trap handler ABI version in CLR The trap handler ABI version is communicated to the debugger using the r_version field in the r_debug structure. This structure is an external dependency, which makes it complicated to keep the trap handler source (in CRL) and the ABI version number (external dependency) in sync. This patch proposes to patch the trap handler ABI version number in _amdgpu_r_debug before communicating it to the debugger. We can't directly include sc's executable.hpp file in CRL as it relies on conflicting definition of ELF related types, so instead we need to rely on a-priori knowledge on the r_debug structure. Fortunately, this structure is part of a stable ABI, so its layout is guaranteed to be kept stable. Update the 2nd level trap handler to follow updates from the ROCr-runtime. The trap handlers are stripped from parts dedicated to architectures unsupported by CLR. Bump the r_debug.r_version to track the ABI changes in the trap handler.
This commit is contained in:
@@ -866,6 +866,8 @@ Device::~Device() {
|
||||
|
||||
extern const char* SchedulerSourceCode;
|
||||
extern const char* SchedulerSourceCode20;
|
||||
|
||||
constexpr int TrapHandlerABIVersion = 10;
|
||||
extern const char* TrapHandlerCode;
|
||||
|
||||
// ================================================================================================
|
||||
@@ -1146,6 +1148,14 @@ bool Device::initializeHeapResources() {
|
||||
if (iDev()->Finalize(finalizeInfo) != Pal::Result::Success) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Override the _amdgpu_r_debug.r_version field with the trap handler
|
||||
// version. We can't import the definition of r_debug here as it would
|
||||
// conflict with ELF related definitions pulled-in by platform/program.hpp.
|
||||
// The layout of r_debug is a stable ABI, so we are guaranteed the
|
||||
// r_version field will always be at offset 0.
|
||||
*reinterpret_cast<int *> (_amdgpu_r_debug_ptr) = TrapHandlerABIVersion;
|
||||
|
||||
Pal::HipRuntimeSetup setup {.pRdebug = _amdgpu_r_debug_ptr,
|
||||
.runtimeState = 1, // Always valid debug state
|
||||
.ttmpSetupHint = GPU_DEBUG_ENABLE};
|
||||
|
||||
Reference in New Issue
Block a user