Commit graph

613 commits

Author SHA1 Message Date
Corey Wharton bf114c6b1a logging: add API to trigger immediate processing of logs
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>
2024-05-13 16:06:11 -04:00
Jordan Yates af515ef87b logging: log_cache: ensure cache contains an entry
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>
2024-05-13 16:05:18 -04:00
Michael Stumpf 854685dfbc Fixes small typo in log_backend_fs.c
Signed-off-by: Michael Stumpf <michaelstumpf585@gmail.com>
2024-05-12 11:04:22 -04:00
Alberto Escolar Piedras b304c26c10 logging: Default to IMMEDIATE mode for native targets
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>
2024-04-26 19:48:49 +01:00
Torsten Robitzki c1b07eda84 logging: fix backend index caluculation
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>
2024-04-26 16:09:24 +02:00
Denis Bourqui e3e009a199 logging: Fix backend filter setting
Call filter_set with backend-id instead of backend-index
when applying a filter on all backends.

Signed-off-by: Denis Bourqui <db@rnx.ch>
2024-04-19 18:01:03 +00:00
Ben Wolsieffer 57ed0a7ae9 logging: multidomain_link: fix crash caused by drop notification
The remote domain may send unsolicited Z_LOG_MULTIDOMAIN_ID_DROPPED IPC
messages, which are not handled in log_multidomain_link_on_recv_cb().
With CONFIG_ASSERT=y, this will cause an assertion failure. With asserts
disabled, this message would be treated as a reply to any in progress
request and cause getter_msg_process() to return early. In turn, this
can cause various kinds of memory corruption when the real reply arrives
and the callback reads/writes stack variables that are no longer valid.

Fix this by explicitly ignoring Z_LOG_MULTIDOMAIN_ID_DROPPED, and also
don't treat unrecognized message types as replies.

Signed-off-by: Ben Wolsieffer <benwolsieffer@gmail.com>
2024-04-18 11:12:35 +02:00
Ben Wolsieffer 72cdbcbbba logging: consistently retrieve source ID from remote messages
The log message header "source" field for messages received from a
remote domain contains the source ID, rather than a pointer to the
source data (which would not be valid in the local domain).

msg_filter_check() did not handle this case and obtained a garbage source
ID for remote log messages. This caused an assertion failure in
filter_get().

Consistently handle this by adding a log_msg_get_source_id() function
that returns the source ID for both local and remote messages. This
function was implemented based on code factored out of
log_output_msg_process().

Signed-off-by: Ben Wolsieffer <benwolsieffer@gmail.com>
2024-04-17 14:28:59 +02:00
Ederson de Souza 67bb6db3f8 syscall: Export all emitted syscalls, enabling them for extensions
Linkable loadable extensions can only use syscalls if they are exported
via EXPORT_SYSCALL (or EXPORT_SYMBOL). Instead of enabling used syscalls
one by one, this patch exports all of them automatically via
`gen_syscalls.py`. If CONFIG_LLEXT=n, the section where the exported
symbols live is discarded, so it should be a non-op when llext is not
enabled.

This patch also removes the now redundant EXPORT_SYSCALL macro. Note
that EXPORT_SYMBOL is still useful on different situations (and is
indeed used by the code generated by `gen_syscalls.py`).

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2024-03-20 16:26:54 +00:00
Krzysztof Chruściński 90be983d4d logging: backends: multidomain: Fix compilation warning
Fix compilation warning due to taking member from a packed structure
and assigning it to a pointer. Compiler warns that it may be
unaligned. However, it is ensured that it will be aligned by
operations preceding this assignment.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-03-15 11:36:08 +00:00
Jukka Rissanen 068d23ab78 log: net: Add structured logging support to syslog
Add structured logging support to syslog backend. This means
that meta data can be included to logging output.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-12 09:44:11 +00:00
Jukka Rissanen d5e55d2595 log: net: Depend on full featured libc instead of just newlibc
For time printout, depend on full featured libc like picolibc
instead of just newlibc.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-12 09:44:11 +00:00
Jukka Rissanen 3c8bd58a06 log: net: Add TCP support to syslog transmitter
Allow user to configure the syslog net backend to use TCP
instead of UDP. The syslog server address for TCP needs to
have "tcp://" URI in front of the address, for example the
tcp://192.0.2.2 server address would use TCP as a transport.
If there is no URI, then UDP would be used by default.

