Page MenuHomeFreeBSD

hook up DTrace's userland CTF support
ClosedPublic

Authored by markj on Oct 3 2014, 6:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 21, 11:33 AM
Unknown Object (File)
Mar 22 2024, 9:06 PM
Unknown Object (File)
Mar 22 2024, 9:06 PM
Unknown Object (File)
Mar 8 2024, 7:30 AM
Unknown Object (File)
Feb 1 2024, 10:06 AM
Unknown Object (File)
Jan 4 2024, 9:51 AM
Unknown Object (File)
Jan 4 2024, 9:51 AM
Unknown Object (File)
Jan 4 2024, 5:51 AM
Subscribers
None

Details

Reviewers
will
rpaulo
Group Reviewers
DTrace
Summary

Userland CTF support was recently implemented upstream but has been disabled in FreeBSD because it requires a bit of work in libproc. This change makes the needed modifications. Specifically,

  • uncomment some libdtrace code which does lookups of functions and type names in an objects CTF
  • introduce a libproc function to obtain ctf data out of an object (proc_name2ctf()). This function requires libctf and just returns NULL if libproc is compiled without libctf (WITHOUT_CDDL).
  • proc_name2sym now returns a prsyminfo_t, which is an upstream type that just serves as an identifier for symbols. Upstream libproc uses it more extensively than we do, I just implemented the minimum support needed for CTF.

There's some more work to do here, especially in the ctf* tools. It's looking like a lot of CTF info is missing when I compile world with WITH_CTF=YES. The upside is that we can now use args[n] in userland probes (again assuming that the CTF info is there), and reference userland types and so on.

It's also worth noting that libproc is fairly inefficient, since it doesn't do much caching of symbol or map info. I'll be working on that in the future, but I wanted to get userland CTF mostly working with a minimal change first.

Test Plan

The uctf tests pass when compiled and run manually. The don't work when invoked from tools/test/dtrace, since the test programs aren't compiled using bsd.*.mk and so they don't include CTF data.

Some ad-hoc testing with USDT and the pid provider seems to indicate that it mostly works. libc seems to be missing some CTF info about function argument types, so I'll be looking into that.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

markj retitled this revision from to hook up DTrace's userland CTF support.
markj updated this object.
markj edited the test plan for this revision. (Show Details)
markj added reviewers: rpaulo, will, DTrace.
rpaulo edited edge metadata.

This looks great, thanks! Symbol lookup caching has been in my TODO for a while, so I'd be grateful if you could do that :-)

This revision is now accepted and ready to land.Oct 3 2014, 6:23 PM

I don't feel I know enough about this area to judge it ready, but it looks fine to me.

It would be nice to see automated ATF tests for USDT/pid probes so that one can simply run them as a means of validating changes in the same area.

In D891#6, @will wrote:

I don't feel I know enough about this area to judge it ready, but it looks fine to me.

It would be nice to see automated ATF tests for USDT/pid probes so that one can simply run them as a means of validating changes in the same area.

Yup, one of the things I'll be working on next is converting the DTrace tests over to use Kyua, and probably bringing in my own mini-testsuite.