Page MenuHomeFreeBSD

dtrace_fbt.4: Document the DTrace fbt provider
ClosedPublic

Authored by 0mp on Jun 18 2025, 10:01 PM.
Tags
Referenced Files
Unknown Object (File)
Fri, Jul 25, 7:17 PM
Unknown Object (File)
Wed, Jul 23, 3:47 AM
Unknown Object (File)
Mon, Jul 21, 11:52 AM
Unknown Object (File)
Sun, Jul 20, 3:00 PM
Unknown Object (File)
Sun, Jul 20, 2:42 PM
Unknown Object (File)
Sun, Jul 20, 2:08 PM
Unknown Object (File)
Sat, Jul 19, 1:40 AM
Unknown Object (File)
Thu, Jul 17, 3:20 AM
Subscribers

Details

Summary

Requested by: markj
Obtained from: Mark Johnston, DTrace, FreeBSD Journal, May 2014
Obtained from: https://wiki.freebsd.org/DTrace/One-Liners
MFC after: 2 weeks
Relnotes: yes

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65401
Build 62284: arc lint + arc unit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
0mp marked 22 inline comments as done.

Address feedback. I'll reply to comments in a moment.

0mp planned changes to this revision.Jun 20 2025, 3:22 PM
0mp added inline comments.
share/man/man4/dtrace_fbt.4
15

name seems to be the right replacement for instruction. Good catch!

15

Putting other things on the line usually affects apropos results.

I cannot easily split that into two lines without adding an extra space after fbt which would be incorrect. I'll leave it as is. apropos will see other instances of .Nm fbt in this file just fine, so not a big problem.

20

So, I took the _non-leaf_ phrase from John Birrell's email introducing DTrace to FreeBSD: https://lists.freebsd.org/pipermail/freebsd-current/2006-May/063299.html

Today's significant emotional event added over 30,000 of those, thanks
to the Function Boundary Tracing (fbt) provider. It provides the
instrumentation of the entry and return of every (non-leaf) function
in the kernel and (non-DTrace provider) modules.

I understand that John meant the leaf functions as described by Mark in his comment.

I'm rewritting this part and moving it to a *Frame Pointer* subsection in IMPLEMENTATION NOTES.

24

https://reviews.freebsd.org/D38825 looks interesting.

I'll reference dtrace_kinst in the Frame Pointer subsection.

I've reworded this part and referred to the Frame Pointer subsection for more details.

25

Good point. That's a todo.

30

We've got a lot of those in other manual pages where we share intuitions with our users on how to approach a given piece of software. I'd be happy to see a note like this because it sets my expectations right.

I'll remove it though as it is perhaps too imprecise and does not really help. Thanks!

31

Great! I'll put that into the Frame Pointer subsection.

39

Historically, fbt's documentation highlighted the instability of the fbt probes. This paragraph follows this tradition and stresses that scripts will likely needed to be modified to run on a newer version of FreeBSD or a different OS.

@christos , would you like to see the wording to be less dramatic?

49

I'll think about it and take care of those examples in the next iterations of this patch. TODO

57

Done. I noted that SDTs are a potential solution to a complex fbt script.

I'm not sure if that's what you meant.

77

I wanted to keep the dtrace: ... message here. This is on purpose.

140

TODO

share/man/man4/dtrace_fbt.4
65

Yeah, I was thinking that maybe apropos(1) likes the use of marcos in code examples and so style.mdoc should be updated to reflect that.

Perhaps that's a fun project for another time. If you don't like the current style here, I'll just use the one recommended by style.mdoc(7).

share/man/man4/dtrace_fbt.4
15

It should come up for "fbt" because the document name is "dtrace_fbt". The issue is that it will come up for "name", "function", and "module".

65

Well sir it's not that I don't like it, it's that the maintainers of the language say it's wrong and it should not be done in the link I provided above on the mdoc/mandoc projects homepage.

127

This one also doesn't need to have so much whitespace, it breaks legibility on narrower consoles.

0mp marked an inline comment as done.Jun 20 2025, 6:13 PM
0mp added inline comments.
share/man/man4/dtrace_fbt.4
15

If we figure out how to split that I'm all for doing that.

65

Haha, okay then, let's not do it like this. If we ever change our mind, we can revisit that. I'll not use macros in code blocks.

127

TODO

0mp marked an inline comment as done.
  • Remove formatting from examples
  • Add a section describing probe arguments
share/man/man4/dtrace_fbt.4
25

Hmm, any idea why -lv does not mention malloc(9)'s third argument?

console
# dtrace -n 'fbt::malloc:return' -lv
   ID   PROVIDER            MODULE                          FUNCTION NAME
31954        fbt            kernel                            malloc return

        Probe Description Attributes
                Identifier Names: Private
                Data Semantics:   Private
                Dependency Class: Unknown

        Argument Attributes
                Identifier Names: Private
                Data Semantics:   Private
                Dependency Class: ISA

        Argument Types
                args[0]: int
                args[1]: void *
