All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dynamic_debug: allow to set dynamic debug flags right at module load time
@ 2010-05-26 12:25 Roman Fietze
  2010-05-26 18:35 ` Jason Baron
  0 siblings, 1 reply; 7+ messages in thread
From: Roman Fietze @ 2010-05-26 12:25 UTC (permalink / raw)
  To: Jason Baron; +Cc: linux-kernel

Hello Jason, hello list,

If I'm not wrong one could only enable any dynamic debugging flag
after a module had been completely loaded, using debugfs. This makes
it impossible to use dev_dbg or pr_debug e.g. inside the module init
function or any function called by it.

My patch works by replacing _DPRINTK_FLAGS_DEFAULT after including all
kernel headers in my module source file and some small patch inside
dynamic_debug.c setting up the internal variables already when loading
a module with flags unequal to zero. This patch can of course be
optimized somewhat by reusing existing variables.

Subject: [PATCH] dynamic_debug: allow to set dynamic debug flags right at module load time

This allows to use e.g. pr_debug right from the beginning, e.g. in the
module init function.

- the module must redefine _DPRINTK_FLAGS_DEFAULT, e.g.

  #undef _DPRINTK_FLAGS_DEFAULT
  #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT

- when a module is loaded and the flags are not zero, the enabled
  count and hash masks are enabled right away

Signed-off-by: Roman Fietze <roman.fietze@telemotive.de>
---
 lib/dynamic_debug.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index d6b8b9b..d10466e 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -656,6 +656,8 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
 {
 	struct ddebug_table *dt;
 	char *new_name;
+	size_t i;
+	char flagbuf[8];
 
 	dt = kzalloc(sizeof(*dt), GFP_KERNEL);
 	if (dt == NULL)
@@ -671,6 +673,22 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
 	dt->ddebugs = tab;
 
 	mutex_lock(&ddebug_lock);
+	for (i = 0 ; i < dt->num_ddebugs ; i++) {
+		struct _ddebug *dp = &dt->ddebugs[i];
+
+		if (dp->flags) {
+			dt->num_enabled++;
+			dynamic_debug_enabled |= (1LL << dp->primary_hash);
+			dynamic_debug_enabled2 |= (1LL << dp->secondary_hash);
+			if (verbose)
+				printk(KERN_INFO
+					"ddebug: added %s:%d [%s]%s %s\n",
+					dp->filename, dp->lineno,
+					dt->mod_name, dp->function,
+					ddebug_describe_flags(dp, flagbuf,
+							sizeof(flagbuf)));
+		}
+	}
 	list_add_tail(&dt->link, &ddebug_tables);
 	mutex_unlock(&ddebug_lock);
 
-- 
1.7.1


-- 
Roman Fietze                Telemotive AG Büro Mühlhausen
Breitwiesen                              73347 Mühlhausen
Tel.: +49(0)7335/18493-45        http://www.telemotive.de

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-07-02  8:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-26 12:25 [PATCH] dynamic_debug: allow to set dynamic debug flags right at module load time Roman Fietze
2010-05-26 18:35 ` Jason Baron
2010-05-27  5:05   ` Roman Fietze
2010-05-28 13:55     ` Jason Baron
2010-06-29 11:25       ` Roman Fietze
2010-07-01 20:43         ` Jason Baron
2010-07-02  8:16           ` [PATCH] dynamic_debug: parse module parameters to enable dynamic printk at " Roman Fietze

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.