Module si_trace_print::stack
source · Expand description
Functions to store a stack offset for indented trace prints and
return the appropriate preprint str
.
Library users should use macros provided in printers
.
Function stack_offset_set
is to force the setting of the “original” stack
depth for a thread.
Functions sn
, so
, sx
, and sñ
return a &str
to preprint before
tracing messages. These functions are used by macros in printers
.
The stack-based indentation amount depend on optimization settings.
In an optimized build, an inlined function will not add to the stack
depth.
Adding explicit inline
attributes may fix such a problem.
According to The Rust Performance Book:
Inline attributes do not guarantee that a function is inlined or not inlined, but in practice,
#[inline(always)]
will cause inlining in all but the most exceptional cases.
At worst, the indentation may not change and all printing will align at the same column.
Lack of indentation may occur in a --release
build or other optimized
builds.
Functions
- Return a string of spaces that is a multiple of the current stack offset with trailing
→
signifying entering a function. - Return a string of spaces that is a multiple of the current stack offset with one trailing space.
- Function
stack_offset_set
gets a baseline “offset” value (retrieved from private functionstack_depth
) and stores it in the private globalSTACK_OFFSET_TABLE
.stack_offset_set
can be explicitly called to force the “original” stack depth value to be set. This explicit call must be done before calling dependent macros (e.g.po()
,den()
, etc.) and before calling any dependent functions (e.g.so()
), otherwise the call will be ignored. Functionstack_offset_set
is implicitly called by the macros inprinters
. - Return a string of spaces that is a multiple of the current stack offset with trailing
←
signifying exiting a function. - Return a string of spaces that is a multiple of the current stack_offset with trailing
↔
signifying entering and exiting a function.