DT(4)

πŸ“¦ in nixpkgs unstable

πŸ’– NAME πŸ’–

okay so bestie, this is dt β€” dynamic tracer β€” and we're in the Kernel Interfaces Manual, on the DT(4) page. It's giving kernel tracing realness, no cap. πŸ’…βœ¨

✨ SYNOPSIS ✨

pseudo-device dt

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so system and application tracing can happen in the kernel. It has to be configured and enabled through the ioctl(2) interface exposed by the pseudo-device /dev/dt.

lowkey important: this device can only be opened when the kern.allowdt sysctl(2) variable is set. periodt. πŸ”₯

πŸŽ€ IOCTL INTERFACE πŸŽ€

The ioctl(2) command codes below are defined in <dev/dt/dtvar.h>. iconic header file, honestly. iykyk.

  • DTIOCGPLIST struct dtioc_probe *dtpr β€” Get available probe entries. yes bestie, all the probe entries.
struct dtioc_probe {
        size_t                   dtpr_size;
        struct dtioc_probe_info *dtpr_probes;
};

If dtpr_size is non-zero, as many probes as possible that can fit into this size will be copied into the supplied buffer. On exit, dtpr_size is always set to the total size required to hold all probe entries (i.e., it is set to sizeof(struct dtioc_probe_info) * dt_nprobes). literally does the math for you, slay. πŸ’…

  • DTIOCGSTATS struct dtioc_stat *dtst β€” Get statistics for current recording. stats check, iconic. πŸ“Š
struct dtioc_stat {
        uint64_t                 dtst_readevt;
        uint64_t                 dtst_dropevt;
};
  • DTIOCRECORD int on β€” Start or stop recording. flip the switch, bestie. 🎬
  • DTIOCPRBENABLE struct dtioc_req *dtrq β€” Enable the given probe for recording. let's gooo. πŸ”₯
struct dtioc_req {
        uint32_t                 dtrq_pbn;
        struct dt_filter         dtrq_filter;
        uint32_t                 dtrq_rate;
        uint64_t                 dtrq_evtflags;
};
  • DTIOCRDVNODE struct *dtioc_rdvn β€” Resolve the instruction pointer from the traced process to the ELF object. big main character energy. πŸ‘‘
struct dtioc_rdvn {
        pid_t                    dtrv_pid;
        int                      dtrv_fd;
        caddr_t                  dtrv_va;
        caddr_t                  dtrv_offset;
        caddr_t                  dtrv_start;
        size_t                   dtrv_len;
};

The caller populates dtrv_pid with the process ID of the traced process and dtrv_va with the program counter address to look up.

On success, the remaining members are populated. dtrv_fd is the file descriptor to the DSO file that dtrv_va belongs to. dtrv_len is the length of the DSO file. dtrv_offset and dtrv_start are the relative offset of dtrv_va to the start of the text segment and the base address of that segment respectively.

To calculate the relative offset of dtrv_va in the DSO the following calculation can be used:

iOffset = dtrv_va - dtrv_start + dtrv_offset

The segment can be found by walking the ELF program headers and looking for the mapping where iOffset is included in the range [GElf_Phdr.p_offset, GElf_Phdr.p_offset + GElf_Phdr.p_filesz)

Using the GElf_Phdr.p_vaddr the base address of the segment can be calculated by

lbase = dtrv_start - GElf_Phdr.p_vaddr

For symbol lookups the offset can now be calculated as

symOffset = dtrv_va - lbase

πŸ“ FILES πŸ“

  • /dev/dt β€” dynamic tracing device. the main character device, honestly. 🫢

πŸ’€ ERRORS πŸ’€

An open of /dev/dt will fail if:

  • [EPERM] β€” the kern.allowdt sysctl(2) variable wasn't set.
  • [ENOMEM] β€” not enough memory space was available.

🌈 SEE ALSO 🌈

ioctl(2), bt(5), btrace(8) β€” go read these too, bestie. ⭐🫢

πŸ‘‘ HISTORY πŸ‘‘

The dt dynamic tracing mechanism first appeared in OpenBSD 6.7. history was made, periodt. 🧚πŸ”₯


This page came from the Debian source/version stamp, dated October 11, 2025, and it's DT(4) β€” bye bestie! πŸ’‹πŸŒΈπŸ’œ

πŸ“¦ where this page comes from
  • nixpkgs unstable: cvs-export
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms