blob: 84d103c474e4d3bd7a3082c7e5ce76c483916740 [file] [log] [blame]
Jason Barone9d376f2009-02-05 11:51:38 -05001/*
2 * lib/dynamic_debug.c
3 *
4 * make pr_debug()/dev_dbg() calls runtime configurable based upon their
5 * source module.
6 *
7 * Copyright (C) 2008 Jason Baron <jbaron@redhat.com>
8 * By Greg Banks <gnb@melbourne.sgi.com>
9 * Copyright (c) 2008 Silicon Graphics Inc. All Rights Reserved.
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/kallsyms.h>
16#include <linux/version.h>
17#include <linux/types.h>
18#include <linux/mutex.h>
19#include <linux/proc_fs.h>
20#include <linux/seq_file.h>
21#include <linux/list.h>
22#include <linux/sysctl.h>
23#include <linux/ctype.h>
André Goddard Rosae7d28602009-12-14 18:01:06 -080024#include <linux/string.h>
Jason Barone9d376f2009-02-05 11:51:38 -050025#include <linux/uaccess.h>
26#include <linux/dynamic_debug.h>
27#include <linux/debugfs.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090028#include <linux/slab.h>
Jason Barone9d376f2009-02-05 11:51:38 -050029
30extern struct _ddebug __start___verbose[];
31extern struct _ddebug __stop___verbose[];
32
33/* dynamic_debug_enabled, and dynamic_debug_enabled2 are bitmasks in which
34 * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They
35 * use independent hash functions, to reduce the chance of false positives.
36 */
37long long dynamic_debug_enabled;
38EXPORT_SYMBOL_GPL(dynamic_debug_enabled);
39long long dynamic_debug_enabled2;
40EXPORT_SYMBOL_GPL(dynamic_debug_enabled2);
41
42struct ddebug_table {
43 struct list_head link;
44 char *mod_name;
45 unsigned int num_ddebugs;
46 unsigned int num_enabled;
47 struct _ddebug *ddebugs;
48};
49
50struct ddebug_query {
51 const char *filename;
52 const char *module;
53 const char *function;
54 const char *format;
55 unsigned int first_lineno, last_lineno;
56};
57
58struct ddebug_iter {
59 struct ddebug_table *table;
60 unsigned int idx;
61};
62
63static DEFINE_MUTEX(ddebug_lock);
64static LIST_HEAD(ddebug_tables);
65static int verbose = 0;
66
67/* Return the last part of a pathname */
68static inline const char *basename(const char *path)
69{
70 const char *tail = strrchr(path, '/');
71 return tail ? tail+1 : path;
72}
73
74/* format a string into buf[] which describes the _ddebug's flags */
75static char *ddebug_describe_flags(struct _ddebug *dp, char *buf,
76 size_t maxlen)
77{
78 char *p = buf;
79
80 BUG_ON(maxlen < 4);
81 if (dp->flags & _DPRINTK_FLAGS_PRINT)
82 *p++ = 'p';
83 if (p == buf)
84 *p++ = '-';
85 *p = '\0';
86
87 return buf;
88}
89
90/*
91 * must be called with ddebug_lock held
92 */
93
94static int disabled_hash(char hash, bool first_table)
95{
96 struct ddebug_table *dt;
97 char table_hash_value;
98
99 list_for_each_entry(dt, &ddebug_tables, link) {
100 if (first_table)
101 table_hash_value = dt->ddebugs->primary_hash;
102 else
103 table_hash_value = dt->ddebugs->secondary_hash;
104 if (dt->num_enabled && (hash == table_hash_value))
105 return 0;
106 }
107 return 1;
108}
109
110/*
111 * Search the tables for _ddebug's which match the given
112 * `query' and apply the `flags' and `mask' to them. Tells
113 * the user which ddebug's were changed, or whether none
114 * were matched.
115 */
116static void ddebug_change(const struct ddebug_query *query,
117 unsigned int flags, unsigned int mask)
118{
119 int i;
120 struct ddebug_table *dt;
121 unsigned int newflags;
122 unsigned int nfound = 0;
123 char flagbuf[8];
124
125 /* search for matching ddebugs */
126 mutex_lock(&ddebug_lock);
127 list_for_each_entry(dt, &ddebug_tables, link) {
128
129 /* match against the module name */
130 if (query->module != NULL &&
131 strcmp(query->module, dt->mod_name))
132 continue;
133
134 for (i = 0 ; i < dt->num_ddebugs ; i++) {
135 struct _ddebug *dp = &dt->ddebugs[i];
136
137 /* match against the source filename */
138 if (query->filename != NULL &&
139 strcmp(query->filename, dp->filename) &&
140 strcmp(query->filename, basename(dp->filename)))
141 continue;
142
143 /* match against the function */
144 if (query->function != NULL &&
145 strcmp(query->function, dp->function))
146 continue;
147
148 /* match against the format */
149 if (query->format != NULL &&
150 strstr(dp->format, query->format) == NULL)
151 continue;
152
153 /* match against the line number range */
154 if (query->first_lineno &&
155 dp->lineno < query->first_lineno)
156 continue;
157 if (query->last_lineno &&
158 dp->lineno > query->last_lineno)
159 continue;
160
161 nfound++;
162
163 newflags = (dp->flags & mask) | flags;
164 if (newflags == dp->flags)
165 continue;
166
167 if (!newflags)
168 dt->num_enabled--;
Roel Kluin4df7b3e2009-07-15 20:29:07 +0200169 else if (!dp->flags)
Jason Barone9d376f2009-02-05 11:51:38 -0500170 dt->num_enabled++;
171 dp->flags = newflags;
172 if (newflags) {
173 dynamic_debug_enabled |=
174 (1LL << dp->primary_hash);
175 dynamic_debug_enabled2 |=
176 (1LL << dp->secondary_hash);
177 } else {
178 if (disabled_hash(dp->primary_hash, true))
179 dynamic_debug_enabled &=
180 ~(1LL << dp->primary_hash);
181 if (disabled_hash(dp->secondary_hash, false))
182 dynamic_debug_enabled2 &=
183 ~(1LL << dp->secondary_hash);
184 }
185 if (verbose)
186 printk(KERN_INFO
187 "ddebug: changed %s:%d [%s]%s %s\n",
188 dp->filename, dp->lineno,
189 dt->mod_name, dp->function,
190 ddebug_describe_flags(dp, flagbuf,
191 sizeof(flagbuf)));
192 }
193 }
194 mutex_unlock(&ddebug_lock);
195
196 if (!nfound && verbose)
197 printk(KERN_INFO "ddebug: no matches for query\n");
198}
199
200/*
Jason Barone9d376f2009-02-05 11:51:38 -0500201 * Split the buffer `buf' into space-separated words.
Greg Banks9898abb2009-02-06 12:54:26 +1100202 * Handles simple " and ' quoting, i.e. without nested,
203 * embedded or escaped \". Return the number of words
204 * or <0 on error.
Jason Barone9d376f2009-02-05 11:51:38 -0500205 */
206static int ddebug_tokenize(char *buf, char *words[], int maxwords)
207{
208 int nwords = 0;
209
Greg Banks9898abb2009-02-06 12:54:26 +1100210 while (*buf) {
211 char *end;
212
213 /* Skip leading whitespace */
André Goddard Rosae7d28602009-12-14 18:01:06 -0800214 buf = skip_spaces(buf);
Greg Banks9898abb2009-02-06 12:54:26 +1100215 if (!*buf)
216 break; /* oh, it was trailing whitespace */
217
218 /* Run `end' over a word, either whitespace separated or quoted */
219 if (*buf == '"' || *buf == '\'') {
220 int quote = *buf++;
221 for (end = buf ; *end && *end != quote ; end++)
222 ;
223 if (!*end)
224 return -EINVAL; /* unclosed quote */
225 } else {
226 for (end = buf ; *end && !isspace(*end) ; end++)
227 ;
228 BUG_ON(end == buf);
229 }
230 /* Here `buf' is the start of the word, `end' is one past the end */
231
232 if (nwords == maxwords)
233 return -EINVAL; /* ran out of words[] before bytes */
234 if (*end)
235 *end++ = '\0'; /* terminate the word */
236 words[nwords++] = buf;
237 buf = end;
238 }
Jason Barone9d376f2009-02-05 11:51:38 -0500239
240 if (verbose) {
241 int i;
242 printk(KERN_INFO "%s: split into words:", __func__);
243 for (i = 0 ; i < nwords ; i++)
244 printk(" \"%s\"", words[i]);
245 printk("\n");
246 }
247
248 return nwords;
249}
250
251/*
252 * Parse a single line number. Note that the empty string ""
253 * is treated as a special case and converted to zero, which
254 * is later treated as a "don't care" value.
255 */
256static inline int parse_lineno(const char *str, unsigned int *val)
257{
258 char *end = NULL;
259 BUG_ON(str == NULL);
260 if (*str == '\0') {
261 *val = 0;
262 return 0;
263 }
264 *val = simple_strtoul(str, &end, 10);
265 return end == NULL || end == str || *end != '\0' ? -EINVAL : 0;
266}
267
268/*
269 * Undo octal escaping in a string, inplace. This is useful to
270 * allow the user to express a query which matches a format
271 * containing embedded spaces.
272 */
273#define isodigit(c) ((c) >= '0' && (c) <= '7')
274static char *unescape(char *str)
275{
276 char *in = str;
277 char *out = str;
278
279 while (*in) {
280 if (*in == '\\') {
281 if (in[1] == '\\') {
282 *out++ = '\\';
283 in += 2;
284 continue;
285 } else if (in[1] == 't') {
286 *out++ = '\t';
287 in += 2;
288 continue;
289 } else if (in[1] == 'n') {
290 *out++ = '\n';
291 in += 2;
292 continue;
293 } else if (isodigit(in[1]) &&
294 isodigit(in[2]) &&
295 isodigit(in[3])) {
296 *out++ = ((in[1] - '0')<<6) |
297 ((in[2] - '0')<<3) |
298 (in[3] - '0');
299 in += 4;
300 continue;
301 }
302 }
303 *out++ = *in++;
304 }
305 *out = '\0';
306
307 return str;
308}
309
310/*
311 * Parse words[] as a ddebug query specification, which is a series
312 * of (keyword, value) pairs chosen from these possibilities:
313 *
314 * func <function-name>
315 * file <full-pathname>
316 * file <base-filename>
317 * module <module-name>
318 * format <escaped-string-to-find-in-format>
319 * line <lineno>
320 * line <first-lineno>-<last-lineno> // where either may be empty
321 */
322static int ddebug_parse_query(char *words[], int nwords,
323 struct ddebug_query *query)
324{
325 unsigned int i;
326
327 /* check we have an even number of words */
328 if (nwords % 2 != 0)
329 return -EINVAL;
330 memset(query, 0, sizeof(*query));
331
332 for (i = 0 ; i < nwords ; i += 2) {
333 if (!strcmp(words[i], "func"))
334 query->function = words[i+1];
335 else if (!strcmp(words[i], "file"))
336 query->filename = words[i+1];
337 else if (!strcmp(words[i], "module"))
338 query->module = words[i+1];
339 else if (!strcmp(words[i], "format"))
340 query->format = unescape(words[i+1]);
341 else if (!strcmp(words[i], "line")) {
342 char *first = words[i+1];
343 char *last = strchr(first, '-');
344 if (last)
345 *last++ = '\0';
346 if (parse_lineno(first, &query->first_lineno) < 0)
347 return -EINVAL;
348 if (last != NULL) {
349 /* range <first>-<last> */
350 if (parse_lineno(last, &query->last_lineno) < 0)
351 return -EINVAL;
352 } else {
353 query->last_lineno = query->first_lineno;
354 }
355 } else {
356 if (verbose)
357 printk(KERN_ERR "%s: unknown keyword \"%s\"\n",
358 __func__, words[i]);
359 return -EINVAL;
360 }
361 }
362
363 if (verbose)
364 printk(KERN_INFO "%s: q->function=\"%s\" q->filename=\"%s\" "
365 "q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u\n",
366 __func__, query->function, query->filename,
367 query->module, query->format, query->first_lineno,
368 query->last_lineno);
369
370 return 0;
371}
372
373/*
374 * Parse `str' as a flags specification, format [-+=][p]+.
375 * Sets up *maskp and *flagsp to be used when changing the
376 * flags fields of matched _ddebug's. Returns 0 on success
377 * or <0 on error.
378 */
379static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
380 unsigned int *maskp)
381{
382 unsigned flags = 0;
383 int op = '=';
384
385 switch (*str) {
386 case '+':
387 case '-':
388 case '=':
389 op = *str++;
390 break;
391 default:
392 return -EINVAL;
393 }
394 if (verbose)
395 printk(KERN_INFO "%s: op='%c'\n", __func__, op);
396
397 for ( ; *str ; ++str) {
398 switch (*str) {
399 case 'p':
400 flags |= _DPRINTK_FLAGS_PRINT;
401 break;
402 default:
403 return -EINVAL;
404 }
405 }
406 if (flags == 0)
407 return -EINVAL;
408 if (verbose)
409 printk(KERN_INFO "%s: flags=0x%x\n", __func__, flags);
410
411 /* calculate final *flagsp, *maskp according to mask and op */
412 switch (op) {
413 case '=':
414 *maskp = 0;
415 *flagsp = flags;
416 break;
417 case '+':
418 *maskp = ~0U;
419 *flagsp = flags;
420 break;
421 case '-':
422 *maskp = ~flags;
423 *flagsp = 0;
424 break;
425 }
426 if (verbose)
427 printk(KERN_INFO "%s: *flagsp=0x%x *maskp=0x%x\n",
428 __func__, *flagsp, *maskp);
429 return 0;
430}
431
Thomas Renningerfd89cfb2010-08-06 16:11:01 +0200432static int ddebug_exec_query(char *query_string)
433{
434 unsigned int flags = 0, mask = 0;
435 struct ddebug_query query;
436#define MAXWORDS 9
437 int nwords;
438 char *words[MAXWORDS];
439
440 nwords = ddebug_tokenize(query_string, words, MAXWORDS);
441 if (nwords <= 0)
442 return -EINVAL;
443 if (ddebug_parse_query(words, nwords-1, &query))
444 return -EINVAL;
445 if (ddebug_parse_flags(words[nwords-1], &flags, &mask))
446 return -EINVAL;
447
448 /* actually go and implement the change */
449 ddebug_change(&query, flags, mask);
450 return 0;
451}
452
Jason Barone9d376f2009-02-05 11:51:38 -0500453/*
454 * File_ops->write method for <debugfs>/dynamic_debug/conrol. Gathers the
455 * command text from userspace, parses and executes it.
456 */
457static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
458 size_t len, loff_t *offp)
459{
Jason Barone9d376f2009-02-05 11:51:38 -0500460 char tmpbuf[256];
Thomas Renningerfd89cfb2010-08-06 16:11:01 +0200461 int ret;
Jason Barone9d376f2009-02-05 11:51:38 -0500462
463 if (len == 0)
464 return 0;
465 /* we don't check *offp -- multiple writes() are allowed */
466 if (len > sizeof(tmpbuf)-1)
467 return -E2BIG;
468 if (copy_from_user(tmpbuf, ubuf, len))
469 return -EFAULT;
470 tmpbuf[len] = '\0';
471 if (verbose)
472 printk(KERN_INFO "%s: read %d bytes from userspace\n",
473 __func__, (int)len);
474
Thomas Renningerfd89cfb2010-08-06 16:11:01 +0200475 ret = ddebug_exec_query(tmpbuf);
476 if (ret)
477 return ret;
Jason Barone9d376f2009-02-05 11:51:38 -0500478
479 *offp += len;
480 return len;
481}
482
483/*
484 * Set the iterator to point to the first _ddebug object
485 * and return a pointer to that first object. Returns
486 * NULL if there are no _ddebugs at all.
487 */
488static struct _ddebug *ddebug_iter_first(struct ddebug_iter *iter)
489{
490 if (list_empty(&ddebug_tables)) {
491 iter->table = NULL;
492 iter->idx = 0;
493 return NULL;
494 }
495 iter->table = list_entry(ddebug_tables.next,
496 struct ddebug_table, link);
497 iter->idx = 0;
498 return &iter->table->ddebugs[iter->idx];
499}
500
501/*
502 * Advance the iterator to point to the next _ddebug
503 * object from the one the iterator currently points at,
504 * and returns a pointer to the new _ddebug. Returns
505 * NULL if the iterator has seen all the _ddebugs.
506 */
507static struct _ddebug *ddebug_iter_next(struct ddebug_iter *iter)
508{
509 if (iter->table == NULL)
510 return NULL;
511 if (++iter->idx == iter->table->num_ddebugs) {
512 /* iterate to next table */
513 iter->idx = 0;
514 if (list_is_last(&iter->table->link, &ddebug_tables)) {
515 iter->table = NULL;
516 return NULL;
517 }
518 iter->table = list_entry(iter->table->link.next,
519 struct ddebug_table, link);
520 }
521 return &iter->table->ddebugs[iter->idx];
522}
523
524/*
525 * Seq_ops start method. Called at the start of every
526 * read() call from userspace. Takes the ddebug_lock and
527 * seeks the seq_file's iterator to the given position.
528 */
529static void *ddebug_proc_start(struct seq_file *m, loff_t *pos)
530{
531 struct ddebug_iter *iter = m->private;
532 struct _ddebug *dp;
533 int n = *pos;
534
535 if (verbose)
536 printk(KERN_INFO "%s: called m=%p *pos=%lld\n",
537 __func__, m, (unsigned long long)*pos);
538
539 mutex_lock(&ddebug_lock);
540
541 if (!n)
542 return SEQ_START_TOKEN;
543 if (n < 0)
544 return NULL;
545 dp = ddebug_iter_first(iter);
546 while (dp != NULL && --n > 0)
547 dp = ddebug_iter_next(iter);
548 return dp;
549}
550
551/*
552 * Seq_ops next method. Called several times within a read()
553 * call from userspace, with ddebug_lock held. Walks to the
554 * next _ddebug object with a special case for the header line.
555 */
556static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos)
557{
558 struct ddebug_iter *iter = m->private;
559 struct _ddebug *dp;
560
561 if (verbose)
562 printk(KERN_INFO "%s: called m=%p p=%p *pos=%lld\n",
563 __func__, m, p, (unsigned long long)*pos);
564
565 if (p == SEQ_START_TOKEN)
566 dp = ddebug_iter_first(iter);
567 else
568 dp = ddebug_iter_next(iter);
569 ++*pos;
570 return dp;
571}
572
573/*
574 * Seq_ops show method. Called several times within a read()
575 * call from userspace, with ddebug_lock held. Formats the
576 * current _ddebug as a single human-readable line, with a
577 * special case for the header line.
578 */
579static int ddebug_proc_show(struct seq_file *m, void *p)
580{
581 struct ddebug_iter *iter = m->private;
582 struct _ddebug *dp = p;
583 char flagsbuf[8];
584
585 if (verbose)
586 printk(KERN_INFO "%s: called m=%p p=%p\n",
587 __func__, m, p);
588
589 if (p == SEQ_START_TOKEN) {
590 seq_puts(m,
591 "# filename:lineno [module]function flags format\n");
592 return 0;
593 }
594
595 seq_printf(m, "%s:%u [%s]%s %s \"",
596 dp->filename, dp->lineno,
597 iter->table->mod_name, dp->function,
598 ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf)));
599 seq_escape(m, dp->format, "\t\r\n\"");
600 seq_puts(m, "\"\n");
601
602 return 0;
603}
604
605/*
606 * Seq_ops stop method. Called at the end of each read()
607 * call from userspace. Drops ddebug_lock.
608 */
609static void ddebug_proc_stop(struct seq_file *m, void *p)
610{
611 if (verbose)
612 printk(KERN_INFO "%s: called m=%p p=%p\n",
613 __func__, m, p);
614 mutex_unlock(&ddebug_lock);
615}
616
617static const struct seq_operations ddebug_proc_seqops = {
618 .start = ddebug_proc_start,
619 .next = ddebug_proc_next,
620 .show = ddebug_proc_show,
621 .stop = ddebug_proc_stop
622};
623
624/*
625 * File_ops->open method for <debugfs>/dynamic_debug/control. Does the seq_file
626 * setup dance, and also creates an iterator to walk the _ddebugs.
627 * Note that we create a seq_file always, even for O_WRONLY files
628 * where it's not needed, as doing so simplifies the ->release method.
629 */
630static int ddebug_proc_open(struct inode *inode, struct file *file)
631{
632 struct ddebug_iter *iter;
633 int err;
634
635 if (verbose)
636 printk(KERN_INFO "%s: called\n", __func__);
637
638 iter = kzalloc(sizeof(*iter), GFP_KERNEL);
639 if (iter == NULL)
640 return -ENOMEM;
641
642 err = seq_open(file, &ddebug_proc_seqops);
643 if (err) {
644 kfree(iter);
645 return err;
646 }
647 ((struct seq_file *) file->private_data)->private = iter;
648 return 0;
649}
650
651static const struct file_operations ddebug_proc_fops = {
652 .owner = THIS_MODULE,
653 .open = ddebug_proc_open,
654 .read = seq_read,
655 .llseek = seq_lseek,
656 .release = seq_release_private,
657 .write = ddebug_proc_write
658};
659
660/*
661 * Allocate a new ddebug_table for the given module
662 * and add it to the global list.
663 */
664int ddebug_add_module(struct _ddebug *tab, unsigned int n,
665 const char *name)
666{
667 struct ddebug_table *dt;
668 char *new_name;
669
670 dt = kzalloc(sizeof(*dt), GFP_KERNEL);
671 if (dt == NULL)
672 return -ENOMEM;
673 new_name = kstrdup(name, GFP_KERNEL);
674 if (new_name == NULL) {
675 kfree(dt);
676 return -ENOMEM;
677 }
678 dt->mod_name = new_name;
679 dt->num_ddebugs = n;
680 dt->num_enabled = 0;
681 dt->ddebugs = tab;
682
683 mutex_lock(&ddebug_lock);
684 list_add_tail(&dt->link, &ddebug_tables);
685 mutex_unlock(&ddebug_lock);
686
687 if (verbose)
688 printk(KERN_INFO "%u debug prints in module %s\n",
689 n, dt->mod_name);
690 return 0;
691}
692EXPORT_SYMBOL_GPL(ddebug_add_module);
693
694static void ddebug_table_free(struct ddebug_table *dt)
695{
696 list_del_init(&dt->link);
697 kfree(dt->mod_name);
698 kfree(dt);
699}
700
701/*
702 * Called in response to a module being unloaded. Removes
703 * any ddebug_table's which point at the module.
704 */
Yehuda Sadehff49d742010-07-03 13:07:35 +1000705int ddebug_remove_module(const char *mod_name)
Jason Barone9d376f2009-02-05 11:51:38 -0500706{
707 struct ddebug_table *dt, *nextdt;
708 int ret = -ENOENT;
709
710 if (verbose)
711 printk(KERN_INFO "%s: removing module \"%s\"\n",
712 __func__, mod_name);
713
714 mutex_lock(&ddebug_lock);
715 list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) {
716 if (!strcmp(dt->mod_name, mod_name)) {
717 ddebug_table_free(dt);
718 ret = 0;
719 }
720 }
721 mutex_unlock(&ddebug_lock);
722 return ret;
723}
724EXPORT_SYMBOL_GPL(ddebug_remove_module);
725
726static void ddebug_remove_all_tables(void)
727{
728 mutex_lock(&ddebug_lock);
729 while (!list_empty(&ddebug_tables)) {
730 struct ddebug_table *dt = list_entry(ddebug_tables.next,
731 struct ddebug_table,
732 link);
733 ddebug_table_free(dt);
734 }
735 mutex_unlock(&ddebug_lock);
736}
737
738static int __init dynamic_debug_init(void)
739{
740 struct dentry *dir, *file;
741 struct _ddebug *iter, *iter_start;
742 const char *modname = NULL;
743 int ret = 0;
744 int n = 0;
745
746 dir = debugfs_create_dir("dynamic_debug", NULL);
747 if (!dir)
748 return -ENOMEM;
749 file = debugfs_create_file("control", 0644, dir, NULL,
750 &ddebug_proc_fops);
751 if (!file) {
752 debugfs_remove(dir);
753 return -ENOMEM;
754 }
755 if (__start___verbose != __stop___verbose) {
756 iter = __start___verbose;
757 modname = iter->modname;
758 iter_start = iter;
759 for (; iter < __stop___verbose; iter++) {
760 if (strcmp(modname, iter->modname)) {
761 ret = ddebug_add_module(iter_start, n, modname);
762 if (ret)
763 goto out_free;
764 n = 0;
765 modname = iter->modname;
766 iter_start = iter;
767 }
768 n++;
769 }
770 ret = ddebug_add_module(iter_start, n, modname);
771 }
772out_free:
773 if (ret) {
774 ddebug_remove_all_tables();
775 debugfs_remove(dir);
776 debugfs_remove(file);
777 }
778 return 0;
779}
780module_init(dynamic_debug_init);