Skip to content
Permalink
Browse files
dyndbg: 1st port of bitmap-to-query code
broken still, needs fixup on undefined format_class_prefixes, which
could become a declarative interface; an ordered list of string
prefixes maps bits 0...N-1.  So it needs sorting.
  • Loading branch information
jimc committed May 11, 2021
1 parent 728c04d commit 0f03b0e100e7a3c1568a2454f3d453f1706d636e
Showing 1 changed file with 47 additions and 0 deletions.
@@ -1150,3 +1150,50 @@ early_initcall(dynamic_debug_init);

/* Debugfs setup must be done later */
fs_initcall(dynamic_debug_init_control);

static int param_set_dyndbg(const char *instr, const struct kernel_param *kp)
{
unsigned int val;
unsigned long changes, result;
int rc, chgct = 0, totct = 0, bitpos;
char query[OUR_QUERY_SIZE];

rc = kstrtouint(instr, 0, &val);
if (rc) {
pr_err("%s: failed\n", __func__);
return -EINVAL;
}
result = val;
// changes = result ^ __drm_debug;

pr_debug("changes:0x%lx from result:0x%lx\n", changes, result);

for_each_set_bit(bitpos, &changes, ARRAY_SIZE(format_class_prefixes)) {

sprintf(query, "format '^%s' %cp", format_class_prefixes[bitpos],
test_bit(bitpos, &result) ? '+' : '-');

chgct = dynamic_debug_exec_queries(query, "drm*");
if (chgct < 0) {
pr_err("%s: exec err:%d on: %s\n", __func__, chgct, query);
continue;
}
pr_debug("change ct:%d on %s\n", chgct, query);
totct += chgct;
}
pr_debug("total changes: %d\n", totct);
//__drm_debug = result;
return 0;
}

static int param_get_dyndbg(char *buffer, const struct kernel_param *kp)
{
pr_debug("debug-val:0x%x\n", //__drm_debug
*((unsigned int *)kp->arg));
return scnprintf(buffer, PAGE_SIZE, "%u\n",
*((unsigned int *)kp->arg));
}
static const struct kernel_param_ops param_ops_debug = {
.set = param_set_dyndbg,
.get = param_get_dyndbg,
};

0 comments on commit 0f03b0e

Please sign in to comment.