When CONFIG_LOG_OUTPUT is set, it indicates that logging strings
are formatted by the application (using log_output module). It is
not needed when backend works in the dictionary mode. So far
LOG_OUTPUT was set also when dictionary mode was used and that
prevented removing of the logging strings from binary which is
an important feature of the dictionary logging.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Move log_output_flush and log_output_write (renamed internal
buffer_write() function) to the header as inline functions.
Those function are used by log_output_dict.c and there are cases
when log_output.c is not compiled in.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Building the net logger backend with IPv4 only gives the following
warning:
log_backend_net.c:116:31: warning: array subscript 'struct sockaddr[0]'
is partly outside array bounds of 'struct sockaddr_in[1]'
[-Warray-bounds] local_addr->sa_family = server_addr.sa_family;
hence assign the address family directly to sockaddr_in/6 structs.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
There are many places where source_id is retrieved and it
depends on runtime filtering being enabled. So far it was
all exposed but lets encapsulate that into a helper function.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Currently we can assume that flpr and ppr cores are always owned by
cpuapp. In that case, cpuapp (which processes ETR buffer content) has
access to the memory where logging strings from ppr and flpr are
located. Those strings do not need to be appended to the message
which is written to the STM (in case of standalone configuration).
This approach reduced logging time, e.g. logging a message with
one argument takes 1.8us on cpuapp and 6.3us on cpurad.
This setting applies only to the case when cpuapp is the owner
of those co-oprocessors and shall be updated if that becomes
configurable but currently there are no means to detect core
owner.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This adds a timestamp format mode, that includes the date, which is
usefull, when using realtime for the logging timestamp.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
this way CONFIG_LOG_OUTPUT_FORMAT_CUSTOM_TIMESTAMP
only uses the custom timestamps for
logs that are not send via syslog.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
Demultiplexer was not ready to handle case when log message was
incomplete which was followed by other log messages. Such scenario
could occur if there was a fault that happen during logging of
a message. In that case incomplete message was followed by valid
messages (fault report) and this fault report was not handled
because processing was blocked waiting for completion of a
message which preceeded fault report.
Since it is expected that some messages may be incomplete a
garbage collection mechanism is added. When start of a message is
received timestamp is logged and list of incomplete messages
is checked for 'old' messages which persist in incomplete state
for long. When message timeouts it is closed and marked as
invalid. It unblocks processing of following messages.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
write_data function which was writing to STMESP data registers was
starting by writing words and tail was written using byte access.
However, RISCV core does not support unaligned access and on Cortex-M33
even if supported it is faster to do aligned access. Reworked
write_data to start first by writing data using byte or half word
access until data pointer is word aligned, then word access is used
and finally tail is written using byte or half word access.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
For code clarity, this commit adjusts the use of `return` statements
in functions with a void return type as follows:
- Transform `return foo();` into separate statements:
`foo();`
`return;`
- Remove unnecessary `return` statements when
they don't affect control flow.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Add support for standalone mode where data written to STMESP is
decoded on chip to a human-readable strings.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Add module which demultiplexes stream of log message which are
encoded into STPv2 stream by log_frontend_stmesp. There are 3 types of
messages that can be present in the stream:
- Log message (starts with DMTS32, followed by Dx and closed by FLAG)
- Tracepoint (FLAGTS or DMTS32)
- STM HW event (DMTS8 on 0x80 master and 0x00 channel)
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
As there are more frontends coming in the future move existing
frontend to the dedicated directory (like backends).
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Change to depend on LOG_DICTIONARY_DB which is broader than
LOG_DICTIONARY_SUPPORT which is set only when log_output
supports dictionary mode. However, it is possible that
log_output is not used when dictionary mode is used. Database
generation is always enabled when dictionary mode is used.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Using the immediate logging option from LLEXT modules requires
one more symbol export.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
If CONFIG_LOG_BACKEND_SHOW_COLOR is disabled, error and warning
lines are still being outputted with color, which is contrary to
what the Kconfig says. So change the color settings for error
and warning lines to no color if this Kconfig is disabled.
The log_output test is also amended to account for this.
Though the test is not skipped as no color is still some colors
(... well... maybe).
Fixes#77150
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Add missing braces to comply with MISRA C:2012 Rule 15.6 and
also following Zephyr's style guideline.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
It's usual to show debug logs as blue.
Showing dbg and info with different colors are good,
but it's preferable to keep info logs with default
color.
Signed-off-by: Félix Piédallu <felix@piedallu.me>
90ab94f61d added a change that source name pointers were not stored
in the const data structure associated with a logging source. That was
done because those string pointers were invalid (on purpose pointing to
non-existing memory) and reading those strings could lead to a fault.
However, those pointers are used by scripts which are building the
dictionary database and after this change script was no longer
able to retrieve source names from elf file and database was incomplete.
This patch brings back storing of source name string pointers but in
API for reading those source names guards are added to not return
invalid addresses.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Make appending to the newest log file in the fs logging backend optional.
By default, if there is still free space in the latest log file,
the fs logging backend appends to it on startup. This is useful for saving
space and avoiding the removal of older log files, if the maximum number
of log files has been reached. The drawback of this behavior is,
that log files that got appended can not be decoded, if the firmware
has changed between startups, for instance by an update,
since the log_dictionary.json used for decoding has also changed.
Therefore, it may be desirable to deactivate appending to log files.
Signed-off-by: Niklas Fabian <niklas.fabian@lemonbeat.com>
Reduce the size of the ble notification if the length of
the line output is less than the current mtu size.
Signed-off-by: Victor Chavez <vchavezb@protonmail.com>
The TPIU supports serializing the data stream both using an UART-like NRZ
protocol as well as using Manchester encoding. Using Manchester encoding
has the advantage that it enables receivers that support it to recover the
clock from the SWO signal itself. This is particularly useful in situations
where the clock rate changes dynamically or is unknown (for example when
debugging the clock tree setup or working with a device with a misbehaving
main oscillator).
Add a Kconfig choice to switch the protocol, keeping the current default of
using the NRZ encoding.
Signed-off-by: Florian Larysch <larysch@fixme.gmbh>
When CONFIG_LOG_OUTPUT is enabled that indicates that logging
strings are used by the runtime logging processing so they should
not be stripped from the binary.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
When userspace is used and frontend was used for logging then runtime
filtering was failing because in user context filtering data was
accessed and filtering data is in the kernel space. Fixing that and
adding runtime filtering to the pre frontend function which is
already executed in the kernel space and filter data can be
accessed.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Logging string stripping depends on LOG_DICTIONARY_SUPPORT being
enabled and it was not set in UART dictionary frontend.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Log frontend supports runtime filtering so it should be
allowed to enable it even when only frontend is used with
no backends.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
If logging packages need to be created at runtime, the format
strings need to be in memory for the packaging code to know
what to be packed. So prevent stripping the logging string
section if CONFIG_LOG_ALWAYS_RUNTIME is enabled.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Check if the calculated package length exceeds the maximum possible
value.
Fixes#75015
Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
`CONFIG_LOG_DOMAIN_ID` has been deprecated for years and
shouldn't be used according to its documentation, remove it.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
The `LOG_BACKEND_FORMAT_TIMESTAMP` Kconfig currently depends on
a list of hardcoded backends.
Let's modify it to depend on an intermediary Kconfig
`LOG_BACKEND_SUPPORTS_FORMAT_TIMESTAMP` instead, which can be
selected by a OOT log backend.
Updated all exisitng supported backends to select this new
Kconfig.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
The POSIX_CLOCK option does not correspond to any standard
option. It was used to active features of several distinct
POSIX Options and Option Groups, which complicated API and
application configuration as a result.
POSIX_CLOCK is being deprecated in order to ensure that Zephyr's
POSIX Kconfig variables correspond to those defined in the
specification, as of IEEE 1003.1-2017.
Additionally, CONFIG_TIMER is being deprecated because it does
not match the corresponding POSIX Option (_POSIX_TIMERS).
With this deprecation, we introduce the following Kconfig
options that map directly to standard POSIX Option Groups by
simply removing "CONFIG_":
* CONFIG_POSIX_TIMERS
Similarly, we introduce the following Kconfig options that
map directly to standard POSIX Options by simply removing
"CONFIG":
* CONFIG_POSIX_CLOCK_SELECTION
* CONFIG_POSIX_CPUTIME
* CONFIG_POSIX_DELAYTIMER_MAX
* CONFIG_POSIX_MONOTONIC_CLOCK
* CONFIG_POSIX_TIMEOUTS
* CONFIG_POSIX_TIMER_MAX
In order to maintain parity with the current feature set, we
introduce the following Kconfig options that map directly to
standard POSIX Option Groups by simply removing "CONFIG_":
* CONFIG_POSIX_MULTI_PROCESS - sleep()
Similarly, in order to maintain parity with the current feature
set, we introduce the following additional Kconfig options that
map directly to standard POSIX Options by simply removing
"CONFIG":
* CONFIG_XSI_SINGLE_PROCESS - gettimeofday()
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.
Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.
Updated the includes path of in-tree sources accordingly.
Most of the changes here are scripted, check the PR for more
info.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
This commit is to fix a warning which is reported in Coverity scan
after device runtime pm is enabled.
Signed-off-by: Roger Wang <roger1.wang@intel.com>
There's such a case captured. When log immediate mode is enabled, each log
message is output per character. However, "log_output_flush()" function is
still called with zero data length at the end of "log_output_process()".
Better to make "buffer_write()" returns immediatley if buffer data
length is zero.
Signed-off-by: Dong Wang <dong.d.wang@intel.com>
Because of include file changes, we now need to include both
hostname.h and net_if.h in the syslog logging module directly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
There are use cases where it's beneficial to trigger the log
thread to process log messages as soon as able instead of waiting
for the processing timer or threshold triggers. An example would be
to flush the log buffer before entering the idle thread after
forcing a system power state.
Signed-off-by: Corey Wharton <xodus7@cwharton.com>
Return an error if the provided cache configuration is not large enough
to hold a single entry. An empty `active` and `idle` list causes NULL
dereferences in `log_cache_get`.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Instead of having the boards override the default
in their Kconfig.defconfig
let's just default to IMMEDIATE logging mode in the main
definition if we are building for a ARCH POSIX board.
This avoid issues w dependencies being lost if not duplicated
correctly.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Backend index must also be incremented, when backend is not an autostart
backend. Otherwise, the resulting bit field can not be used to address
a backend by index; autostart field would have to be taken into account.
Signed-off-by: Torsten Robitzki <Torsten@Robitzki.de>