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:
Chris Freehill
2020-12-21 16:16:43 -06:00
orang tua 7b5f220f76
melakukan 68095b50e7
2 mengubah file dengan 11 tambahan dan 0 penghapusan
+7
Melihat File
@@ -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.
+4
Melihat File
@@ -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
}