Crate cros_tracing

Source

Modules§

trace_marker 🔒
A wrapper around trace_marker tracing features

Macros§

expand_fmt_internal
This macro expands an expression with its value for easier printing. expand_fmt_internal!(my_var) becomes "(my_var: {:?})".
push_descriptors
Macro used to handle fd permanency across jailed devices. If we run crosvm without --disable-sandbox, we need to add the trace_marker file descriptor to the list of file descriptors allowed to be accessed by the sandboxed process. We call this macro to add the file descriptor to the list of keep_rds that the process is allowed to access every time we jail.
setup_trace_marker
Macro used to set up the trace environment categories. It takes a variable number of arguments in pairs of category, boolean value on whether or not the tracing category is enabled at compile time.
trace_event
Returns a Trace object with a new name and index and traces its enter state, if the given category identifier is enabled. Extra args can be provided for easier debugging. Upon exiting its scope, it is automatically collected and its exit gets traced.
trace_event_begin
Begins a tracing event context in the given category, it increases the counter of the currently traced events for that category by one.
trace_event_end
Ends a tracing event context in the given category, it decreases the counter of the currently traced events for that category by one.
trace_simple_print
Prints a single non-scoped message without creating a trace context. The tagged variant lets us enable or disable individual categories.
zero_internal
This macro is used as a placeholder to let us iterate over the compile-time allocated vector of categories when we statically initialize it. This macro should only be used internally to this crate.

Structs§

Trace
A trace context obtained from a trace_event!() call.

Enums§

TracedCategories
The tracing categories that the trace_marker backend supports.

Statics§

CATEGORY_COUNTER
Vector counting how many tracing event contexts are running for each category.
ENABLED_CATEGORIES
Vector used to test if a category is enabled or not for tracing.
EVENT_COUNTER
Sequential identifier for scoped trace events. This unique identifier is incremented for each new trace_event() call.

Functions§

init
Initializes the trace_marker backend. It attepts to open the trace_marker file and keep a reference that can be shared throughout the lifetime of the crosvm process.
push_descriptors_internal
Platform-specific implementation of the push_descriptors! macro. If the trace_marker file has been initialized properly, it adds its file descriptor to the list of file descriptors that are allowed to be accessed when the process is jailed in the sandbox.
trace_simple_print_internal
Platform-specific implementation of the trace_simple_print! macro. If tracing is enabled on the system, it writes the given message to the trace_marker file.