TRACE-CMD.DAT.V(5)
๐ trace-cmd.dat.v7 โ trace-cmd version 7 file format ๐
okay so this is the trace-cmd.dat.v7 page from the libtracefs Manual, and bestie, it is literally the blueprint for the trace.dat file. Every byte has a job. No cap. ๐
โจ NAME โจ
trace-cmd.dat.v7 โ trace-cmd version 7 file format
๐ธ SYNOPSIS ๐ธ
trace-cmd.dat ignore
๐ DESCRIPTION ๐
The trace-cmd(1) utility produces a trace.dat file. It may also be named anything, depending on whether the user specifies a different output name, but it still has to have a certain binary format. The file is used by trace-cmd to save kernel traces into it and to be able to extract the trace from it at a later point (see trace-cmd-report(1)). Iconic little container behavior, honestly. ๐ซถ
๐ง INITIAL FORMAT ๐ง
Opening-bytes time, bestie. The first three bytes contain the magic value:
0x17 0x08 0x44
The next 7 bytes contain the characters tracing.
The next set of characters contain a null '\0' terminated string that contains the version of the file: 7\0.
The next 1 byte contains the flags for the file endianess:
0= little endian1= big endian
The next byte contains the number of bytes per "long" value:
4โ 32-bit long values8โ 64-bit long values
Note: This is the long size of the target's user space. Not the kernel space size.
[ Now all numbers are written in file defined endianess. ]
The next 4 bytes are a 32-bit word that defines what the traced host machine page size was.
The compression algorithm header is written next:
name\0version\0
where name and version are strings, name and version of the compression algorithm used to compress the trace file. If the name is none, the data in the file is not compressed.
The next 8 bytes are 64-bit integer, the offset within the file where the first OPTIONS section is located.
The rest of the file consists of different sections. The only mandatory is the first OPTIONS section; all others are optional. The location and the order of the sections is not strict. Each section starts with a header:
๐ฆ FORMAT OF THE SECTION HEADER ๐ฆ
<2 bytes>unsigned short integer, ID of the section.<2 bytes>unsigned short integer, section flags:1= the section is compressed.
<4 bytes>ID of a string, description of the section.<8 bytes>long long unsigned integer, size of the section in the file.
If the section is compressed, the above is the compressed size. The section must be uncompressed on reading. The described format of the sections refers to the uncompressed data.
๐๏ธ COMPRESSION FORMAT OF THE FILE SECTIONS ๐๏ธ
Some of the sections in the file may be compressed with the compression algorithm, specified in the compression algorithm header. Compressed sections have a compression header, written after the section header and right before the compressed data:
<4 bytes>unsigned int, size of compressed data in this section.<4 bytes>unsigned int, size of uncompressed data.<data>binary compressed data, with the specified size.
๐ฅ COMPRESSION FORMAT OF THE TRACE DATA ๐ฅ
There are two special sections, BUFFER FLYRECORD and BUFFER LATENCY, containing trace data. These sections may be compressed with the compression algorithm, specified in the compression header. Usually the size of these sections is huge, that's why its compression format is different from the other sections. The trace data is compressed in chunks. The size of one chunk is specified in the file creation time. The format of compressed trace data is:
<4 bytes> unsigned int, count of chunks.
Follows the compressed chunks of given count. For each chunk:
<4 bytes> unsigned int, size of compressed data in this chunk.
<4 bytes> unsigned int, size of uncompressed data, aligned with the trace page size.
<data> binary compressed data, with the specified size.
These chunks must be uncompressed on reading. The described format of trace data refers to the uncompressed data. ๐ฆ
โจ OPTIONS SECTION โจ
Section ID: 0
Okay so this is literally the only mandatory section in the file. No cap. There can be multiple options sections, and the first one is located at the offset specified right after the compression algorithm header. The section is made of multiple trace options, and each option has this exact format:
<2 bytes> unsigned short integer, ID of the option.
<4 bytes> unsigned integer, size of the option's data.
<binary data> bytes of the size specified above, data of the option.
These are the options supported by the trace file version 7, bestie ๐
DONEโ id0, size8. This option indicates the end of the options section, and it's always written as the last option. TheDONEoption data is:
<8 bytes> long long unsigned integer, offset in the trace file where
the next options section is located. If this offset is 0, then there
are no more options sections.
DATEโ id1, size vary. TheDATEoption data is a null terminated ASCII string, which represents the time difference between trace events timestamps and the Generic Time of Day of the system.CPUSTATโ id2, size vary. TheCPUSTAToption data is a null terminated ASCII string, the content of the"per_cpu/cpu<id>/stats"file from the trace directory. There is aCPUSTAToption for each CPU.BUFFERโ id3, size vary. TheBUFFERoption describes the flyrecord trace data saved in the file, collected from one trace instance. There is aBUFFERoption for each trace instance. The format of theBUFFERdata is:
<8 bytes> long long unsigned integer, offset in the trace file where the
BUFFER FLYRECORD section is located, containing flyrecord trace data.
<string> a null terminated ASCII string, name of the trace instance. Empty string ""
is saved as name of the top instance.
<string> a null terminated ASCII string, trace clock used for events timestamps in
this trace instance.
<4 bytes> unsigned integer, size of the trace buffer page.
<4 bytes> unsigned integer, count of the CPUs with trace data.
For each CPU of the above count:
<4 bytes> unsigned integer, ID of the CPU.
<8 bytes> long long unsigned integer, offset in the trace file where the trace data
for this CPU is located.
<8 bytes> long long unsigned integer, size of the trace data for this CPU.
TRACECLOCKโ id4, size vary. TheTRACECLOCKoption data is a null terminated ASCII string, the content of the"trace_clock"file from the trace directory.UNAMEโ id5, size vary. TheUNAMEoption data is a null terminated ASCII string, identifying the system where the trace data is collected. The string is retrieved by theuname()system call.HOOKโ id6, size vary. TheHOOKoption data is a null terminated ASCII string, describing event hooks: custom event matching to connect any two events together.OFFSETโ id7, size vary. TheOFFSEToption data is a null terminated ASCII string, representing a fixed time that is added to each event timestamp on reading.CPUCOUNTโ id8, size4. TheCPUCOUNToption data is:
<4 bytes> unsigned integer, number of CPUs in the system.
VERSIONโ id9, size vary. TheVERSIONoption data is a null terminated ASCII string, representing the version of thetrace-cmdapplication, used to collect these trace logs.PROCMAPSโ id10, size vary. ThePROCMAPSoption data is a null terminated ASCII string, representing the memory map of each traced filtered process. The format of the string is, for each filtered process:
<procss ID> <libraries count> <process command> \n
<memory start address> <memory end address> <full path of the mapped library file> \n
...
separate line for each library, used by this process
...
...
TRACEIDโ id11, size8. TheTRACEIDoption data is a unique identifier of this tracing session:
<8 bytes> long long unsigned integer, trace session identifier.
TIME_SHIFTโ id12, size vary. TheTIME_SHIFToption stores time synchronization information, collected during host and guest tracing session. Usually it is saved in the guest trace file. This information is used to synchronize guest with host events timestamps, when displaying all files from this tracing session. The format of theTIME_SHIFToption data is:
<8 bytes> long long unsigned integer, trace identifier of the peer (usually the host).
<4 bytes> unsigned integer, flags specific to the time synchronization protocol, used in this
trace session.
<4 bytes> unsigned integer, number of traced CPUs. For each CPU, timestamps corrections
are recorded:
<4 bytes> unsigned integer, count of the recorded timestamps corrections for this CPU.
<array of unsigned long long integers of the above count>, times when the corrections are calculated
<array of unsigned long long integers of the above count>, corrections offsets
<array of unsigned long long integers of the above count>, corrections scaling ratio
GUESTโ id13, size vary. TheGUESToption stores information about traced guests in this tracing session. Usually it is saved in the host trace file. There is a separateGUESToption for each traced guest. The information is used when displaying all files from this tracing session. The format of theGUESToption data is:
<string> a null terminated ASCII string, name of the guest.
<8 bytes> long long unsigned integer, trace identifier of the guest for this session.
<4 bytes> unsigned integer, number of guest's CPUs. For each CPU:
<4 bytes> unsigned integer, ID of the CPU.
<4 bytes> unsigned integer, PID of the host task, emulating this guest CPU.
TSC2NSECโ id14, size16. TheTSC2NSECoption stores information, used to convert TSC events timestamps to nanoseconds. The format of theTSC2NSECoption data is:
<4 bytes> unsigned integer, time multiplier.
<4 bytes> unsigned integer, time shift.
<8 bytes> unsigned long long integer, time offset.
STRINGSโ id15, size vary. TheSTRINGSoption holds a list of nul terminated strings that holds the names of the other sections.HEADER_INFOโ id16, size8. TheHEADER_INFOoption data is:
<8 bytes> long long unsigned integer, offset into the trace file where the HEADER INFO
section is located
FTRACE_EVENTSโ id17, size8. TheFTRACE_EVENTSoption data is:
<8 bytes> long long unsigned integer, offset into the trace file where the
FTRACE EVENT FORMATS section is located.
EVENT_FORMATSโ id18, size8. TheEVENT_FORMATSoption data is:
<8 bytes> long long unsigned integer, offset into the trace file where the EVENT FORMATS
section is located.
KALLSYMSโ id19, size8. TheKALLSYMSoption data is:
<8 bytes> long long unsigned integer, offset into the trace file where the KALLSYMS
section is located.
PRINTKโ id20, size8. ThePRINTKoption data is:
<8 bytes> long long unsigned integer, offset into the trace file where the TRACE_PRINTK
section is located.
CMDLINESโ id21, size8. TheCMDLINESoption data is:
<8 bytes> long long unsigned integer, offset into the trace file where the
SAVED COMMAND LINES section is located.
BUFFER_TEXTโ id22, size. TheBUFFER_LAToption describes the latency trace data saved in the file. The format of theBUFFER_LATdata is:
<8 bytes> long long unsigned integer, offset in the trace file where the
BUFFER LATENCY section is located, containing latency trace data.
<string> a null terminated ASCII string, name of the trace instance. Empty string ""
is saved as name of the top instance.
<string> a null terminated ASCII string, trace clock used for events timestamps in
this trace instance.
BTF_FILEโ id23, size8. TheBTF_FILEoption data is a compressed data from the host file/sys/kernel/btf/vmlinux, using the compression algorithm defined by thetrace.datheader. The compression data includes the size of the uncompressed output.LAST_BOOT_INFOโ id24, size vary. TheLAST_BOOT_INFOoption data contains the content of thelast_boot_infoif the file existed for an instance. It starts with the instance name, followed by a colon":"and then the content of thelast_boot_infofile. Currently the instance name is not used, but exists in case in the future there are more than one instance with this file.MODULES_FILEโ id25, size8. TheMODULES_FILEoption data is a compressed data from the host file/proc/modules, using the compression algorithm defined by thetrace.datheader. The compression data includes the size of the uncompressed output.
๐ฆ HEADER INFO SECTION ๐ฆ
Section ID: 16
The first 12 bytes of the section, after the section header, contain the string:
"header_page\0"
The next 8 bytes are a 64-bit word containing the size of the page header information stored next.
The next set of data is of the size read from the previous 8 bytes, and contains the data retrieved from debugfs/tracing/events/header_page.
Note: the size of the second field commit contains the target kernel long size. For example:
field: local_t commit; offset:8; \fBsize:8;\fR signed:1;
shows the kernel has a 64-bit long.
The next 13 bytes contain the string:
"header_event\0"
The next 8 bytes are a 64-bit word containing the size of the event header information stored next.
The next set of data is of the size read from the previous 8 bytes and contains the data retrieved from debugfs/tracing/events/header_event.
This data allows the trace-cmd tool to know if the ring buffer format of the kernel made any changes.
๐ง FTRACE EVENT FORMATS SECTION โ Section ID: 17
Right after the section header comes the tea on the Ftrace-specific events โ These are the events that the Ftrace plugins use โ and no, they are not enabled by event tracing. Different vibe entirely, iykyk.
The next 4 bytes hold a 32-bit word: the number of Ftrace event format files chillin' in the file.
Then, for the number of times defined by that previous 4 bytes, you get:
8bytes for the size of the Ftrace event format file.
And the Ftrace event format file itself, copied straight from the target machine:
debugfs/tracing/events/ftrace/<event>/format
๐ธ EVENT FORMATS SECTION โ Section ID: 18
Directly after the section header comes the info about the event layout ๐
The next 4 bytes are a 32-bit word containing the number of event systems stored in the file. These are the directories in debugfs/tracing/events, excluding the ftrace directory (she's not invited to this one).
For the number of times defined by those previous 4 bytes, here's the rundown:
- A null-terminated string containing the system name.
4bytes containing a 32-bit word containing the number of events within the system.
And for the number of times defined in that previous 4 bytes:
8bytes for the size of the event format file.- The event format file copied from the target machine:
debugfs/tracing/events/<system>/<event>/format
๐ KALLSYMS SECTION โ Section ID: 19
Directly after the section header comes the mapping of function addresses to function names โ literally the "who is who" of the kernel ๐ซถ
The next 4 bytes are a 32-bit word containing the size of the data holding those function mappings.
The next set of data is of the size defined by the previous 4 bytes, and it contains the information from the target machine's file:
/proc/kallsyms
โจ TRACE_PRINTK SECTION โ Section ID: 20
So if a developer used trace_printk() inside the kernel, it may store the format string outside the ring buffer (main character behaviour, honestly). You can find that info in:
debugfs/tracing/printk_formats
The next 4 bytes are a 32-bit word containing the size of the data holding the printk formats.
The next set of data is of the size defined by the previous 4 bytes and contains the information from debugfs/tracing/printk_formats.
๐ฆ SAVED COMMAND LINES SECTION โ Section ID: 21
Directly after the section header comes the info mapping a PID to a process name ๐ซถ
The next 8 bytes contain a 64-bit word that holds the size of the data mapping the PID to a process name.
The next set of data is of the size defined by the previous 8 bytes and contains the information from debugfs/tracing/saved_cmdlines.
๐ฅ BUFFER FLYRECORD SECTION
This section contains flyrecord tracing data, collected in one trace instance. The data is saved per CPU โ every CPU gets its own little moment ๐
Each BUFFER FLYRECORD section has a corresponding BUFFER option containing info about the saved CPU's trace data. Padding is placed between the section header and the CPU data, which puts the CPU data at a page-aligned (target page) position in the file.
This data is copied directly from the Ftrace ring buffer and is the same format as the ring buffer specified by the event header files loaded in the header format file.
The trace-cmd tool will try to mmap(2) the data page by page with the target's page size if possible. If it fails to mmap, it will just read the data instead. Plan B, but make it fashion ๐
๐ BUFFER TEXT SECTION โ Section ID: 22
This section contains latency tracing data โ ASCII text taken from the target's debugfs/tracing/trace file. No cap, it's just text.
๐ STRINGS SECTION โ Section ID: 15
All strings of the trace file metadata are stored in a string section within the file ๐ That section contains a list of nul-terminated ASCII strings. An ID of the string is used in the file metadata, and that ID is the offset of the actual string into the string section. Strings can be stored into multiple string sections in the file โ she's flexible like that.
๐ BTF FILE SECTION โ Section ID: 23
Directly after the section header comes an 8 byte value that contains a 64-bit word holding the size of the BTF file (which may be compressed ๐ฅ).
The next set of data is of the size defined by the previous 8 bytes and contains the information from:
/sys/kernel/btf/vmlinux
๐ MODULES FILE SECTION โ Section ID: 25
Directly after the section header comes an 8 byte value that contains a 64-bit word holding the size of the modules file (which may be compressed โจ).
The next set of data is of the size defined by the previous 8 bytes and contains the information from:
/proc/modules
๐ SEE ALSO
trace-cmd(1), trace-cmd-record(1), trace-cmd-report(1), trace-cmd-start(1), trace-cmd-stop(1), trace-cmd-extract(1), trace-cmd-reset(1), trace-cmd-split(1), trace-cmd-list(1), trace-cmd-listen(1), trace-cmd.dat(5)
Like, go read them, bestie. All of them. It's giving "required reading" ๐
๐ซถ AUTHOR
Written by Steven Rostedt, <rostedt@goodmis.org[1]> โ the icon who made this whole thing ๐
๐ RESOURCES
https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/
๐ COPYING
Copyright (C) 2010 Red Hat, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).
๐ NOTES
rostedt@goodmis.orgmailto:rostedt@goodmis.org
And that's a wrap on the whole page, bestie ๐โจ go forth and read trace files like the main character you are. This one came from libtracefs, dated 03/09/2026, and it's TRACE-CMD.DAT.V(5) โ slay ๐
๐
๐ฆ where this page comes from
- arch rolling: trace-cmd 3.4-1 ยท GPL-2.0-only AND LGPL-2.1-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms