aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/dynamic_debug.c81
1 files changed, 35 insertions, 46 deletions
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 310c753cf83e..8675717c0f16 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -107,20 +107,22 @@ static char *ddebug_describe_flags(struct _ddebug *dp, char *buf,
107 return buf; 107 return buf;
108} 108}
109 109
110#define vpr_info_dq(q, msg) \ 110#define vpr_info(fmt, ...) \
111do { \ 111 if (verbose) do { pr_info(fmt, ##__VA_ARGS__); } while (0)
112 if (verbose) \ 112
113 /* trim last char off format print */ \ 113#define vpr_info_dq(q, msg) \
114 pr_info("%s: func=\"%s\" file=\"%s\" " \ 114do { \
115 "module=\"%s\" format=\"%.*s\" " \ 115 /* trim last char off format print */ \
116 "lineno=%u-%u", \ 116 vpr_info("%s: func=\"%s\" file=\"%s\" " \
117 msg, \ 117 "module=\"%s\" format=\"%.*s\" " \
118 q->function ? q->function : "", \ 118 "lineno=%u-%u", \
119 q->filename ? q->filename : "", \ 119 msg, \
120 q->module ? q->module : "", \ 120 q->function ? q->function : "", \
121 (int)(q->format ? strlen(q->format) - 1 : 0), \ 121 q->filename ? q->filename : "", \
122 q->format ? q->format : "", \ 122 q->module ? q->module : "", \
123 q->first_lineno, q->last_lineno); \ 123 (int)(q->format ? strlen(q->format) - 1 : 0), \
124 q->format ? q->format : "", \
125 q->first_lineno, q->last_lineno); \
124} while (0) 126} while (0)
125 127
126/* 128/*
@@ -180,12 +182,11 @@ static int ddebug_change(const struct ddebug_query *query,
180 if (newflags == dp->flags) 182 if (newflags == dp->flags)
181 continue; 183 continue;
182 dp->flags = newflags; 184 dp->flags = newflags;
183 if (verbose) 185 vpr_info("changed %s:%d [%s]%s =%s\n",
184 pr_info("changed %s:%d [%s]%s =%s\n", 186 trim_prefix(dp->filename), dp->lineno,
185 trim_prefix(dp->filename), dp->lineno, 187 dt->mod_name, dp->function,
186 dt->mod_name, dp->function, 188 ddebug_describe_flags(dp, flagbuf,
187 ddebug_describe_flags(dp, flagbuf, 189 sizeof(flagbuf)));
188 sizeof(flagbuf)));
189 } 190 }
190 } 191 }
191 mutex_unlock(&ddebug_lock); 192 mutex_unlock(&ddebug_lock);
@@ -410,8 +411,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
410 default: 411 default:
411 return -EINVAL; 412 return -EINVAL;
412 } 413 }
413 if (verbose) 414 vpr_info("op='%c'\n", op);
414 pr_info("op='%c'\n", op);
415 415
416 for ( ; *str ; ++str) { 416 for ( ; *str ; ++str) {
417 for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) { 417 for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) {
@@ -423,8 +423,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
423 if (i < 0) 423 if (i < 0)
424 return -EINVAL; 424 return -EINVAL;
425 } 425 }
426 if (verbose) 426 vpr_info("flags=0x%x\n", flags);
427 pr_info("flags=0x%x\n", flags);
428 427
429 /* calculate final *flagsp, *maskp according to mask and op */ 428 /* calculate final *flagsp, *maskp according to mask and op */
430 switch (op) { 429 switch (op) {
@@ -441,8 +440,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
441 *flagsp = 0; 440 *flagsp = 0;
442 break; 441 break;
443 } 442 }
444 if (verbose) 443 vpr_info("*flagsp=0x%x *maskp=0x%x\n", *flagsp, *maskp);
445 pr_info("*flagsp=0x%x *maskp=0x%x\n", *flagsp, *maskp);
446 return 0; 444 return 0;
447} 445}
448 446
@@ -487,8 +485,7 @@ static int ddebug_exec_queries(char *query)
487 if (!query || !*query || *query == '#') 485 if (!query || !*query || *query == '#')
488 continue; 486 continue;
489 487
490 if (verbose) 488 vpr_info("query %d: \"%s\"\n", i, query);
491 pr_info("query %d: \"%s\"\n", i, query);
492 489
493 rc = ddebug_exec_query(query); 490 rc = ddebug_exec_query(query);
494 if (rc < 0) { 491 if (rc < 0) {
@@ -498,7 +495,7 @@ static int ddebug_exec_queries(char *query)
498 nfound += rc; 495 nfound += rc;
499 i++; 496 i++;
500 } 497 }
501 pr_info("processed %d queries, with %d matches, %d errs\n", 498 vpr_info("processed %d queries, with %d matches, %d errs\n",
502 i, nfound, errs); 499 i, nfound, errs);
503 500
504 if (exitcode) 501 if (exitcode)
@@ -653,8 +650,7 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
653 return -EFAULT; 650 return -EFAULT;
654 } 651 }
655 tmpbuf[len] = '\0'; 652 tmpbuf[len] = '\0';
656 if (verbose) 653 vpr_info("read %d bytes from userspace\n", (int)len);
657 pr_info("read %d bytes from userspace\n", (int)len);
658 654
659 ret = ddebug_exec_queries(tmpbuf); 655 ret = ddebug_exec_queries(tmpbuf);
660 kfree(tmpbuf); 656 kfree(tmpbuf);
@@ -717,8 +713,7 @@ static void *ddebug_proc_start(struct seq_file *m, loff_t *pos)
717 struct _ddebug *dp; 713 struct _ddebug *dp;
718 int n = *pos; 714 int n = *pos;
719 715
720 if (verbose) 716 vpr_info("called m=%p *pos=%lld\n", m, (unsigned long long)*pos);
721 pr_info("called m=%p *pos=%lld\n", m, (unsigned long long)*pos);
722 717
723 mutex_lock(&ddebug_lock); 718 mutex_lock(&ddebug_lock);
724 719
@@ -742,9 +737,8 @@ static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos)
742 struct ddebug_iter *iter = m->private; 737 struct ddebug_iter *iter = m->private;
743 struct _ddebug *dp; 738 struct _ddebug *dp;
744 739
745 if (verbose) 740 vpr_info("called m=%p p=%p *pos=%lld\n",
746 pr_info("called m=%p p=%p *pos=%lld\n", 741 m, p, (unsigned long long)*pos);
747 m, p, (unsigned long long)*pos);
748 742
749 if (p == SEQ_START_TOKEN) 743 if (p == SEQ_START_TOKEN)
750 dp = ddebug_iter_first(iter); 744 dp = ddebug_iter_first(iter);
@@ -766,8 +760,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
766 struct _ddebug *dp = p; 760 struct _ddebug *dp = p;
767 char flagsbuf[10]; 761 char flagsbuf[10];
768 762
769 if (verbose) 763 vpr_info("called m=%p p=%p\n", m, p);
770 pr_info("called m=%p p=%p\n", m, p);
771 764
772 if (p == SEQ_START_TOKEN) { 765 if (p == SEQ_START_TOKEN) {
773 seq_puts(m, 766 seq_puts(m,
@@ -791,8 +784,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
791 */ 784 */
792static void ddebug_proc_stop(struct seq_file *m, void *p) 785static void ddebug_proc_stop(struct seq_file *m, void *p)
793{ 786{
794 if (verbose) 787 vpr_info("called m=%p p=%p\n", m, p);
795 pr_info("called m=%p p=%p\n", m, p);
796 mutex_unlock(&ddebug_lock); 788 mutex_unlock(&ddebug_lock);
797} 789}
798 790
@@ -815,8 +807,7 @@ static int ddebug_proc_open(struct inode *inode, struct file *file)
815 struct ddebug_iter *iter; 807 struct ddebug_iter *iter;
816 int err; 808 int err;
817 809
818 if (verbose) 810 vpr_info("called\n");
819 pr_info("called\n");
820 811
821 iter = kzalloc(sizeof(*iter), GFP_KERNEL); 812 iter = kzalloc(sizeof(*iter), GFP_KERNEL);
822 if (iter == NULL) 813 if (iter == NULL)
@@ -866,8 +857,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
866 list_add_tail(&dt->link, &ddebug_tables); 857 list_add_tail(&dt->link, &ddebug_tables);
867 mutex_unlock(&ddebug_lock); 858 mutex_unlock(&ddebug_lock);
868 859
869 if (verbose) 860 vpr_info("%u debug prints in module %s\n", n, dt->mod_name);
870 pr_info("%u debug prints in module %s\n", n, dt->mod_name);
871 return 0; 861 return 0;
872} 862}
873EXPORT_SYMBOL_GPL(ddebug_add_module); 863EXPORT_SYMBOL_GPL(ddebug_add_module);
@@ -888,8 +878,7 @@ int ddebug_remove_module(const char *mod_name)
888 struct ddebug_table *dt, *nextdt; 878 struct ddebug_table *dt, *nextdt;
889 int ret = -ENOENT; 879 int ret = -ENOENT;
890 880
891 if (verbose) 881 vpr_info("removing module \"%s\"\n", mod_name);
892 pr_info("removing module \"%s\"\n", mod_name);
893 882
894 mutex_lock(&ddebug_lock); 883 mutex_lock(&ddebug_lock);
895 list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) { 884 list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) {