Skip to contentSkip to conversation

kdb: kdb_support: Fix debugging information problem

PATCH Superseded Stephen Zhang 2 participants 2 messages Jan 28, 2021 – Jan 29, 2021 KGDB / KDB /debug_core

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kdb: kdb_support: Fix debugging information problem

There are several common patterns.

0:

	kdb_printf("...",...);

which is the normal one.

1:

	kdb_printf("%s: "...,__func__,...)

We could improve '1' to this :

	#define kdb_func_printf(format, args...) \
		   kdb_printf("%s: " format, __func__, ## args)

2:

	if(KDB_DEBUG(AR))
		kdb_printf("%s "...,__func__,...);

We could improve '2' to this :

	#define kdb_dbg_printf(mask, format, args...) \
			   do { \
					if (KDB_DEBUG(mask)) \
						kdb_func_printf(format, ## args); \
			   } while (0)

In additon, we changed the format code of size_t to %zu.

---
v1->v2 Changelog:
- Add 'mask' parameter in kdb_dbg_printf()

Thanks to Daniel and Doug's suggestions and review.

 kernel/debug/kdb/kdb_private.h | 10 ++++++++
 kernel/debug/kdb/kdb_support.c | 56 +++++++++++++++++++-----------------------
 2 files changed, 35 insertions(+), 31 deletions(-)
kernel/debug/kdb/kdb_private.h +10 -0
index a4281fb..0a56d35 100644
@@ -254,4 +254,14 @@ extern unsigned long kdb_task_state(const struct task_struct *p,
 #define	KDB_WORD_SIZE	((int)sizeof(unsigned long))
 
 #endif /* CONFIG_KGDB_KDB */
+
+#define kdb_func_printf(format, args...) \
+	kdb_printf("%s: " format, __func__, ## args)
+
+#define kdb_dbg_printf(mask, format, args...) \
+	do { \
+		if (KDB_DEBUG(mask)) \
+			kdb_func_printf(format, ## args); \
+	} while (0)
+
 #endif	/* !_KDBPRIVATE_H */
kernel/debug/kdb/kdb_support.c +25 -31

140 lines not on this page · raw message

Signature · 1 line
1.8.3.1
reviewer Reviewed-by on v2 1/1
#1 lore raw

Hi,

kernel/debug/kdb/kdb_support.c line 43

Quoted 8 lines · Stephen Zhang

int kdbgetsymval(const char *symname, kdb_symtab_t *symtab) {

kernel/debug/kdb/kdb_support.c +2 -3
-       if (KDB_DEBUG(AR))
-               kdb_printf("kdbgetsymval: symname=%s, symtab=%px\n", symname,
-                          symtab);
+       kdb_dbg_printf(AR, "symname=%s, symtab=%px\n", symname,
+               symtab);

nit: in this file it seems like convention is that alignment for continued arguments is to match up with the first argument, so the line starting with "symtab" needs to be indented more to line up under "AR". Similar in some cases below.

kernel/debug/kdb/kdb_support.c line 49

Quoted 10 lines
        memset(symtab, 0, sizeof(*symtab));
        symtab->sym_start = kallsyms_lookup_name(symname);
        if (symtab->sym_start) {
kernel/debug/kdb/kdb_support.c +3 -4
-               if (KDB_DEBUG(AR))
-                       kdb_printf("kdbgetsymval: returns 1, "
-                                  "symtab->sym_start=0x%lx\n",
-                                  symtab->sym_start);
+               kdb_dbg_printf(AR, "returns 1, "
+                       "symtab->sym_start=0x%lx\n",
+                       symtab->sym_start);

nit: This doesn't need to be 3 lines anymore. Probably best is to stop splitting the string. In general the kernel convention considers it better to not split strings even if you have to make long lines, but in this case you won't even make a long line.

Other than those nits this looks really nice to me.