See the relevant RFC at https://www.rfc-editor.org/rfc/rfc6587
for details.

Fixes #66728

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-03-12 09:44:11 +00:00
Tom Burdick 0650a88bed llext: Rework hello_world test case to be "simple"
The simple test is there to test the API and simple extensions in
unison. Hello world was intended to be the first not the only extension
being tested.

Also refactors the entry thread to allow for usermode potentially by
passing the pointer to the function symbol rather than having it look it
up directly.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-03-09 14:44:23 +00:00
Fin Maaß 0d776d39bb net: dhcpv4: set log backend net ip via option
Adds the option to set the log_backend_net ip via dhcpv4
option 7.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-03-08 15:18:30 +00:00
Fin Maaß 2b23d1f3f1 log: net: Add log_backend_net_start function
Adds a function to start log_backend_net

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-03-08 15:18:30 +00:00
Fin Maaß 6e12b0210f log: net: move log_backend_net_get() to header
This moves the declaration of log_backend_net_get() to
zephyr/logging/log_backend_net.h

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-03-08 15:18:30 +00:00
Fin Maaß 7bc4ea1e2f log: net: add option to set server ip with struct sockaddr
Adds a function to set the syslog server ip with a struct sockaddr,
so that it can be set without a string.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-03-08 15:18:30 +00:00
Fin Maaß abdfc4b1fe logging: support using real time as timestamp
Adds a option to use real time from posix instant
of the system uptime as the logging timestamp.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-03-06 15:58:43 +00:00
Joakim Andersson ad58b39f41 logging: Add option to not generate dictionary database always
Add option to not generate the logging dictionary database when the
zephyr finale image is created. Instead this database can be created
by its own build target.
This reduces the build time during debugging as the database file is not
required as part of the debugging.

Fix build byproducts not listing the output file.
Add comment so users know which command is executing as this command
can take a long time.

Signed-off-by: Joakim Andersson <joakim.andersson@heimdallpower.com>
2024-03-06 10:38:37 +00:00
Krzysztof Chruściński 44e0a64a90 logging: Fix support for CONFIG_LOG_MSG_APPEND_RO_STRING_LOC
There is an Kconfig option which results in RO string locations
being appended to the cbprintf package of a log message. Option was
not correctly handled, especially optimized API which was recently
added did not support that. Restoring support.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-03-04 14:01:55 +01:00
Jukka Rissanen 508a261286 log: net: Convert syslog network transmitter to use sockets
Convert the network log backend to use socket API instead of
net_context API. This allows the backend to be used also
with socket offloading network drivers.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-02-01 10:22:47 -06:00
Dawid Niedzwiecki ea630294d3 logging: add flag to skip source info
Add a flag to skip printing the source info.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-01-22 14:05:11 -05:00
Erwan Gouriou b98c7942ca pm: console: Use async runtime put to minimize resumption/suspension
When device runtime pm is enabled on console device, do not suspend
device synchronously on each char transmission, but rather use asynchronous
suspension request.
This will save useless and costly suspension/resumption procedure, which
can involve uart device clock suspension but also pin configuration
to sleep state (which itself involves gpio clock activation ...).

On STM32, using asynch device suspension allows to divide by 3 the
transmission time of a character chain.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2024-01-18 10:51:10 +01:00
Gerhard Jörges 2a0e5e93f3 logging: net: update hostname
This commit adds a function that updates the hostname displayed by the
net backend. It is called by the network stack when the hostname is
updated.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2024-01-17 14:42:58 +01:00
Tom Burdick 897553af17 logging: Remove hda log backend
The HDA log backend has been buggy for some time, and the fixes are well
understood. The issue with HDA log as it is implemented today means
there are concurrency and ISR issues where it can deadlock.

