xen-troops / zephyr-xenlib

Set of Zephyr libs and applications that provides basic Dom0 services
Apache License 2.0
0 stars 10 forks source link

xenlib: internal threads doesn't have names which makes thread_analyzer output not informative #84

Open GrygiriiS opened 4 months ago

GrygiriiS commented 4 months ago

The thread_analyzer produces output with thread addresses and no names, as result impossible to say which thread is where.

To Zephyr thread_analyzer enable use:

 -DCONFIG_THREAD_ANALYZER=y \
 -DCONFIG_THREAD_ANALYZER_USE_PRINTK=y \
 -DCONFIG_THREAD_ANALYZER_AUTO=y \
 -DCONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5
Thread analyze:                                                                                                       
 0x80c1700           : STACK: unused 3632 usage 464 / 4096 (11 %); CPU: 0 % 
^^^^^^^^^^^^^^^^^^                                          
      : Total CPU cycles used: 78879
 0x80c12f0           : STACK: unused 3632 usage 464 / 4096 (11 %); CPU: 0 %
      : Total CPU cycles used: 71
 thread_analyzer     : STACK: unused 0 usage 1024 / 1024 (100 %); CPU: 1 %
      : Total CPU cycles used: 228061711
 0x80bed10           : STACK: unused 3056 usage 1040 / 4096 (25 %); CPU: 0 %
      : Total CPU cycles used: 23777
 sysworkq            : STACK: unused 3712 usage 384 / 4096 (9 %); CPU: 0 %
      : Total CPU cycles used: 23
 shell_uart          : STACK: unused 1696 usage 2400 / 4096 (58 %); CPU: 0 %
      : Total CPU cycles used: 4750908
 idle                : STACK: unused 3696 usage 400 / 4096 (9 %); CPU: 98 %
      : Total CPU cycles used: 15343969381
 ISR0                : STACK: unused 6512 usage 1680 / 8192 (20 %)

Thread names has to be added as:

    k_thread_name_set(&context->rx_thread, "name");

-- or --

    if (IS_ENABLED(CONFIG_THREAD_NAME)) {
        char name[THREAD_MAX_NAME_LEN];

        snprintk(name, sizeof(name), "name-%", <param>);
        k_thread_name_set(ctx->rx_thread, name);
    }