Lines Matching +full:rc +full:- +full:map +full:- +full:name
78 …"( 0 = off (default), 1 = module add/rm, 2 = >control summary, 3 = parsing, 4 = per-site changes)"…
83 int skip = strlen(__FILE__) - strlen("lib/dynamic_debug.c"); in trim_prefix()
106 char *p = fb->buf; in ddebug_describe_flags()
112 if (p == fb->buf) in ddebug_describe_flags()
116 return fb->buf; in ddebug_describe_flags()
135 if (query->format) { in vpr_info_dq()
136 fmtlen = strlen(query->format); in vpr_info_dq()
137 while (fmtlen && query->format[fmtlen - 1] == '\n') in vpr_info_dq()
138 fmtlen--; in vpr_info_dq()
141 v3pr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u class=%s\n", in vpr_info_dq()
143 query->function ?: "", in vpr_info_dq()
144 query->filename ?: "", in vpr_info_dq()
145 query->module ?: "", in vpr_info_dq()
146 fmtlen, query->format ?: "", in vpr_info_dq()
147 query->first_lineno, query->last_lineno, query->class_string); in vpr_info_dq()
153 struct ddebug_class_map *map; in ddebug_find_valid_class() local
156 list_for_each_entry(map, &dt->maps, link) { in ddebug_find_valid_class()
157 idx = match_string(map->class_names, map->length, class_string); in ddebug_find_valid_class()
159 *class_id = idx + map->base; in ddebug_find_valid_class()
160 return map; in ddebug_find_valid_class()
163 *class_id = -ENOENT; in ddebug_find_valid_class()
182 struct ddebug_class_map *map = NULL; in ddebug_change() local
189 /* match against the module name */ in ddebug_change()
190 if (query->module && in ddebug_change()
191 !match_wildcard(query->module, dt->mod_name)) in ddebug_change()
194 if (query->class_string) { in ddebug_change()
195 map = ddebug_find_valid_class(dt, query->class_string, &valid_class); in ddebug_change()
196 if (!map) in ddebug_change()
203 for (i = 0; i < dt->num_ddebugs; i++) { in ddebug_change()
204 struct _ddebug *dp = &dt->ddebugs[i]; in ddebug_change()
206 /* match site against query-class */ in ddebug_change()
207 if (dp->class_id != valid_class) in ddebug_change()
211 if (query->filename && in ddebug_change()
212 !match_wildcard(query->filename, dp->filename) && in ddebug_change()
213 !match_wildcard(query->filename, in ddebug_change()
214 kbasename(dp->filename)) && in ddebug_change()
215 !match_wildcard(query->filename, in ddebug_change()
216 trim_prefix(dp->filename))) in ddebug_change()
220 if (query->function && in ddebug_change()
221 !match_wildcard(query->function, dp->function)) in ddebug_change()
225 if (query->format) { in ddebug_change()
226 if (*query->format == '^') { in ddebug_change()
229 p = strstr(dp->format, query->format+1); in ddebug_change()
230 if (p != dp->format) in ddebug_change()
232 } else if (!strstr(dp->format, query->format)) in ddebug_change()
237 if (query->first_lineno && in ddebug_change()
238 dp->lineno < query->first_lineno) in ddebug_change()
240 if (query->last_lineno && in ddebug_change()
241 dp->lineno > query->last_lineno) in ddebug_change()
246 newflags = (dp->flags & modifiers->mask) | modifiers->flags; in ddebug_change()
247 if (newflags == dp->flags) in ddebug_change()
250 if (dp->flags & _DPRINTK_FLAGS_PRINT) { in ddebug_change()
252 static_branch_disable(&dp->key.dd_key_true); in ddebug_change()
254 static_branch_enable(&dp->key.dd_key_true); in ddebug_change()
258 trim_prefix(dp->filename), dp->lineno, in ddebug_change()
259 dt->mod_name, dp->function, in ddebug_change()
260 ddebug_describe_flags(dp->flags, &fbuf), in ddebug_change()
262 dp->flags = newflags; in ddebug_change()
274 * Split the buffer `buf' into space-separated words.
300 return -EINVAL; /* unclosed quote */ in ddebug_tokenize()
307 nwords ? words[nwords - 1] : "<none>"); in ddebug_tokenize()
308 return -EINVAL; in ddebug_tokenize()
315 return -EINVAL; /* ran out of words[] before bytes */ in ddebug_tokenize()
347 pr_err("bad line-number: %s\n", str); in parse_lineno()
348 return -EINVAL; in parse_lineno()
355 char *last = strchr(first, '-'); in parse_linerange()
357 if (query->first_lineno || query->last_lineno) { in parse_linerange()
358 pr_err("match-spec: line used 2x\n"); in parse_linerange()
359 return -EINVAL; in parse_linerange()
363 if (parse_lineno(first, &query->first_lineno) < 0) in parse_linerange()
364 return -EINVAL; in parse_linerange()
366 /* range <first>-<last> */ in parse_linerange()
367 if (parse_lineno(last, &query->last_lineno) < 0) in parse_linerange()
368 return -EINVAL; in parse_linerange()
371 if (query->last_lineno == 0) in parse_linerange()
372 query->last_lineno = UINT_MAX; in parse_linerange()
374 if (query->last_lineno < query->first_lineno) { in parse_linerange()
375 pr_err("last-line:%d < 1st-line:%d\n", in parse_linerange()
376 query->last_lineno, in parse_linerange()
377 query->first_lineno); in parse_linerange()
378 return -EINVAL; in parse_linerange()
381 query->last_lineno = query->first_lineno; in parse_linerange()
383 v3pr_info("parsed line %d-%d\n", query->first_lineno, in parse_linerange()
384 query->last_lineno); in parse_linerange()
388 static int check_set(const char **dest, char *src, char *name) in check_set() argument
390 int rc = 0; in check_set() local
393 rc = -EINVAL; in check_set()
394 pr_err("match-spec:%s val:%s overridden by %s\n", in check_set()
395 name, *dest, src); in check_set()
398 return rc; in check_set()
405 * func <function-name>
406 * file <full-pathname>
407 * file <base-filename>
408 * module <module-name>
409 * format <escaped-string-to-find-in-format>
411 * line <first-lineno>-<last-lineno> // where either may be empty
420 int rc = 0; in ddebug_parse_query() local
425 pr_err("expecting pairs of match-spec <value>\n"); in ddebug_parse_query()
426 return -EINVAL; in ddebug_parse_query()
434 rc = check_set(&query->function, arg, "func"); in ddebug_parse_query()
436 if (check_set(&query->filename, arg, "file")) in ddebug_parse_query()
437 return -EINVAL; in ddebug_parse_query()
439 /* tail :$info is function or line-range */ in ddebug_parse_query()
440 fline = strchr(query->filename, ':'); in ddebug_parse_query()
445 /* take as function name */ in ddebug_parse_query()
446 if (check_set(&query->function, fline, "func")) in ddebug_parse_query()
447 return -EINVAL; in ddebug_parse_query()
450 return -EINVAL; in ddebug_parse_query()
453 rc = check_set(&query->module, arg, "module"); in ddebug_parse_query()
458 rc = check_set(&query->format, arg, "format"); in ddebug_parse_query()
461 return -EINVAL; in ddebug_parse_query()
463 rc = check_set(&query->class_string, arg, "class"); in ddebug_parse_query()
466 return -EINVAL; in ddebug_parse_query()
468 if (rc) in ddebug_parse_query()
469 return rc; in ddebug_parse_query()
471 if (!query->module && modname) in ddebug_parse_query()
476 query->module = modname; in ddebug_parse_query()
483 * Parse `str' as a flags specification, format [-+=][p]+.
494 case '-': in ddebug_parse_flags()
499 pr_err("bad flag-op %c, at start of %s\n", *str, str); in ddebug_parse_flags()
500 return -EINVAL; in ddebug_parse_flags()
505 for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) { in ddebug_parse_flags()
507 modifiers->flags |= opt_array[i].flag; in ddebug_parse_flags()
513 return -EINVAL; in ddebug_parse_flags()
516 v3pr_info("flags=0x%x\n", modifiers->flags); in ddebug_parse_flags()
521 /* modifiers->flags already set */ in ddebug_parse_flags()
522 modifiers->mask = 0; in ddebug_parse_flags()
525 modifiers->mask = ~0U; in ddebug_parse_flags()
527 case '-': in ddebug_parse_flags()
528 modifiers->mask = ~modifiers->flags; in ddebug_parse_flags()
529 modifiers->flags = 0; in ddebug_parse_flags()
532 v3pr_info("*flagsp=0x%x *maskp=0x%x\n", modifiers->flags, modifiers->mask); in ddebug_parse_flags()
548 return -EINVAL; in ddebug_exec_query()
551 if (ddebug_parse_flags(words[nwords-1], &modifiers)) { in ddebug_exec_query()
553 return -EINVAL; in ddebug_exec_query()
555 if (ddebug_parse_query(words, nwords-1, &query, modname)) { in ddebug_exec_query()
557 return -EINVAL; in ddebug_exec_query()
561 vpr_info_dq(&query, nfound ? "applied" : "no-match"); in ddebug_exec_query()
567 last error or number of matching callsites. Module name is either
573 int i, errs = 0, exitcode = 0, rc, nfound = 0; in ddebug_exec_queries() local
586 rc = ddebug_exec_query(query, modname); in ddebug_exec_queries()
587 if (rc < 0) { in ddebug_exec_queries()
589 exitcode = rc; in ddebug_exec_queries()
591 nfound += rc; in ddebug_exec_queries()
604 /* apply a new bitmap to the sys-knob's current bit-state */
610 const struct ddebug_class_map *map = dcp->map; in ddebug_apply_class_bitmap() local
616 for (bi = 0; bi < map->length; bi++) { in ddebug_apply_class_bitmap()
620 snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], in ddebug_apply_class_bitmap()
621 test_bit(bi, new_bits) ? '+' : '-', dcp->flags); in ddebug_apply_class_bitmap()
626 v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi, in ddebug_apply_class_bitmap()
627 ct, map->class_names[bi], *new_bits); in ddebug_apply_class_bitmap()
633 #define KP_NAME(kp) kp->name
635 #define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1)
637 /* accept comma-separated-list of [+-] classnames */
640 const struct ddebug_class_param *dcp = kp->arg; in param_set_dyndbg_classnames()
641 const struct ddebug_class_map *map = dcp->map; in param_set_dyndbg_classnames() local
649 return -ENOMEM; in param_set_dyndbg_classnames()
651 /* start with previously set state-bits, then modify */ in param_set_dyndbg_classnames()
652 curr_bits = old_bits = *dcp->bits; in param_set_dyndbg_classnames()
660 if (*cl_str == '-') { in param_set_dyndbg_classnames()
668 cls_id = match_string(map->class_names, map->length, cl_str); in param_set_dyndbg_classnames()
675 switch (map->map_type) { in param_set_dyndbg_classnames()
677 /* the +/- pertains to a single bit */ in param_set_dyndbg_classnames()
683 totct += ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits); in param_set_dyndbg_classnames()
684 *dcp->bits = curr_bits; in param_set_dyndbg_classnames()
686 map->class_names[cls_id]); in param_set_dyndbg_classnames()
689 /* cls_id = N in 0..max. wanted +/- determines N or N-1 */ in param_set_dyndbg_classnames()
690 old_bits = CLASSMAP_BITMASK(*dcp->lvl); in param_set_dyndbg_classnames()
694 *dcp->lvl = (cls_id + (wanted ? 1 : 0)); in param_set_dyndbg_classnames()
695 v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, in param_set_dyndbg_classnames()
696 map->class_names[cls_id], old_bits, curr_bits); in param_set_dyndbg_classnames()
699 pr_err("illegal map-type value %d\n", map->map_type); in param_set_dyndbg_classnames()
708 * param_set_dyndbg_classes - class FOO >control
710 * @kp: kp->arg has state: bits/lvl, map, map_type
713 * DECLARE_DYNDBG_CLASSMAP. For LEVEL map-types, enforce relative
720 const struct ddebug_class_param *dcp = kp->arg; in param_set_dyndbg_classes()
721 const struct ddebug_class_map *map = dcp->map; in param_set_dyndbg_classes() local
723 int rc, totct = 0; in param_set_dyndbg_classes() local
725 switch (map->map_type) { in param_set_dyndbg_classes()
729 /* handle [+-]classnames list separately, we are done here */ in param_set_dyndbg_classes()
734 /* numeric input, accept and fall-thru */ in param_set_dyndbg_classes()
735 rc = kstrtoul(instr, 0, &inrep); in param_set_dyndbg_classes()
736 if (rc) { in param_set_dyndbg_classes()
738 return -EINVAL; in param_set_dyndbg_classes()
742 pr_err("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); in param_set_dyndbg_classes()
743 return -EINVAL; in param_set_dyndbg_classes()
746 /* only _BITS,_NUM (numeric) map-types get here */ in param_set_dyndbg_classes()
747 switch (map->map_type) { in param_set_dyndbg_classes()
750 if (inrep & ~CLASSMAP_BITMASK(map->length)) { in param_set_dyndbg_classes()
752 KP_NAME(kp), inrep, CLASSMAP_BITMASK(map->length)); in param_set_dyndbg_classes()
753 inrep &= CLASSMAP_BITMASK(map->length); in param_set_dyndbg_classes()
756 totct += ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits); in param_set_dyndbg_classes()
757 *dcp->bits = inrep; in param_set_dyndbg_classes()
761 if (inrep > map->length) { in param_set_dyndbg_classes()
763 KP_NAME(kp), inrep, map->length); in param_set_dyndbg_classes()
764 inrep = map->length; in param_set_dyndbg_classes()
766 old_bits = CLASSMAP_BITMASK(*dcp->lvl); in param_set_dyndbg_classes()
770 *dcp->lvl = inrep; in param_set_dyndbg_classes()
773 pr_warn("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); in param_set_dyndbg_classes()
781 * param_get_dyndbg_classes - classes reader
782 * @buffer: string description of controlled bits -> classes
783 * @kp: kp->arg has state: bits, map
786 * altered by direct >control. Displays 0x for DISJOINT, 0-N for
791 const struct ddebug_class_param *dcp = kp->arg; in param_get_dyndbg_classes()
792 const struct ddebug_class_map *map = dcp->map; in param_get_dyndbg_classes() local
794 switch (map->map_type) { in param_get_dyndbg_classes()
798 return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits); in param_get_dyndbg_classes()
802 return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl); in param_get_dyndbg_classes()
804 return -1; in param_get_dyndbg_classes()
819 if (PREFIX_SIZE - wrote > 0) in remaining()
820 return PREFIX_SIZE - wrote; in remaining()
829 if (desc->flags & _DPRINTK_FLAGS_INCL_TID) { in __dynamic_emit_prefix()
837 if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME) in __dynamic_emit_prefix()
839 desc->modname); in __dynamic_emit_prefix()
840 if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) in __dynamic_emit_prefix()
842 desc->function); in __dynamic_emit_prefix()
843 if (desc->flags & _DPRINTK_FLAGS_INCL_SOURCENAME) in __dynamic_emit_prefix()
845 trim_prefix(desc->filename)); in __dynamic_emit_prefix()
846 if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO) in __dynamic_emit_prefix()
848 desc->lineno); in __dynamic_emit_prefix()
849 if (pos - pos_after_tid) in __dynamic_emit_prefix()
852 buf[PREFIX_SIZE - 1] = '\0'; in __dynamic_emit_prefix()
859 if (unlikely(desc->flags & _DPRINTK_FLAGS_INCL_ANY)) in dynamic_emit_prefix()
929 if (dev && dev->dev.parent) { in __dynamic_netdev_dbg()
932 dev_printk_emit(LOGLEVEL_DEBUG, dev->dev.parent, in __dynamic_netdev_dbg()
935 dev_driver_string(dev->dev.parent), in __dynamic_netdev_dbg()
936 dev_name(dev->dev.parent), in __dynamic_netdev_dbg()
965 if (ibdev && ibdev->dev.parent) { in __dynamic_ibdev_dbg()
968 dev_printk_emit(LOGLEVEL_DEBUG, ibdev->dev.parent, in __dynamic_ibdev_dbg()
971 dev_driver_string(ibdev->dev.parent), in __dynamic_ibdev_dbg()
972 dev_name(ibdev->dev.parent), in __dynamic_ibdev_dbg()
973 dev_name(&ibdev->dev), in __dynamic_ibdev_dbg()
976 printk(KERN_DEBUG "%s: %pV", dev_name(&ibdev->dev), &vaf); in __dynamic_ibdev_dbg()
1000 * File_ops->write method for <debugfs>/dynamic_debug/control. Gathers the
1012 if (len > USER_BUF_PAGE - 1) { in ddebug_proc_write()
1014 return -E2BIG; in ddebug_proc_write()
1038 iter->table = NULL; in ddebug_iter_first()
1041 iter->table = list_entry(ddebug_tables.next, in ddebug_iter_first()
1043 iter->idx = iter->table->num_ddebugs; in ddebug_iter_first()
1044 return &iter->table->ddebugs[--iter->idx]; in ddebug_iter_first()
1055 if (iter->table == NULL) in ddebug_iter_next()
1057 if (--iter->idx < 0) { in ddebug_iter_next()
1059 if (list_is_last(&iter->table->link, &ddebug_tables)) { in ddebug_iter_next()
1060 iter->table = NULL; in ddebug_iter_next()
1063 iter->table = list_entry(iter->table->link.next, in ddebug_iter_next()
1065 iter->idx = iter->table->num_ddebugs; in ddebug_iter_next()
1066 --iter->idx; in ddebug_iter_next()
1068 return &iter->table->ddebugs[iter->idx]; in ddebug_iter_next()
1078 struct ddebug_iter *iter = m->private; in ddebug_proc_start()
1089 while (dp != NULL && --n > 0) in ddebug_proc_start()
1101 struct ddebug_iter *iter = m->private; in ddebug_proc_next()
1112 #define class_in_range(class_id, map) \ argument
1113 (class_id >= map->base && class_id < map->base + map->length)
1117 struct ddebug_class_map *map; in ddebug_class_name() local
1119 list_for_each_entry(map, &iter->table->maps, link) in ddebug_class_name()
1120 if (class_in_range(dp->class_id, map)) in ddebug_class_name()
1121 return map->class_names[dp->class_id - map->base]; in ddebug_class_name()
1129 * current _ddebug as a single human-readable line, with a
1134 struct ddebug_iter *iter = m->private; in ddebug_proc_show()
1146 trim_prefix(dp->filename), dp->lineno, in ddebug_proc_show()
1147 iter->table->mod_name, dp->function, in ddebug_proc_show()
1148 ddebug_describe_flags(dp->flags, &flags)); in ddebug_proc_show()
1149 seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); in ddebug_proc_show()
1152 if (dp->class_id != _DPRINTK_CLASS_DFLT) { in ddebug_proc_show()
1157 seq_printf(m, " class unknown, _id:%d", dp->class_id); in ddebug_proc_show()
1212 if (!strcmp(cm->mod_name, dt->mod_name)) { in ddebug_attach_module_classes()
1215 cm->mod_name, cm->base, cm->length, cm->map_type); in ddebug_attach_module_classes()
1217 for (j = 0; j < cm->length; j++) in ddebug_attach_module_classes()
1218 v3pr_info(" %d: %d %s\n", j + cm->base, j, in ddebug_attach_module_classes()
1219 cm->class_names[j]); in ddebug_attach_module_classes()
1221 list_add(&cm->link, &dt->maps); in ddebug_attach_module_classes()
1226 vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); in ddebug_attach_module_classes()
1237 v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs); in ddebug_add_module()
1238 if (!di->num_descs) { in ddebug_add_module()
1246 return -ENOMEM; in ddebug_add_module()
1249 * For built-in modules, name lives in .rodata and is in ddebug_add_module()
1250 * immortal. For loaded modules, name points at the name[] in ddebug_add_module()
1254 dt->mod_name = modname; in ddebug_add_module()
1255 dt->ddebugs = di->descs; in ddebug_add_module()
1256 dt->num_ddebugs = di->num_descs; in ddebug_add_module()
1258 INIT_LIST_HEAD(&dt->link); in ddebug_add_module()
1259 INIT_LIST_HEAD(&dt->maps); in ddebug_add_module()
1261 if (di->classes && di->num_classes) in ddebug_add_module()
1262 ddebug_attach_module_classes(dt, di->classes, di->num_classes); in ddebug_add_module()
1265 list_add_tail(&dt->link, &ddebug_tables); in ddebug_add_module()
1268 vpr_info("%3u debug prints in module %s\n", di->num_descs, modname); in ddebug_add_module()
1302 * modprobe foo finds foo.params in boot-args, strips "foo.", and
1309 return ddebug_dyndbg_param_cb(param, val, module, -ENOENT); in ddebug_dyndbg_module_param_cb()
1314 list_del_init(&dt->link); in ddebug_table_free()
1327 int ret = -ENOENT; in ddebug_remove_module()
1331 if (dt->mod_name == mod_name) { in ddebug_remove_module()
1351 ret = ddebug_add_module(&mod->dyndbg_info, mod->name); in ddebug_module_notify()
1356 ddebug_remove_module(mod->name); in ddebug_module_notify()
1390 return -ENODEV; in dynamic_debug_init_control()
1417 .num_descs = __stop___dyndbg - __start___dyndbg, in dynamic_debug_init()
1418 .num_classes = __stop___dyndbg_classes - __start___dyndbg_classes, in dynamic_debug_init()
1440 modname = iter->modname; in dynamic_debug_init()
1445 if (strcmp(modname, iter->modname)) { in dynamic_debug_init()
1454 modname = iter->modname; in dynamic_debug_init()
1470 v2pr_info(" %d builtin ddebug class-maps\n", di.num_classes); in dynamic_debug_init()
1476 * parse_args avoids ad-hoc parsing. This will also attempt in dynamic_debug_init()
1477 * to activate queries for not-yet-loaded modules, which is in dynamic_debug_init()