The fixes are effectively dropping the usage of ipc to communicate
status, using polling on the hda stream, and having a formatter per call
context (cores + isr) when log mode immediate is enabled to fix log
mangling. However it was found this had a lot of unintentional side
effects that made it difficult to make progress on when it came to
changes of the host side python tooling.

Meanwhile the feature has sat unused for nearly a year. Remove it, and
it can always be revisited in the future if something like it happens to
be needed.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-01-17 09:52:48 +01:00
Krzysztof Chruściński 5bafa25e13 logging: Use strings stripping for dictionary backends
Enabled by default strings stripping for dictionary based
backends.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-01-15 09:58:39 +01:00
Krzysztof Chruściński b9bf596b34 logging: Fix LOG_FMT_SECTION_STRIP Kconfig dependency
Strings stripping was disallowed when LOG_OUTPUT was used. However,
there is a dictionary log_output module which could work with stripped
strings. Dependency is changed to LOG_DICTIONARY_SUPPORT.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-01-15 09:58:39 +01:00
Krzysztof Chruściński c9e2975a96 logging: log_cmds: Add support for frontend runtime filtering
Add support for controlling runtime filtering for frontend.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-01-15 09:57:54 +01:00
Krzysztof Chruściński b819b51fe7 logging: Add support for runtime filtering in frontend
So far frontend supported only compile time filtering. Adding
support for runtime filtering. From runtime filtering perspective
frontend is treated similar to any other backend but since
it is a singleton it has fixed ID.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-01-15 09:57:54 +01:00
Alberto Escolar Piedras bd9836be8c subsys logging: Enable native backend if possible
Let's always enable the native_posix backend even
if the serial is used.
Both can be used at the same time, and:
a) users expect the logger output in the invoking shell even if they
enable the UART
b) Since printk is routed to the logger twister actually needs it
for tests to pass as for native platforms it looks into the stdout
of the process.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-10 10:01:37 +01:00
Fang Huang 37305fa06b logging: mipi_syst: Add CONFIG_LOG_MIPI_SYST_DISABLE_TIMESTAMP
This adds user configurable CONFIG_LOG_MIPI_SYST_DISABLE_TIMESTAMP
Kconfig option to use it for macro MIPI_SYST_PCFG_ENABLE_TIMESTAMP.
Moving macro definition of MIPI_SYST_PCFG_ENABLE_TIMESTAMP from
mipi-sys-t library to platform.h which defaulted to undef.
CONFIG_LOG_MIPI_SYST_DISABLE_TIMESTAMP gives flexibility to users
when needn't use mipi-sys-t protocol timestamp.

Signed-off-by: Fang Huang <fang.huang@intel.com>
2024-01-05 06:40:09 -05:00
Fabio Baltieri a3e39cb0e5 logging: make CONFIG_LOG_ALWAYS_RUNTIME build check less ambiguous
When these fails the compiler just prints "Option must be enabled" with
no reference to what option, so one has to look at the code to find out.
Mention the actual option in the error to make these unambiguous.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-02 10:10:49 +01:00
Kai Meinhard 70ae47587a LOG: DICT: Forward the User Context Void pointer to backend
The dictionary logging passed the full log_output structure
to the backend instead of the user context void pointer.

Signed-off-by: Kai Meinhard <meinhard@gessler.de>
2024-01-02 10:09:27 +01:00
Jordan Yates 5bf8edc85f logging: uart: cleanup device runtime PM checks
`pm_device_runtime_get` and `pm_device_runtime_put` have returned `0`
when device runtime PM is not enabled since #56222. Manually checking
the state is no longer required.

Additionally, the functions have been able to run in an ISR context
since #60785, which removed the need to special case `k_is_in_isr()`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-12-06 18:00:21 -05:00
Guennadi Liakhovetski 69cdc32892 llext: export some symbols
Export some symbols for loadable modules. Also add an
EXPORT_SYSCALL() helper macro for exporting system calls by their
official names.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-12-01 10:08:12 -05:00
Krzysztof Chruściński 465446e5aa logging: Add string validation to detect %p misuse
Logging shall not use character pointers with %p because in
certain configurations it may lead to memory faults. A compile
time detection is added. If faulty usage is detected then
message is replaced with error message which indicates which
message failed and what shall be done (casting to a pointer
of different type).

