[PATCH v7 22/25] dyndbg: improve err report in attach_user_module_classes

From: Jim Cromie
Date: Thu Oct 12 2023 - 13:24:08 EST


convert a WARN on 3 conditions, into BUG_ON 2 of them (which don't
happen), and an early return on (!cli->user_mod_name), which *was*
happening, so should be seen going forward. Maybe this should be a
WARN.

NB: The underlying problem was a missing __align(8) in the
DYNDBG_CLASSMAP_USE, which manifested as a corrupt record with a map
pointer which segv'd.

Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
---
lib/dynamic_debug.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 974395bf8a83..3dc512fb1d66 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -1284,9 +1284,11 @@ static void ddebug_attach_user_module_classes(struct ddebug_table *dt,
*/
for_each_boxed_vector(di, class_users, num_class_users, i, cli) {

- if (WARN_ON(!cli || !cli->map || !cli->user_mod_name))
- continue;
-
+ BUG_ON(!cli || !cli->map);
+ if (!cli->user_mod_name) {
+ pr_warn("class_ref[%d] !user-mod-name looking for %s\n", i, dt->mod_name);
+ return;
+ }
if (!strcmp(cli->user_mod_name, dt->mod_name)) {

vpr_cm_info(cli->map, "class_ref[%d] %s -> %s", i,
--
2.41.0