• Jim Cromie's avatar
    dyndbg: test DECLARE_DYNDBG_CLASSMAP, sysfs nodes · 6ea3bf46
    Jim Cromie authored
    Demonstrate use of DECLARE_DYNDBG_CLASSMAP macro, and expose them as
    sysfs-nodes for testing.
    
    For each of the 4 class-map-types:
    
      - declare a class-map of that type,
      - declare the enum corresponding to those class-names
      - share _base across 0..30 range
      - add a __pr_debug_cls() call for each class-name
      - declare 2 sysnodes for each class-map
        for 'p' flag, and future 'T' flag
    
    These declarations create the following sysfs parameter interface:
    
      :#> pwd
      /sys/module/test_dynamic_debug/parameters
      :#> ls
      T_disjoint_bits  T_disjoint_names  T_level_names  T_level_num  do_prints
      p_disjoint_bits  p_disjoint_names  p_level_names  p_level_num
    
    NOTES:
    
    The local wrapper macro is an api candidate, but there are already too
    many parameters.  OTOH, maybe related enum should be in there too,
    since it has _base inter-dependencies.
    
    The T_* params control the (future) T flag on the same class'd
    pr_debug callsites as their p* counterparts.  Using them will fail,
    until the dyndbg-trace patches are added in.
    
    :#> echo 1 > T_disjoint
    [   28.792489] dyndbg: disjoint: 0x1 > test_dynamic_debug.T_D2
    [   28.793848] dyndbg: query 0: "class D2_CORE +T" mod:*
    [   28.795086] dyndbg: split into words: "class" "D2_CORE" "+T"
    [   28.796467] dyndbg: op='+'
    [   28.797148] dyndbg: unknown flag 'T'
    [   28.798021] dyndbg: flags parse failed
    [   28.798947] dyndbg: processed 1 queries, with 0 matches, 1 errs
    [   28.800378] dyndbg: bit_0: -22 matches on class: D2_CORE -> 0x1
    [   28.801959] dyndbg: test_dynamic_debug.T_D2: updated 0x0 -> 0x1
    [   28.803974] dyndbg: total matches: -22
    Signed-off-by: default avatarJim Cromie <jim.cromie@gmail.com>
    Link: https://lore.kernel.org/r/20220904214134.408619-22-jim.cromie@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    6ea3bf46
test_dynamic_debug.c 3.67 KB