|
PebbleOS
|
Compile-time replacement of log strings by tokens (CONFIG_LOG_HASHED).
More...
Macros | |
| #define | NEW_LOG_VERSION "0102" |
Version of the .log_strings format, major and minor on two digits each. | |
| #define | LOG_STRINGS_SECTION_ADDRESS 0xC0000000 |
Address the .log_strings section is linked at; tokens are offsets from it. | |
| #define | PACKED_CORE_OFFSET 30 |
| Position of the core number in a message ID. | |
| #define | PACKED_CORE_MASK 0x03 |
| Mask of the core number, 2 bits. | |
| #define | PACKED_NUM_FMT_OFFSET 29 |
| Position of the number of format conversions in a token. | |
| #define | PACKED_NUM_FMT_MASK 0x07 |
| Mask of the number of format conversions, 3 bits. | |
| #define | PACKED_STR1FMT_OFFSET 26 |
| Position of the first string conversion index in a token. | |
| #define | PACKED_STR1FMT_MASK 0x07 |
| Mask of the first string conversion index, 3 bits. | |
| #define | PACKED_STR2FMT_OFFSET 23 |
| Position of the second string conversion index in a token. | |
| #define | PACKED_STR2FMT_MASK 0x07 |
| Mask of the second string conversion index, 3 bits. | |
| #define | PACKED_STRFMTS_OFFSET 23 |
| Position of both string conversion indices in a token. | |
| #define | PACKED_STRFMTS_MASK 0x3f |
| Mask of both string conversion indices, 6 bits. | |
| #define | PACKED_LEVEL_OFFSET 20 |
| Position of the packed level in a token. | |
| #define | PACKED_LEVEL_MASK 0x07 |
| Mask of the packed level, 3 bits. | |
| #define | PACKED_HASH_OFFSET 0 |
| Position of the string offset in a token. | |
| #define | PACKED_HASH_MASK 0x7FFFF |
| Mask of the string offset, 19 bits. | |
| #define | MSGID_STR_AND_HASH_MASK ((PACKED_STRFMTS_MASK << PACKED_STRFMTS_OFFSET) | (PACKED_HASH_MASK << PACKED_HASH_OFFSET)) |
| Mask of the string indices and string offset of a message ID. | |
| #define | MSGID_CORE_AND_HASH_MASK ((PACKED_CORE_MASK << PACKED_CORE_OFFSET) | (PACKED_HASH_MASK << PACKED_HASH_OFFSET)) |
| Mask of the core number and string offset of a message ID. | |
| #define | STRINGIFY_NX(a) #a |
| Turn the argument into a string literal without expanding it. | |
| #define | STRINGIFY(a) STRINGIFY_NX(a) |
| Turn the expansion of the argument into a string literal. | |
Compile-time replacement of log strings by tokens (CONFIG_LOG_HASHED).
Each PBL_LOG call site places "file:line:level:color:format" in the .log_strings section, which is linked at LOG_STRINGS_SECTION_ADDRESS, outside the firmware image, and logs a token instead of the string. The host turns tokens back into messages with the dictionary extracted from the ELF file.
Token layout:
%s conversions, 3 bits each, 0 for none;.log_strings (512 KiB).The .log_strings section holds:
.log_string.header: "NL\<major\>\<minor\>:\<offset mask\>=\<token list\>", the format version and description of the entries;.log_core_number: "CORE\<number\>", the core the strings belong to;.log_string: the strings of every call site, plus "MODULE:\<file\>:\<module\>" entries emitted by PBL_LOG_MODULE_DEFINE() and PBL_LOG_MODULE_DECLARE() that map files to log modules and are never referenced by a token.Limitations: at most 7 conversions per message, at most 2 of them %s, without flags or width; no %%; only arguments of 32 bits or less (see SPLIT_64_BIT_ARG()). Formats breaking them are not detected at build time. The code must be built with -Os, or the token computation is not folded.
| #define LOG_STRINGS_SECTION_ADDRESS 0xC0000000 |
Address the .log_strings section is linked at; tokens are offsets from it.
| #define MSGID_CORE_AND_HASH_MASK ((PACKED_CORE_MASK << PACKED_CORE_OFFSET) | (PACKED_HASH_MASK << PACKED_HASH_OFFSET)) |
Mask of the core number and string offset of a message ID.
| #define MSGID_STR_AND_HASH_MASK ((PACKED_STRFMTS_MASK << PACKED_STRFMTS_OFFSET) | (PACKED_HASH_MASK << PACKED_HASH_OFFSET)) |
Mask of the string indices and string offset of a message ID.
| #define NEW_LOG_VERSION "0102" |
Version of the .log_strings format, major and minor on two digits each.
| #define PACKED_CORE_MASK 0x03 |
Mask of the core number, 2 bits.
| #define PACKED_CORE_OFFSET 30 |
Position of the core number in a message ID.
| #define PACKED_HASH_MASK 0x7FFFF |
Mask of the string offset, 19 bits.
| #define PACKED_HASH_OFFSET 0 |
Position of the string offset in a token.
| #define PACKED_LEVEL_MASK 0x07 |
Mask of the packed level, 3 bits.
| #define PACKED_LEVEL_OFFSET 20 |
Position of the packed level in a token.
| #define PACKED_NUM_FMT_MASK 0x07 |
Mask of the number of format conversions, 3 bits.
| #define PACKED_NUM_FMT_OFFSET 29 |
Position of the number of format conversions in a token.
| #define PACKED_STR1FMT_MASK 0x07 |
Mask of the first string conversion index, 3 bits.
| #define PACKED_STR1FMT_OFFSET 26 |
Position of the first string conversion index in a token.
| #define PACKED_STR2FMT_MASK 0x07 |
Mask of the second string conversion index, 3 bits.
| #define PACKED_STR2FMT_OFFSET 23 |
Position of the second string conversion index in a token.
| #define PACKED_STRFMTS_MASK 0x3f |
Mask of both string conversion indices, 6 bits.
| #define PACKED_STRFMTS_OFFSET 23 |
Position of both string conversion indices in a token.
| #define STRINGIFY | ( | a | ) | STRINGIFY_NX(a) |
Turn the expansion of the argument into a string literal.
| a | Argument. |
| #define STRINGIFY_NX | ( | a | ) | #a |
Turn the argument into a string literal without expanding it.
| a | Argument. |