'p + 2' should be smaller than end pointer, bigger value may leads
to undefined memory region read.
Memmove should include last '\0' char.
Without this fix output looks like:
task add 0xbe070600 pipe-task 0x1fffa0f0U
After changes:
task add 0xbe070600 pipe-task <f11818eb-e92e-4082-82a3-dc54c604ebb3>
Fixes: 12f2d9b2c8 logger: Refactor UUID parsing
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
config->uids_dict has never been freed before.
`out` label has been added to perform `uuid_dict`
free before function return.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Passing %s with random address leads to logger crash.
It's especially important right now, after changing
print formatter for UUID from %s to %pU. It's why
DBG_ABI patch number has been updated.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Split UUID formatter parsing from general formatter parser,
to make functions shorter and less complicated.
By the way reduce number of loops.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
fread() returns number of readed blocks, 0 when nothing read.
Comparison fread return value with "!ret" is quite misleading -
may suggests that negative value is returrned after fail.
Swapping if content makes flow easier, then first is error check,
and eventyally return statement, next try to reopen file.
It allows to check error condition only in one place, so there
won't be possibility to use different error checks in subsequent
stages (like ferror() and errno).
in_file alignment with trace entry size check has been added,
to warn about corrupted file.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
log format text comes from ldc file (may be invalid),
so error check is needed. Don't treat it as fatal error,
because this error may not impact following logs, when
formatting text is root cause of the issue.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
fread may return 0 when some error occurred or nothig has been reded.
Moreover errno may not be set on Windows plaform, use ferror
instead. See:
https://www.gnu.org/software/gnulib/manual/html_node/fread.html
Fixes: 337afc4f3809: ("logger: add error message when reading sof/etrace instead of sof/trace")
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Reported by VERBOSE=1 CMAKE_BUILD_TYPE=Release ./scripts/build-tools.sh -l
and gcc version 9.3.0-10ubuntu2:
tools/logger/convert.c:630:5: error: ignoring return value of ‘freopen’,
declared with attribute warn_unused_result [-Werror=unused-result]
Tested with sof-test/test-case/check-suspend-resume-with-audio.sh
Fixes commit 6a84b4e945 ("sof: logger: reopen trace file upon EOF")
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
As reported by gcc 9.3.0-10ubuntu2 and
VERBOSE=1 CMAKE_BUILD_TYPE=Release ./scripts/build-tools.sh -l
‘__builtin___snprintf_chk’ output between 23 and 57 bytes
into a time_fmt destination of size 32
Fixes commit d7b535e282 ("logger: Add option to set timestamp
precision")
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Failing silently is not nice. Now prints instead:
TIMESTAMP DELTA C# COMPONENT LOCATION CONTENT
error: in logger_read(), fread(..., /sys/kernel/debug/sof/etrace) \
failed: Invalid argument(22)
Also make logger_read() and the process return [-]errno which can have
different values and some information instead of -ferror() which has
only one value (non-zero in theory, 1 in practice) hence no information.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
In case we ever needed to load the entry from ldc file, without params
processing and printing.
Signed-off-by: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
Most functions in logger depend on values stored in conver_config struct
which are passed to almost all function calls. This patch moves pointer
to the config to global context and allows each function to derive
necessary values from there. This reduces needless parameters passed
to function calls and allows for more flexible access to data in nested
functions.
Signed-off-by: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
Parse arguments given in -F flag, in form where each -F argument
is given as separate line. Format of single -F entry is
`<log_level>=<component_list>`. <log_level> must corresponds with
.name field from log_level_dict. List of component are build from
elements separated with `,` and single element may have one of the
following forms:
"<name> <pipe_id>.<comp_id>" - single component instance
"<name> <pipe_id>.*" - components with given name on piepeline with pipe_id
"<name>*" - each component instance with given name or global component
"<name>" - as above
"* <pipe_id>.<comp_id>" - component on selected pipe_id with given comp_id
"* <pipe_id>.*" - each component on pipeline with pipe_id
"*" - each component in firmware
<name> must correspond values of uuid entries from ldc file.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
A few, general usage functions where implemented in converter file.
They should be moved to separate file, to make it easily accessible
form any source file. Moreover removing it from converter file, is a
part of this file cleanup.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
This conversion should be done in function, because of future usage
in different places, outside converter.c file.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
ABI version saved in fw_ready doesn't match with DBG_ABI version
saved in ldc file even for proper pair of fw and ldc file.
Moreover ldc file content changes at any log modyfication, what
is not related with DBG_ABI change, so this way of solving this
problem is incorrect.
Introduced src_hash value change solves both problems.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
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>
Name and UUID value of component should be aligned with their address.
Output before change:
ADDRESS UUID NAME
0x1FFFA000 <8b9d100c-6d78-418f-90a3-e0e805d0852b> host
0x1FFFA01C <8b9d100c-6d78-418f-90a3-e0e805d0852b> host
0x1FFFA03C <8b9d100c-6d78-418f-90a3-e0e805d0852b> host
and after:
ADDRESS UUID NAME
0x1FFFA000 <8b9d100c-6d78-418f-90a3-e0e805d0852b> host
0x1FFFA01C <f11818eb-e92e-4082-82a3-dc54c604ebb3> pipe-task
0x1FFFA03C <34dc0385-fc2f-4f7f-82d2-6cee444533e0> volume-task
0x1FFFA05C <b77e677e-5ff4-4188-af14-fba8bdbf8682> volume
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
It make code dealing with entries simpler, and allow to create
UUID entries dictionary with constant access time to any entry.
As long as struct definition is fixed, then can passed as pointer
with correct type to function call, instead of void pointer.
UUID entries aren't storred in flash memory, so entry size is not
important.
Explicit add zero at the end of entity_name to trigger string overflow
warning for shortest incorrect string length.
Resolve problem with cutted UUID info in logger output.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
All trace entries are identified by uuids only now.
Previous TRACE_CLASS_ identification removed completely.
UUIDs are passed to the tracing subsystem inside a trace
context. Each trace context defines run-time log level.
The level is initialized to LOG_LEVEL_INFO (this may be
change per instance is needed) and may be re-configured
at run-time.
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
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>
Split this function to part responsible for pointer calculation
and string formatting. It make possibility to use same
string format with different pointer arithmetic.
Moreover introduce aprintf to make memory allocation for output
string more automated process.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Double space in formatting string led to little mismatch between header
and content in output logger file.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
When out_fd points standard output then error message shouldn't be
duplicated - duplicated messages only make logger output more messy.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Error during conversion should be logged to stderr and to
output file by default. Such a approach will speed up debugging
process when some error with conversion occur in CI.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Content inside if statement should be indented with only one
tab more that if keyword.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Log entry format is scanned by the logger and if %s is found,
then corresponding parameter is interpreted as address
of static uuid entry. The original address is replaced by
formatted uuid namen and value, painted in blue, before
fprintf() is called.
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Log entry parameters format is compacted to reserve more
space for the text.
Max entry location length is increased to 24 characters.
Timestamp and component name/id use colors to improve
readability.
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Content of static uuid section is appended to the ldc file
along with a new special header by rimage.
New ldc file part is read by the logger to decode
uuid pointers provided in traces into nice names.
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
New trace entry parameter is defined: uuid of the source.
Technically, this is an address of uuid entry linked
inside a special section in elf.
Has_ids is removed from the static log entry since eventually
all entries will use uuids and -1 detection is good enough
detection for those who still do not provide ids.
Note: both changes are done in a single patch to avoid two
major dbg-abi version bumps.
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Optional fw version verification moved to separate function
in order to modularize code of convert().
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
The sof-logger and potentially other debug API clients perform ABI
compatibility check using the single FW ABI version. The same one is used
by the primary FW client which is the kernel driver. If there is a change
made to the debug API, the main ABI has to be updated to protect integrity
of the debug tools while such a change may not affect the kernel driver
at all.
This patch introduces new debug ABI version to be increased when changing
user space debug interfaces while the the main ABI is not affected.
Recompilation and installation of the new driver every time the tunneled
debug protocol is upgraded may be avoided.
Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
Probes are a feature that will allow user to extract and inject data
from/into buffers at runtime.
Basic flow is as follows:
1. Initialization of probes subsystem, allowing for simultaneous
configuration of DMA for extraction. If extraction DMA is not setup
during init, extraction probes will be disabled.
2. Configuration of probe points, preceded by DMA configuration in case
of injection probes.
3. Probes are now in operation and will send single multiplexed stream from
extraction probe points and inject data into specified buffers.
4. State of probes and associated DMAs may be retrieved via INFO functions.
5. Removal of probe points.
6. Removal of injection DMAs.
7. Deinitialization of probes subsystem.
Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
Signed-off-by: ArturX Kloniecki <arturx.kloniecki@linux.intel.com>
This patch adds print of text ASRC into sof-logger for ASRC
originated traces instead of unknown.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This change adds stream map and channel map structures
used for channel re-routing and stream aggregation.
Signed-off-by: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
Latest GCC does additional checks. This patch fixes the following build
error.
Scanning dependencies of target sof-logger
[ 0%] Building C object logger/CMakeFiles/sof-logger.dir/convert.c.o
/home/lrg/work/sof/sof/tools/logger/convert.c: In function ‘serial_read’:
/home/lrg/work/sof/sof/tools/logger/convert.c:311:2: error: converting a packed ‘struct log_entry_header’ pointer (alignment 1) to a ‘uint32_t’ {aka ‘unsigned int’} pointer (alignment 4) may result in an unaligned pointer value [-Werror=address-of-packed-member]
311 | for (len = 0, n = (uint32_t *)&dma_log; len < sizeof(dma_log); n++) {
| ^~~
In file included from /home/lrg/work/sof/sof/tools/logger/convert.c:15:
/home/lrg/work/sof/sof/tools/../src/include/user/trace.h:94:8: note: defined here
94 | struct log_entry_header {
| ^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [logger/CMakeFiles/sof-logger.dir/build.make:76: logger/CMakeFiles/sof-logger.dir/convert.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:91: logger/CMakeFiles/sof-logger.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>