Commit Graph

40 Commits

Author SHA1 Message Date
Marc Herbert 158089ceb6 Add and fix many logger and dma-related comments. No code change.
Learned the hard way.  Will help refactoring or duplicated
"reverse-engineering" effort.

Zero code change, pure comments: no functional change.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-28 15:52:44 +01:00
Marc Herbert d6f6a456c1 logger: fix column and header alignments
Increase default width from 10 to 12 to stop common misalignment,
especially in relative mode.

New timestamp_width() function to avoid duplication and
divergence.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-27 12:17:53 +01:00
Marc Herbert 37e87e54b1 logger: partial rewording of one log_err() and usage message
Cosmetic change that does not fit in any other commit.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-27 12:17:53 +01:00
Marc Herbert dc0ab8a449 logger: fix precision bug introduced by new -e option
Add missing "break" so the -e option stops spilling on the -f precision
option. Fixes commit 53ce8b9d9f ("logger: new relative timestamps
option, relative to first entry seen"). Since that commit the -e option
was wrongly assigned to the precision too.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-19 15:43:06 +01:00
Marc Herbert 53ce8b9d9f logger: new relative timestamps option, relative to first entry seen
Add a new sof-logger -e 0/1 relative timestamps option where the
TIMESTAMP column is relative to the first entry seen.

Removes many digits and makes the TIMESTAMP column much more readable in
short logs.

Also stop showing "NaN" as the first DELTA like something went
wrong. Show zero instead.

The new option is off by default when using -r(aw) and on otherwise.

The first entry is kept always absolute.

Before:

         TIMESTAMP              DELTA C# COMPONENT     LOCATION                      CONTENT
[6653843012.343750] (             NaN) c0 dma-trace    src/trace/dma-trace.c:339     ERROR FW ...
[6653843111.510417] (       99.166664) c0 ll-schedule  ./schedule/ll_schedule.c:229  perf ll_work
[6653843309.010417] (      197.500000) c0 ll-schedule  ./schedule/ll_schedule.c:399  task add
[6653843314.166667] (        5.156250) c0 ll-schedule  ./schedule/ll_schedule.c:403  task params
[6653843322.031250] (        7.864583) c0 ll-schedule  ./schedule/ll_schedule.c:309  new added
[6653843327.031250] (        5.000000) c0 ll-schedule  ./schedule/ll_schedule.c:312  num_tasks 2
[6653844109.531250] (      782.500000) c0 sa                    src/lib/agent.c:65   perf sys_load
[6653844155.156250] (       45.625000) c0 ll-schedule  ./schedule/ll_schedule.c:229  perf ll_work
[6653844384.218750] (      229.062500) c0 component       src/audio/component.c:130  comp new host

After:

         TIMESTAMP              DELTA C# COMPONENT     LOCATION                      CONTENT
[686125142.395834] (        0.000000) c0 dma-trace    src/trace/dma-trace.c:339     ERROR FW ...
[       94.270833] (       94.270836) c0 ll-schedule   ./schedule/ll_schedule.c:229  perf ll_work
[      296.770833] (      202.500000) c0 ll-schedule   ./schedule/ll_schedule.c:399  task add
[      301.979167] (        5.208333) c0 ll-schedule   ./schedule/ll_schedule.c:403  task params
[      309.843750] (        7.864583) c0 ll-schedule   ./schedule/ll_schedule.c:309  new added
[      314.843750] (        5.000000) c0 ll-schedule   ./schedule/ll_schedule.c:312  num_tasks 2
[     1092.395833] (      777.552063) c0 sa                     src/lib/agent.c:65   perf sys_load
[     1137.968750] (       45.572918) c0 ll-schedule   ./schedule/ll_schedule.c:229  perf ll_work
[     1850.208333] (      712.239563) c0 component        src/audio/component.c:130  comp new host

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-02 13:35:48 +01:00
Marc Herbert 2e6cafa02f logger: use strerror()
Useful error messages when forgetting to use "sudo" or to change
permissions in udev.

Some places were printing the errno decimal. Others no specific error
at all.

Sample outputs:

error: Unable to open version file /sys/kernel/debug/sof/fw_version: \
                                                       Permission denied

error: Unable to open version file /sys/kernel/debug/sof/fw_version: \
                                               No such file or directory

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-01 22:04:45 +01:00
Karol Trzcinski 9e131360fc logger: Check for unused arguments
There is no place for unused arguments, their are consequence of invalid
argument list as usual.
Such an situation is highly possible especially during defining trace
filters, eg `-Fv=mux 4.1` instead `-F"v=mux 4.1"` or `-Fv=mux4.1`.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-21 11:48:19 +01:00
Pan Xiuli 2fe7c89489 logger: change the usage string for filter
Change the misleading usage info for filter.
Add format as tips for filter string.

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
2020-10-20 11:08:20 +01:00
Pan Xiuli b804e1df7e logger: fix opt for filter parameter
The -F filter option has argument, we should use
F: instead of F in the optstring.

Fixes: #3530

Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
2020-10-20 11:08:20 +01:00
Karol Trzcinski a76d74534a logger: Disable ldc compatibility check for ldc dump operation
LDC with FW compatibility check has no sens for ldc dump operation,
because ldc dump reads only information provided in ldc file,
without engaging any information from FW - can be done offline as well.
Logger and ldc file DBG_ABI compatibility check is still active.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-09-30 16:23:35 +01:00
Karol Trzcinski 7722365264 logger: Fix memory leak at first filter append
For first run, allocated memory pointer has been written twice to
config->filter_config but freed only once - memory leak.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-09-15 11:17:21 +01:00
Marc Herbert 742cbb8af6 logger: use __attribute__((format(printf, 1, 2))) in misc.h
Also works with clang.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-09-14 10:43:54 +01:00
Karol Trzcinski 7650398d01 logger: Add option to disable firmware compatibility check
It may be needed for situation when user have firmware after
small fixes without updated ldc file or fw_ready file is not
accessible. Option dedicated for advanced users.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-09-02 14:32:03 +01:00
Karol Trzcinski 7da08bed48 logger: Enable LDC and FW compatibility check by default
By default user should use compatible files.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-09-02 14:32:03 +01:00
Karol Trzcinski bd0e10d133 logger: Store filter config given in command line
To parse filter configuration given by user, uuid dictionary
must be readed first from ldc file. Otherwise it's impossible
to validate given components names. This is reason why filter
configuration must be buffered and parsed in later steps.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-08-25 13:09:38 +01:00
Karol Trzcinski d07035d981 logger: Align g flag description in help message
Help message, near -g flags looks like:

sof-logger:      -f precision           Set timestamp precision
sof-logger:      -g             Hide timestamp
sof-logger:      -d *.ldc_file          Dump ldc_file information

before changes, and after apply this patch, descriptions are aligned.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-08-04 11:26:19 +01:00
Karol Trzcinski cb10221109 logger: Rename float_precision to time_precision
New name better describes variable functionality.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-06-24 09:30:26 +01:00
Karol Trzcinski d97e9291e1 logger: Add possibility to hide timestamps
After removing timestamps it is possible to compare output logs
with tools like diff or similar. Moreover then output logs are
in more compact form.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-06-24 09:30:26 +01:00
Karol Trzcinski 0596f5b71c logger: Pass input file in -d flag
Such an approach is more logical, user add flag to dump information
and specify what to dump just after it. Using separate argument
with file path and flag to dump is less natural. So after change
`./sof-logger -l file.ldc -d`
will be replaced with
`./sof-logger -d file.ldc`

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-05-27 13:24:10 +01:00
Karol Trzcinski 44a25a1a64 logger: Do not open input file for ldc_dump
Input file is not needed for these functionalities, so shouldn't be
opened.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-05-27 13:24:10 +01:00
Karol Trzcinski fe3dfe4007 logger: Fix help message consistency
Before this patch output message was misaligned and one flag
description start from small letter:
sof-logger:      -L                     Hide log location in source code
sof-logger:      -f precision                   set timestamp precision
sof-logger:      -d                     Dump ldc information

After change, it's fixed:
sof-logger:      -L                     Hide log location in source code
sof-logger:      -f precision           Set timestamp precision
sof-logger:      -d                     Dump ldc information

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-05-27 12:15:29 +01:00
Karol Trzcinski 1535738355 logger: Move optstring from getopt function to separate variable
Such a change is provoked by getting close to maximal line length
in line with getopt line call. Moving format string to separate
variable is more logical solution than splitting function arguments
on separate lines.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-05-27 11:31:59 +03:00
Karol Trzcinski d7b535e282 logger: Add option to set timestamp precision
Shorten timestamp makes logger output more compact, it change:
$ ./sof-logger -l sof-cnl.ldc -i dma_trace_1.bin
         TIMESTAMP              DELTA C# COMPONENT          LOCATION                      CONTENT
[   497588.489583] (   497588.500000) c0 DMA                .../intel/cavs/hda-dma.c:407  hda-dmac: 4 channel 6 -> get
to:
$ sof-logger -l sof-cnl.ldc -i dma_trace_1.bin -f0
   TIMESTAMP        DELTA C# COMPONENT          LOCATION                      CONTENT
[    497588] (    497588) c0 DMA                .../intel/cavs/hda-dma.c:407  hda-dmac: 4 channel 6 -> get

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-05-18 12:06:51 +01:00
Karol Trzcinski 5469b1a070 logger: Add option to cutout trace location
It allows to make logs output more compact, it change:
$ ./sof-logger -l sof-cnl.ldc -i dma_trace_1.bin
         TIMESTAMP              DELTA C# COMPONENT          LOCATION                      CONTENT
[   497588.489583] (   497588.500000) c0 DMA                .../intel/cavs/hda-dma.c:407  hda-dmac: 4 channel 6 -> get
to:
$ ./sof-logger -l sof-cnl.ldc -i dma_trace_1.bin -L
         TIMESTAMP              DELTA C# COMPONENT          CONTENT
[   497588.489583] (   497588.500000) c0 DMA                hda-dmac: 4 channel 6 -> get

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-05-18 12:06:51 +01:00
Karol Trzcinski f87c6e89f2 smex: logger: Logger should point to smex as ldc generator
rimage will not be responsible for ldc file creation so logger
should points valid tool.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-04-03 16:27:04 +01:00
Payal Kshirsagar 66fd8cefba tools: logger: avoid NULL comparison
Change suggested by coccinelle.
Avoid NULL comparison, compare using boolean operator.

Signed-off-by: Payal Kshirsagar <payalskshirsagar1234@gmail.com>
2020-03-27 10:50:52 +01:00
Karol Trzcinski 7bf879b226 tools: logger: Add clock parameter in help message
help message should explicity show that -c flags needs parameter.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-03-26 10:18:30 +01:00
Karol Trzcinski fc84534247 tools: logger: Add LDC dump option
Create dump options for logger to print important information from
LDC file, like DBG_ABI version and UUID with corresponding names.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-03-26 10:18:30 +01:00
Dragos Tarcatu 7334d63fd4 tools: logger: (cosmetic) Improve usage text
Improve the sof-logger usage description text a little bit.
Specifically the -s argument is pretty confusing right now as
it says nothing about having an additional argument for the state
name.

Signed-off-by: Dragos Tarcatu <dragos_tarcatu@mentor.com>
2019-11-01 10:20:13 +01:00
Tomasz Lauda 119746d206 common: replace __attribute__((packed)) with __packed
Replaces all occurrences of __attribute__((packed)) with
__packed macro.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2019-07-12 16:12:59 +02:00
Janusz Jankowski 0eb68c6d5d logger: add debugfs entries for apl and cnl
Logger was aware only of debugfs entries for BYT/HSW platforms.
This commit adds debugfs entries for APL/CNL.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2019-06-07 22:36:50 +02:00
ArturX Kloniecki 3e3f1d0cae Logger: Update license info in sof-looger files.
Signed-off-by: ArturX Kloniecki <arturx.kloniecki@linux.intel.com>
2019-05-31 22:26:31 +02:00
Kai Vehmanen e14ab7088b tools: logger: fix parsing of -s argument
Fix logic for saving the snapshot file argument. getopt()
is called at least once after snapshot option is parsed and
getopt() will erase the optarg value when exiting the while
loop. Without this patch, argument is always NULL and snapshot
cannot be taken.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2019-04-15 16:25:39 +01:00
Marcin Maka ad0ff1f2e5 tools: logger: added less formatted output mode
Activated by '-r' option. Useful for intermediate log
processing when the output is used as an input for another
tool. No headers, tokens separated by single spaces,
component ids concatenated with component name to
still produce a single token if present.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2019-04-01 11:37:57 +02:00
Liam Girdwood 50685bfb42 logger: improve some error messages.
Make error messages more meaningful

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2019-02-01 16:17:07 +00:00
Bartosz Kokoszko e3cf1f2fed logger: use fopen binary mode
Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2019-01-31 11:11:57 +01:00
Guennadi Liakhovetski 64bbee865b logger: support reading from a serial port
On some systems the DSP has no DMA interface to the host and is
using a serial port for sending its trace. This patch adds a "-u"
argument to specify a baudrate, that should be used with the serial
interface. The implementation takes care of spurious bytes,
sometimes seen in the beginning of the trace, produced by the port
initialisation by the DSP. The format is fixed to 8N1.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2019-01-11 11:44:21 +00:00
Guennadi Liakhovetski 28039d3024 logger: (cosmetic) fix the return value, use pointers
1. Programs shouldn't exit with negative return values, strictly
   speaking only EXIT_SUCCESS and EXIT_FAILURE should be used,
   however it is also valid to return 0 for success and any number
   from 1 to 125 for a failure.
2. Avoid passing complete structs as function parameters where an
   additional copy of one isn't needed, use const pointers instead.
3. Remove a left-over unused argument.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2019-01-11 11:44:21 +00:00
Marcin Maka 95a3d93bbd tools: logger: turn off colors if the output file is not a tty.
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2018-12-04 13:37:16 +00:00
Curtis Malainey 5b5888ce07 Move SOFT into sub folder for SOF merge
Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2018-11-24 23:27:24 -08:00