Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304052
b: refs/heads/master
c: b48420c
h: refs/heads/master
v: v3
  • Loading branch information
Jim Cromie authored and Greg Kroah-Hartman committed Apr 30, 2012
1 parent e13a0ac commit f619b46
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9fb48c744ba6a4bf58b666f4e6fdac3008ea1bd4
refs/heads/master: b48420c1d3019ce8d84fb8e58f4ca86b8e3655b8
17 changes: 17 additions & 0 deletions trunk/include/linux/dynamic_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ extern int ddebug_remove_module(const char *mod_name);
extern __printf(2, 3)
int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...);

extern int ddebug_dyndbg_module_param_cb(char *param, char *val,
const char *modname);

struct device;

extern __printf(3, 4)
Expand Down Expand Up @@ -94,11 +97,25 @@ do { \

#else

#include <linux/string.h>
#include <linux/errno.h>

static inline int ddebug_remove_module(const char *mod)
{
return 0;
}

static inline int ddebug_dyndbg_module_param_cb(char *param, char *val,
const char *modname)
{
if (strstr(param, "dyndbg")) {
pr_warn("dyndbg supported only in "
"CONFIG_DYNAMIC_DEBUG builds\n");
return 0; /* allow and ignore */
}
return -EINVAL;
}

#define dynamic_pr_debug(fmt, ...) \
do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0)
#define dynamic_dev_dbg(dev, fmt, ...) \
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2953,7 +2953,7 @@ static struct module *load_module(void __user *umod,

/* Module is ready to execute: parsing args may do that. */
err = parse_args(mod->name, mod->args, mod->kp, mod->num_kp,
-32768, 32767, NULL);
-32768, 32767, &ddebug_dyndbg_module_param_cb);
if (err < 0)
goto unlink;

Expand Down
49 changes: 49 additions & 0 deletions trunk/lib/dynamic_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,41 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
}
EXPORT_SYMBOL_GPL(ddebug_add_module);

/* handle both dyndbg=".." and $module.dyndbg=".." params at boot */
static int ddebug_dyndbg_boot_param_cb(char *param, char *val,
const char *unused)
{
const char *modname = NULL;
char *sep;

sep = strchr(param, '.');
if (sep) {
*sep = '\0';
modname = param;
param = sep + 1;
}
if (strcmp(param, "dyndbg"))
return 0; /* skip all other params w/o error */

vpr_info("module: %s %s=\"%s\"\n", modname, param, val);

ddebug_exec_queries(val ? val : "+p");
return 0; /* query failure shouldnt stop module load */
}

/* handle dyndbg args to modprobe */
int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *doing)
{
if (strcmp(param, "dyndbg"))
return -ENOENT;

vpr_info("module: %s %s=\"%s\"\n", doing, param, val);

ddebug_exec_queries((val ? val : "+p"));

return 0; /* query failure shouldnt stop module load */
}

static void ddebug_table_free(struct ddebug_table *dt)
{
list_del_init(&dt->link);
Expand Down Expand Up @@ -929,6 +964,7 @@ static int __init dynamic_debug_init(void)
{
struct _ddebug *iter, *iter_start;
const char *modname = NULL;
char *cmdline;
int ret = 0;
int n = 0;

Expand Down Expand Up @@ -967,6 +1003,18 @@ static int __init dynamic_debug_init(void)
/* keep tables even on ddebug_query parse error */
ret = 0;
}
/* now that ddebug tables are loaded, process all boot args
* again to find and activate queries given in dyndbg params.
* While this has already been done for known boot params, it
* ignored the unknown ones (dyndbg in particular). Reusing
* parse_args avoids ad-hoc parsing. This will also attempt
* to activate queries for not-yet-loaded modules, which is
* slightly noisy if verbose, but harmless.
*/
cmdline = kstrdup(saved_command_line, GFP_KERNEL);
parse_args("dyndbg params", cmdline, NULL,
0, 0, 0, &ddebug_dyndbg_boot_param_cb);
kfree(cmdline);

out_free:
if (ret)
Expand All @@ -977,5 +1025,6 @@ static int __init dynamic_debug_init(void)
}
/* Allow early initialization for boot messages via boot param */
arch_initcall(dynamic_debug_init);

/* Debugfs setup must be done later */
module_init(dynamic_debug_init_debugfs);

0 comments on commit f619b46

Please sign in to comment.