PebbleOS
Loading...
Searching...
No Matches
Macros
Log hashing

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.
 

Detailed Description

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:

The .log_strings section holds:

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.

Macro Definition Documentation

◆ LOG_STRINGS_SECTION_ADDRESS

#define LOG_STRINGS_SECTION_ADDRESS   0xC0000000

Address the .log_strings section is linked at; tokens are offsets from it.

◆ MSGID_CORE_AND_HASH_MASK

#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.

◆ MSGID_STR_AND_HASH_MASK

#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.

◆ NEW_LOG_VERSION

#define NEW_LOG_VERSION   "0102"

Version of the .log_strings format, major and minor on two digits each.

◆ PACKED_CORE_MASK

#define PACKED_CORE_MASK   0x03

Mask of the core number, 2 bits.

◆ PACKED_CORE_OFFSET

#define PACKED_CORE_OFFSET   30

Position of the core number in a message ID.

◆ PACKED_HASH_MASK

#define PACKED_HASH_MASK   0x7FFFF

Mask of the string offset, 19 bits.

◆ PACKED_HASH_OFFSET

#define PACKED_HASH_OFFSET   0

Position of the string offset in a token.

◆ PACKED_LEVEL_MASK

#define PACKED_LEVEL_MASK   0x07

Mask of the packed level, 3 bits.

◆ PACKED_LEVEL_OFFSET

#define PACKED_LEVEL_OFFSET   20

Position of the packed level in a token.

◆ PACKED_NUM_FMT_MASK

#define PACKED_NUM_FMT_MASK   0x07

Mask of the number of format conversions, 3 bits.

◆ PACKED_NUM_FMT_OFFSET

#define PACKED_NUM_FMT_OFFSET   29

Position of the number of format conversions in a token.

◆ PACKED_STR1FMT_MASK

#define PACKED_STR1FMT_MASK   0x07

Mask of the first string conversion index, 3 bits.

◆ PACKED_STR1FMT_OFFSET

#define PACKED_STR1FMT_OFFSET   26

Position of the first string conversion index in a token.

◆ PACKED_STR2FMT_MASK

#define PACKED_STR2FMT_MASK   0x07

Mask of the second string conversion index, 3 bits.

◆ PACKED_STR2FMT_OFFSET

#define PACKED_STR2FMT_OFFSET   23

Position of the second string conversion index in a token.

◆ PACKED_STRFMTS_MASK

#define PACKED_STRFMTS_MASK   0x3f

Mask of both string conversion indices, 6 bits.

◆ PACKED_STRFMTS_OFFSET

#define PACKED_STRFMTS_OFFSET   23

Position of both string conversion indices in a token.

◆ STRINGIFY

#define STRINGIFY (   a)    STRINGIFY_NX(a)

Turn the expansion of the argument into a string literal.

Parameters
aArgument.

◆ STRINGIFY_NX

#define STRINGIFY_NX (   a)    #a

Turn the argument into a string literal without expanding it.

Parameters
aArgument.