0mp marked 3 inline comments as done.Jun 23 2025, 12:35 PM
0mp added inline comments.
share/man/man4/dtrace_fbt.4
25

I've added a section about probe arguments.

An example of dtrace -lv is still a todo.

65

I've removed mdoc macros from code listings.

127

I've narrowed all the examples of count aggregations to the same width.

share/man/man4/dtrace_fbt.4
65

XXX: I should probably advertise typed args first instead of the untyped argX variables..

Presumably this page should be xref'ed from dtrace.1, like the other providers?

share/man/man4/dtrace_fbt.4
20

"Almost every" is misleading. It lets one trace functions which are not inlined, but many functions are inlined. One way to say this would be, "... the entry and return of almost every function corresponding to an ELF symbol in the kernel and loaded kernel modules."

21
25

In that command you're printing the arguments for the return probe. dtrace -n 'fbt::malloc:entry' -lv should show you the function arguments.

36

Is arg0 supposed to be the D syntax? If so, it should probably be args[0] instead. arg0 is a raw 64-bit integer, while args[0] has the same type as the probe argument. For instance, fbt::malloc:entry {print(*arg1);} won't work, but fbt::malloc:entry {print(*args[1]);} will.

39
43
45
58
63

If you use args[N] syntax, then the arguments will be typed according to the function's signature, as I noted above.

Presumably this page should be xref'ed from dtrace.1, like the other providers?

I was thinking of handling cross-references afterwards in subsequent commits.

share/man/man4/dtrace_fbt.4
15

Okay I've been playing with this: the name of the command is dtrace, the command modifier fbt tells dtrace to use function boundary tracing, : is the delimiter, and the three subsequent arguments are arguments. Right?

This renders as:
dtrace "fbt:module:function:name"

In D50922#1164261, @0mp wrote:

Presumably this page should be xref'ed from dtrace.1, like the other providers?

I was thinking of handling cross-references afterwards in subsequent commits.

Eh, I am the most junior and least authorative, but IMHO please don't do that, commits should be atomic unless we made mistakes (like I do constantly :P), or it's too big to review and has clean chunking points.

In D50922#1164261, @0mp wrote:

Presumably this page should be xref'ed from dtrace.1, like the other providers?

I was thinking of handling cross-references afterwards in subsequent commits.

Eh, I am the most junior and least authorative, but IMHO please don't do that, commits should be atomic unless we made mistakes (like I do constantly :P), or it's too big to review and has clean chunking points.

Hmm, I usually prefer to commit the new manual pages or programs in one commit and then connect them to other places in the tree in another commit. I'll ask my mentors what they think about that approach.

share/man/man4/dtrace_fbt.4
15

Nice try! :D But you'd need -n for that.

So, it'd need to be something like:

dtrace -n "fbt:module:function:name { ... }"

at the very least.

Also, DTrace scripts can live in files as well, so it does not feel right to suggest the intended use of FBT is only for DTrace one-liner on the command line.

The synopsis section always feels a bit hacky if it describes something that's not a shell command, a C function, or a kernel module.

Also, remember that Dq might render as stylized quotes. Qq would be better here.

I still believe that the current synopsis is the most optimal of all we came up so far.

Let's ask Ingo! He probably knows. I'll send him a mail.

0mp marked 10 inline comments as done.

Address feedback and refactor some sections.

share/man/man4/dtrace_fbt.4
20

Thanks! Applied

25

Thanks. I've added dtrace -lv example.

36

Fair point. I'll address that in the next revision.

39
43

I rewrote this part.

45

I rewrote this part.

140

Added!

0mp marked 3 inline comments as done.Fri, Jul 11, 3:24 PM
0mp added inline comments.
share/man/man4/dtrace_fbt.4
49

The part about FBT's stability has been moved to CAVEATS. It also added a small example.

I addressed all comments. Thank you very much for all your feedback!

  • Fix a typo in Example 1
share/man/man4/dtrace_fbt.4
41–42
60

Isn't this redundant? We could write this like "args[0], ...".

77

Seems redundant as the table below gives the same information.

117
157
268
309

Not sure.

313–314
0mp planned changes to this revision.Mon, Jul 14, 5:01 PM
0mp marked 8 inline comments as done.
  • Address Christos' feedback
share/man/man4/dtrace_fbt.4
60

We could, but a table is easier to navigate. Also, we explain return probe args in a table as well, so it's consistent. I agree that it is a bit verbose, but I'd like to avoid saying just that "functions arguments are args[0], ...".

77

I kind of like the idea that the paragraph is easy to read and gives some more details and the table provides a quick reference. I'm not sure how I'd golf that into less text without sacrificing readability.

This revision is now accepted and ready to land.Tue, Jul 15, 1:11 PM

We can of course fix them later, but I did send a mail asking about how we write the synopsis. These SYNOPSIS(es?) do introduce bugs in apropos results.

I really appreciate these pages. I think dtrace is a killer feature and BSD style manpages are a killer feature and marrying them is very good.