This document explains how producer, service and consumer interact end-to-end during a tracing session, with references to code and IPC requests / responses.
RegisterDataSource
IPC. Nothing more happens on the Producer until this point. Nothing traces by default.EnableTracing
IPC.data_sources
section of the trace config: for each entry, if a matching data source is found in the producer(s) (accordingly to what advertised in step 2):SetupTracing
IPC message, passing a shared memory buffer to the producer(s) (only once for each producer).StartDataSource
IPC message to each producer, for each data source configured in the trace config and present in the producer (if any).TraceWriter
(typically one for each thread).TraceWriter
writes one or more TracePacket
.TraceWriter
takes ownership of shared memory buffer's chunks, using the SharedMemoryArbiter
.TracePacket
, the TraceWriter
will unavoidably cross the chunk boundary (typically 4KB, but can configured to be smaller).TraceWriter
will release the current chunk and acquire a new chunk through the SharedMemoryArbiter
.SharedMemoryArbiter
will, out-of-band, send a CommitDataRequest
to the service, requesting it to move some chunks of the shared memory buffer into the final trace buffer.TracePacket
were fragmented over several chunks, it is possible that some of these chunks are gone from the shared memory buffer and committed into the final trace buffer (step 16). In this case, the SharedMemoryArbiter
will send an other CommitDataRequest
IPC message to request the out-of-band patching of the chunk data into the final trace buffer.{ProducerID (unspoofable), WriterID, ChunkID}
is still present in the trace buffer and if so will proceed to patch it (% checks).FlushRequest
to the service, asking it commit all data on flight in the trace buffers.Flush
request to all producers involved in the trace session.Flush()
all their TraceWriter
and reply to the service flush request.FlushRequest
DisableTracing
IPC request to stop tracing and freeze the content of the trace buffers.StopDataSource
request for each data source in each Producer.ReadBuffers
IPC request (unless it did previously pass a file descriptor to the service when enabling the trace through the write_into_file
field of the trace config).TracePacket(s)
back to the consumer.TraceWriter
sequences will be unaffected.FreeBuffers
(or simply disconnects).