Commit graph

18 commits

Author SHA1 Message Date
Benjamin Cabé 779636415c lib: cbprintf: doc: Doxygen cleanup
Fixed a couple typos and added @deprecated tags for deprecated macros.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-07-20 16:25:22 +02:00
Gerard Marull-Paretas 866c176410 doc: doxygen: create utilities group
Add a new top-level for general utilities, like utility functions,
linear range API, time utils, etc. This category should be used by stuff
that is not strictly bound to the OS, like are OS services.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-06-05 20:21:09 -04:00
Tom Burdick dbc366918d tests: Enable qemu_xtensa logging tests
Enables logging testing for qemu_xtensa along with the fixes needed to
correctly run the tests.

Several tests in log_api rely on being able to calculate the size of
the message in the mpsc_pbuf to know when an overflow occurs. The
size being calculated assumed a ROUND_UP size alignment to sizeof(long
long). On xtensa this is actually 16 bytes as defined by
CBPRINTF_PACKAGE_ALIGNMENT.

Changes the size calculation for SIMPLE_MSG_LEN to account for this.

The second issue was a misaligned package that would cause reading
from the incorrect memory when going to format the package with cbpprintf.

Fixes the padding used to align the package in cbprintf.h and adds a build
assert ensuring correct alignment when building against xtensa in both
cbprintf.h and log_msg.h.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2022-11-04 11:02:27 -04:00
Keith Packard cb5c440525 picolibc: Fix a couple of printfcb wrapper macros
Picolibc aliases the printfcb functions directly to printf
equivalents. There were a couple of these macros that were broken.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-10-31 17:17:42 +09:00
Krzysztof Chruscinski a7224830ce lib: os: cbprintf: Mechanism for detecting %p in static package
Static packaging is using only argument types to build a package. There
is one case where analysing argument type only is not enough to
determine package content. That is %p with (unsigned) char pointer vs
%s. In case of %s a string might need to be appended to the package
and in case of %p it must be avoided. Format string analysis is required
to distinguish those two cases.
In order to speed up the runtime inspection, additional information is
added to a static package. That is index of the string argument (where
first argument has index 0). This information allows quick format string
inspection where nth format specifier is found and checked if it is a
pointer format specifier.
Inspection algorithm is added to cbprintf_package_convert() and if %p
is found then data for that argument is discarded. Additionally, log
warning is printed with suggestion to cast pointer argument to void *
to avoid confusion. It is desired to get rid of this ambiguity because
there are going to be logging configurations where strings are stripped
from a binary and runtime inspection cannot be performed.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-09-19 10:14:23 +00:00
Daniel Leung 203c4c2e13 lib: os: cbprintf: move padding for xtensa from hdr_ext to hdr
This moves padding needed for Xtensa in the cbprintf package header
from the extended header to the simple header. This is due to
the cbprintf packaging function uses the simple header to calculate
offset. This results in the padding not being there in the package,
and the printing function reading incorrect data in the package.

This was discovered while looking into #49016. Without the padding
in the simple header, turning on tagged argument on cbprintf would
crash on qemu_xtensa.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-09-05 10:16:07 +02:00
Rob Barnes f3375af4b6 cbprintf: Remove unnecessary downcast
Downcast from const void* to void* is unnecessary since the signature of
memcpy expects a const in second param. This downcast will raise a
compile error when -Werror=cast-qual is on.

Signed-off-by: Rob Barnes <robbarnes@google.com>
2022-08-31 10:21:42 +00:00
Krzysztof Chruscinski bb74b4f028 lib: os: cbprintf: Renamed flags used for conversion function
At some point, package copy function was extended and renamed
to cbprintf_package_convert. However, flags used by this
function were not renamed and used contained COPY idiom.
Deprecating flags with COPY and replacing them with flags
with CONVERT idiom to match function which is utilizing them.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-08-26 12:52:08 +02:00
Daniel Leung 7dc20978e3 lib: os: cbprintf: fix typo exteral -> external
The cbprintf formatter cbvprintf_exteral_formatter_func has a typo
in it with a missing 'n'. So add it.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-08-17 08:08:46 +00:00
Yuval Peress 82caf98dde cbprintf: fix missing field initializer warning
When compiling with '-Werror=missing-field-initializers', the cbprintf
header causes an error since 'off' isn't initialized.

Signed-off-by: Yuval Peress <peress@google.com>
2022-07-19 10:29:53 +02:00
Keith Packard 2d20faab47 lib/os: Replace cbvprintf and printfcb family when using picolibc
Picolibc already provides the functionality offered by cbprintf, so
there's no reason to use the larger and less functional version included
in zephyr.

Signed-off-by: Keith Packard <keithp@keithp.com>
2022-06-27 12:47:25 +02:00
Georgij Cernysiov a8fbdf72f7 lib: os: cbprintf: fix cbprintf_enums include path
Corrects `cbprintf_enums.h` include path to contain
<zephyr/...> prefix.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2022-06-09 18:28:47 +02:00
Daniel Leung aff6e8b2f7 lib: os: cbprint: enable tagged arguments for packaging
This adds some bits to support tagged arguments to be used for
packaging. If enabled, the packaging function no longer looks at
the format strings to determine the types of arguments, but
instead, each argument is tagged with a type by preceding it
with another argument as type (integer). This allows the format
strings to be removed from the final binary to conserve space.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-06-08 00:15:55 +09:00
Gerard Marull-Paretas fb9b3bcd93 include: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all includes within
include directory to the new prefix <zephyr/...>. Note that the
conversion has been scripted, refer to zephyrproject-rtos#45388 for more
details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:03:00 +02:00
Krzysztof Chruscinski 07322b85c9 lib: os: cbprintf: Add function for converting package
Extend package copying functionality by adding function for converting
a package. Function gets callback+context pair and converted package
is part by part passed to that callback. Contrary to typical sprintf
callback which works on chars, callback works with buffers.

Existing cbprintf_package_copy function is implemented as static
inline and uses new cbprintf_package_convert API.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-05-04 18:56:55 -04:00
Guennadi Liakhovetski 462bd8abc2 sparse: fix all errors
sparse complains about cbprintf incompatible callback type and
incorrect size of struct __va_list. Add exceptions to silence those
errors.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2022-04-28 08:54:21 -04:00
Daniel Leung 3539db43ef lib: os: cbprintf: use TOOLCHAIN_HAS_C_GENERIC macro instead
Since toolchain.h supplies the macro TOOLCHAIN_HAS_C_GENERIC to
indicate if the compiler supports C Generic, there is no need to
do the long chain of macro arithmetic in cbprintf header file.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2022-04-13 08:29:23 -05:00
Yuval Peress 53ef68d459 include: Prefix includes to use a scope
Move include paths and add new target_include_directories to support
backwards compatibility:
* /include -> /include/zephyr
  example: <irq.h> -> <zephyr/irq.h>

Issue #41543

Signed-off-by: Yuval Peress <peress@google.com>
2022-04-08 19:03:32 +02:00
Renamed from include/sys/cbprintf.h (Browse further)