Skip to contentSkip to conversation

kdb: kdb_support: Fix debugging information problem

PATCH In review Stephen Zhang 2 participants 2 messages Feb 4, 2021 KGDB / KDB /debug_core

lore
Share & tools
lore
#0 lore raw

PATCH v4 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.

v2->v4 Changelog:
- Adjust alignment for some lines.

Suggested by Douglas Anderson.

 kernel/debug/kdb/kdb_private.h | 10 ++++++++
 kernel/debug/kdb/kdb_support.c | 53 ++++++++++++++++--------------------------
 2 files changed, 30 insertions(+), 33 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 +20 -33

136 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 16 lines · Stephen Zhang

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:

Quoted 8 lines
        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); \

This line is picked up by checkpatch as being overlong.

Quoted 3 lines
                           } while (0)

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

Should be addition.

Quoted 1 line

It is arguable that there should be a Reviewed-by: from Doug here... although given the big changes in v3 I don't think you were wrong to drop it.

Nevertheless... given the implicit R-b ("when Daniel merges") in Doug's comments on v3 I decided to reinstate it.

No action needed from you on this. I have fixed up all these issues when I applied the patch. Thanks!

Daniel.