Validation is enabled only for configurations which remove
strings from binary as otherwise it may impact CI execution
time.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-11-24 09:23:18 +01:00
Henrik Brix Andersen c0c8952739 shell: do not enable subsystem/driver shell modules by default
Do not enable subsystem/driver shell modules by default and stop abusing
CONFIG_SHELL_MINIMAL, which is internal to the shell subsystem, to decide
when to enable a driver shell.

The list of shell modules has grown considerably through the
years. Enabling CONFIG_SHELL for doing e.g. an interactive debug session
leads to a large number of shell modules also being enabled unless
explicitly disabled, which again leads to non-negligible increases in
RAM/ROM usage.

This commit attempts to establish a policy of subsystem/driver shell
modules being disabled by default, requiring the user/application to
explicitly enable only those needed.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-11-20 09:21:40 +01:00
Flavio Ceolin d027d26298 logging: LOG_PRINTK disabled in userspace
LOG_PRINTK needs to run in supervisor mode and since there
is no syscall that allows it to be called from userspace, this
option has to be disabled when userspace is selected.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-16 09:25:21 -05:00
Flavio Ceolin a48e68441b logging: Remove syscall for z_log_msg_runtime_vcreate
This syscall is completely problematic in userspace, it does
not check ANY parameter that is given and it uses variadic argument
that are not copied / checked before being used in the implementation,
instead it just pass a pointer to user stack with unknown data is
blindly consumed by the kernel.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-11-16 09:25:21 -05:00
Mike J. Chen 85fb2873e4 logging: log_core: support CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD value of 1
Previous implementation didn't work if CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD
was set to 1. Minmimum value that worked was 2. A value of 1 would
just be ignored and act like 0 with threshold triggerring disabled.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2023-11-16 09:28:26 +01:00
Yong Cong Sin aa71ed4a1f logging: backend: uart: compile the uart_dev pointer conditionally
Compile the `uart_dev` pointer only when necessary
(when `zephyr,log-uart` is used), this saves 4 bytes in
32-bit systems and 8 bytes in 64-bit systems.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-11-14 12:26:48 -05:00
Yong Cong Sin 2049aa8d16 logging: backend: uart: variable shouldn't have the same name as struct
Rename the `device` variable in the `struct lbu_cb_ctx` to
`uart_dev`, as it is a convention in Zephyr to not have the
struct variable name after the struct.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-11-14 12:26:48 -05:00
Yong Cong Sin 1b4a647950 logging: backend: uart: append index conditionally for compatibility
Updated the `LBU_DEFINE` so that the index is appended only
when given to improve backward compatibility.

When it is depending on the `zephyr,console` node, the backend
is defined as `log_backend_uart`.

When it is depending on the new `zephyr,log-uart` node, the
backend is defined as `log_backend_uart0`,
`log_backend_uart1`, and so on.

Updated the names of the internal variables to follow the same
naming convention.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2023-11-14 12:26:48 -05:00
Chris Friedt c0064f1de8 logging: uart: support multiple instances
Extends the log_backend_uart to support logging to multiple
UART instances.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-11-13 09:47:06 +01:00
Anas Nashif a08bfeb49c syscall: rename Z_OOPS -> K_OOPS
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 684b8fcdd0 syscall: Z_SYSCALL_VERIFY_MSG -> K_SYSCALL_VERIFY_MSG
Rename macros and do not use Z_ for internal APIs.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 4e396174ce kernel: move syscall_handler.h to internal include directory
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Krzysztof Chruściński 01cf78ad39 logging: Do not check pointers when strings are stripped
When logging strings are stripped from the binary prevent
performing check of pointers which requires access to the
string.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-31 09:01:38 +01:00
Krzysztof Chruściński 9470e3d129 logging: Imply strings stripping if dictionary frontend is used
When UART dictionary frontend is used strings can be removed
from the binary.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-10-27 11:42:21 +02:00