-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logging: support emitting MIPI Sys-T catalog messages #43784
logging: support emitting MIPI Sys-T catalog messages #43784
Conversation
The following west manifest projects have been modified in this Pull Request:
Note: This message is automatically posted and updated by the Manifest GitHub Action. |
b351e6d
to
34f3f7e
Compare
Updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Started to look into it. Wasn't yet involved much in dictionary/catalog logging.
I have 2 question:
- why string from rodata are not cataloged but appended to the log message?
- how to parse catalog mipi syst sample? I run the sample and wanted to run
log_parser.py
with xml file as database but got error.
include/logging/log_msg2.h
Outdated
@@ -195,19 +195,20 @@ enum z_log_msg2_mode { | |||
#define Z_LOG_MSG2_STACK_CREATE(_cstr_cnt, _domain_id, _source, _level, _data, _dlen, ...) \ | |||
do { \ | |||
int _plen; \ | |||
uint32_t flags = CBPRINTF_PACKAGE_FIRST_RO_STR_CNT(_cstr_cnt) | \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you could use similar approach as i did in multi-domain PR and create a define:
https://github.com/zephyrproject-rtos/zephyr/blob/45c528dfde3d38abf9153f1bcb139b2fafb0b0c8/include/logging/log_msg2.h#L138
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated and replaced it with a macro.
include/logging/log_msg2.h
Outdated
@@ -221,8 +222,7 @@ do { \ | |||
#ifdef CONFIG_LOG_SPEED | |||
#define Z_LOG_MSG2_SIMPLE_CREATE(_cstr_cnt, _domain_id, _source, _level, ...) do { \ | |||
int _plen; \ | |||
CBPRINTF_STATIC_PACKAGE(NULL, 0, _plen, Z_LOG_MSG2_ALIGN_OFFSET, \ | |||
CBPRINTF_PACKAGE_FIRST_RO_STR_CNT(_cstr_cnt), \ | |||
CBPRINTF_STATIC_PACKAGE(NULL, 0, _plen, Z_LOG_MSG2_ALIGN_OFFSET, flags, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will it compile, flags variable is not created here. Use define as suggested above would result in single place of flags definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird... ran through twister without any issue...
Sys-T does not use catalog for string arguments. There is no way to tag whether a string in the argument list is a string in catalog or a full string. Therefore, each string argument needs to be replaced with the full string.
There is a |
34f3f7e
to
c58936a
Compare
@dcpleung does it mean that strings are inserted as value into the stream and not appended like in cbprintf package? Is this somehow standardized or would it be possible to somehow send package as is (converted to mipi syst stream)? Current approach requires quite a lot of processing. Also when package is statically created then ro/rw indexes will be appended for char pointers even when they were used for One more thing. I didn't see |
@nordic-krch In the MIPI Sys-T Spec, section 9.1.4, the example shows the C strings are copied to output. So a format string of As for As for sending the |
right, I only got to mipi STP specification and couldn't find anything there. Seems that i need to get into mipi_syst specification then. |
With the new structure of the cbpprintf packages, the Python parser needs to be updated to skip extra bytes before reaching the string table. Signed-off-by: Daniel Leung <[email protected]>
The MIPI Sys-T library can now take a format string with a variable argument list so there is no need for the temporary buffer anymore. This saves some stack space in v1 immediate mode. Signed-off-by: Daniel Leung <[email protected]>
Compilers often combine strings to conserve space, if one string is a perfect substring of another one towards the end. So add another string in the test to make sure dictionary logging is still working correctly under this scenario. Signed-off-by: Daniel Leung <[email protected]>
Fixes some easy pylint warnings. Signed-off-by: Daniel Leung <[email protected]>
This changes the database generation to actually extracting individual strings instead of stuffing the whole binary sections into the database. This allows the generation script to be extended to accommodate more output formats. Note that if CONFIG_LOG2_FMT_SECTION is enabled, the format strings are in log_strings_sections, and also have associated debug symbols in DWARF. So there is no need to manually extract them. Signed-off-by: Daniel Leung <[email protected]>
This changes the script to allow output format to be specified. Currently, only JSON is support. This will allow supporting other formats in the future. Signed-off-by: Daniel Leung <[email protected]>
This adds the ability to the dictionary logging database generation script to output MIPI Sys-T collateral in XML. This will allow usage of catalog logging under Sys-T, which is similar to dictionary logging. Signed-off-by: Daniel Leung <[email protected]>
This updates the mipi-sys-t module to support prepared argument list for catalog messages. Signed-off-by: Daniel Leung <[email protected]>
This adds a new CONFIG_LOG2_MSG_PKG_ALWAYS_ADD_RO_STRING_IDXS kconfig. If enabled, the log message packages will always have the indexes of read-only string arguments appended to the package. This will be selected only by those backends requiring it. Signed-off-by: Daniel Leung <[email protected]>
MIPI Sys-T catalog messages are similar to dictionary logging where an ID is emitted instead of the format string. This allows the format strings to be removed from the final binary to save a few bytes. This adds the necessary bits to determine to emit catalog messages when appropriate. Note that this implementation copies the argument list as-is with string arguments stitched together since the format strings are assumed to have been removed and they cannot be examined to properly convert the argument lists into catalog message payloads. Because of this, various build asserts are there to avoid building for configurations where they are known not to work. Signed-off-by: Daniel Leung <[email protected]>
Compilers often combine strings to conserve space, if one string is a perfect substring of another one towards the end. So add another string in the test to make sure sys-t with catalog messages is still working correctly under this scenario. Signed-off-by: Daniel Leung <[email protected]>
This adds qemu_x86_64 and qemu_cortex_a53 to make sure 64-bit support for Sys-T is not broken in the future. Signed-off-by: Daniel Leung <[email protected]>
This adds to sample.yaml to build for MIPI Sys-T catalog message support. Note that the current implementation of emitting Sys-T catalog messages does not support 64-bit and architectures having additional alignment requirements. So only allow qemu_x86 and mps2_an385 at the moment. Signed-off-by: Daniel Leung <[email protected]>
c58936a
to
57a8a92
Compare
Rebased after #43520 was merged. |
Add myself to the CODEOWNERS for samples/subsys/logging/syst to make checkpatch happy, and to get notifications of changes in the sample. Signed-off-by: Daniel Leung <[email protected]>
Add a README.rst on how to build the MIPI Sys-T logging sample and how to parse the output. Signed-off-by: Daniel Leung <[email protected]>
Added a README for the syst sample to show how to get back readable log messages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment.
I wonder if it wouldn't be better to just dump log message as is (similar to dictionary backend) or put it into some custom mipi STP stream and then have some python script that converts this stream to mipi syst format. That would be simpler on device side, handle %p
and ro strings could also be sent by address and fetched on the host.
#endif | ||
|
||
#ifdef CONFIG_64BIT | ||
#define MIPI_SYST_CATMSG_ARGS_COPY MIPI_SYST_CATALOG64_ARGS_COPY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a point to have it as 64bit is not supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully we can support 64-bit in the near future.
Thanks @dcpleung |
This is probably going to be problematic as people won't be able to use arbitrary MIPI tool to parse the log messages. Having a standard spec means multiple tools can be used (as drop-in replacement). Requiring an additional parsing steps breaks this model. I don't think people needing log messages through MIPI would want to deviate from standard. |
MIPI Sys-T catalog messages are similar to dictionary logging where an ID is emitted instead of the format string. This allows the format strings to be removed from the final binary to save a few bytes. This adds the necessary bits to determine to emit catalog messages when appropriate.
See individual commits for details.