Introduce RSMI_DEBUG_INFINITE_LOOP
The environment variable RSMI_DEBUG_INFINITE_LOOP is introduced to facilitate debugging RSMI in user applications. When this env. variable is non-zero, an infinite loop will be entered in rsmi_init(). At this point, a debugger can be attached and RSMI can be debugger. This only applies to debug builds. Change-Id: I23f6dd730fc965764295070de053314a1cc5b6aa
This commit is contained in:
@@ -143,6 +143,13 @@ struct rsmi_func_id_iter_handle {
|
||||
};
|
||||
|
||||
struct RocmSMI_env_vars {
|
||||
// If RSMI_DEBUG_INFINITE_LOOP is non-zero, rsmi_init() will go into
|
||||
// an infinite loop in debug builds. For release builds, this is
|
||||
// ignored. This is useful for debugging RSMI applications with
|
||||
// gdb. After attaching with gdb, the inf. loop can be exited and
|
||||
// RSMI can be debugged.
|
||||
uint32_t debug_inf_loop;
|
||||
|
||||
// Bitfield that is AND'd with various RSMI_DEBUG_* bits to determine
|
||||
// which debugging information should be turned on. Env. variable
|
||||
// RSMI_DEBUG_BITFIELD is used to set all the debug info bits.
|
||||
|
||||
@@ -258,6 +258,8 @@ RocmSMI::Initialize(uint64_t flags) {
|
||||
|
||||
GetEnvVariables();
|
||||
|
||||
while (env_vars_.debug_inf_loop) {}
|
||||
|
||||
while (std::string(kAMDMonitorTypes[i]) != "") {
|
||||
amd_monitor_types_.insert(kAMDMonitorTypes[i]);
|
||||
++i;
|
||||
@@ -386,12 +388,14 @@ void RocmSMI::GetEnvVariables(void) {
|
||||
env_vars_.path_HWMon_root_override = nullptr;
|
||||
env_vars_.path_power_root_override = nullptr;
|
||||
env_vars_.enum_override = 0;
|
||||
env_vars_.debug_inf_loop = 0;
|
||||
#else
|
||||
env_vars_.debug_output_bitfield = GetEnvVarUInteger("RSMI_DEBUG_BITFIELD");
|
||||
env_vars_.path_DRM_root_override = getenv("RSMI_DEBUG_DRM_ROOT_OVERRIDE");
|
||||
env_vars_.path_HWMon_root_override = getenv("RSMI_DEBUG_HWMON_ROOT_OVERRIDE");
|
||||
env_vars_.path_power_root_override = getenv("RSMI_DEBUG_PP_ROOT_OVERRIDE");
|
||||
env_vars_.enum_override = GetEnvVarUInteger("RSMI_DEBUG_ENUM_OVERRIDE");
|
||||
env_vars_.debug_inf_loop = GetEnvVarUInteger("RSMI_DEBUG_INFINITE_LOOP");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user