[PATCH 02/63] test-dyndbg: fixup CLASSMAP usage error

Louis Chauvet louis.chauvet at bootlin.com
Tue Feb 25 11:22:05 UTC 2025



Le 25/01/2025 à 07:45, Jim Cromie a écrit :
> A more careful reading of logging output from test_dynamic_debug.ko
> reveals:
> 
> lib/test_dynamic_debug.c:103 [test_dynamic_debug]do_cats =pmf "doing categories\n"
> lib/test_dynamic_debug.c:105 [test_dynamic_debug]do_cats =p "LOW msg\n" class:MID
> lib/test_dynamic_debug.c:106 [test_dynamic_debug]do_cats =p "MID msg\n" class:HI
> lib/test_dynamic_debug.c:107 [test_dynamic_debug]do_cats =_ "HI msg\n" class unknown, _id:13
> 
> 107 says: HI is unknown, 105,106 have LOW/MID and MID/HI skew.
> 
> The enum's 1st val (explicitly initialized) was wrong; it must be
> _base, not _base+1 (a DECLARE_DYNDBG_CLASSMAP param).  So the last
> enumeration exceeded the range of mapped class-id's, which triggered
> the "class unknown" report.  I coded in an error, intending to verify
> err detection, then forgot, and missed that it was there.
> 
> So this patch fixes a bad usage of DECLARE_DYNDBG_CLASSMAP(), showing
> that it is too error-prone.  As noted in test-mod comments:
> 
>   * Using the CLASSMAP api:
>   * - classmaps must have corresponding enum
>   * - enum symbols must match/correlate with class-name strings in the map.
>   * - base must equal enum's 1st value
>   * - multiple maps must set their base to share the 0-62 class_id space !!
> 
> Signed-off-by: Jim Cromie <jim.cromie at gmail.com>

Reviewed-by: Louis Chauvet <louis.chauvet at bootlin.com>
Tested-by: Louis Chauvet <louis.chauvet at bootlin.com>

> ---
>   lib/test_dynamic_debug.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c
> index 77c2a669b6af..396144cf351b 100644
> --- a/lib/test_dynamic_debug.c
> +++ b/lib/test_dynamic_debug.c
> @@ -75,7 +75,7 @@ DD_SYS_WRAP(disjoint_bits, p);
>   DD_SYS_WRAP(disjoint_bits, T);
>   
>   /* symbolic input, independent bits */
> -enum cat_disjoint_names { LOW = 11, MID, HI };
> +enum cat_disjoint_names { LOW = 10, MID, HI };
>   DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, 10,
>   			"LOW", "MID", "HI");
>   DD_SYS_WRAP(disjoint_names, p);

-- 
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



More information about the Intel-gfx-trybot mailing list