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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
`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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
When UART dictionary frontend is used strings can be removed
from the binary.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Add option to remove string literals which are constant and
never touched by the firmware. It can save significant amount
of RO memory.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Some compilers (e.g. riscv32) does not handle well complex macros
for logging. Generated code is bigger than expected (e.g. riscv32
code is almost twice bigger than cortex-m code). Use of logging can
lead to unexpected code increase.
To handle that an analysis of the zephyr code base was performed and
it shown that 75-80% of logs are simple strings with 0 arguments
(~45%), one 32 bit argument (~26%) or two 32 bit arguments (~6%).
Given that a set of dedicated macro were created which are applied
to those 3 cases which on 32 bit platform create very simple log
messages without padding or alignment needed.
Such dedicated macros save up to 40% of code (riscv32) and also
executes 30% faster (arm cortex and riscv32).
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Extend frontend API with optional set of functions which can
be used when simplified log message handling is enabled. If this
mode is enabled then there are dedicated macros for processing the
most common messages (string + 0-2 word arguments). Using this API
can speed up the processing of messages that are the most common.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>