Page MenuHomeFreeBSD

Fix dtrace symbol resolution for anonymous structs/unions
ClosedPublic

Authored by jtl on Nov 17 2020, 3:02 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Mar 19, 7:40 AM
Unknown Object (File)
Mon, Mar 11, 5:23 AM
Unknown Object (File)
Feb 23 2024, 11:04 AM
Unknown Object (File)
Jan 27 2024, 7:39 AM
Unknown Object (File)
Jan 11 2024, 10:44 PM
Unknown Object (File)
Jan 10 2024, 9:56 PM
Unknown Object (File)
Dec 22 2023, 1:06 PM
Unknown Object (File)
Dec 21 2023, 8:47 PM
Subscribers

Details

Summary

In D27213, @ae reported that he was seeing this problem:

$ dtrace -n 'fbt::ip_input:entry { printf("%s", stringof(args[0]->m_pkthdr.rcvif->if_xname)); }'
dtrace: invalid probe specifier fbt::ip_input:entry { printf("%s", stringof(args[0]->m_pkthdr.rcvif->if_xname)); }: in action list: m_pkthdr is not a member of struct mbuf

This only occurs when ipfw.d is loaded first, which imports struct mbuf into the "D" CTF container.

As part of the import, ctf_add_type() is calling ctf_member_iter() to call membadd() on each member of the structure/union:

if (ctf_member_iter(src_fp, src_type, membadd, &dst) != 0)

ctf_member_iter() calls ctf_strptr() to convert the name index to a string. ctf_strptr() is converting a 0-index to an empty string. membadd() is then adding the member with a name of the empty string. However, that confuses other places in the code (such as _ctf_member_info), which expect empty string member names to be encoded as index 0.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 34853
Build 31879: arc lint + arc unit

Event Timeline

jtl requested review of this revision.Nov 17 2020, 3:02 AM

While here, update the code in ctf_add_generic() to encode empty type names with index 0. This fixes the analogous case for type names.

Could you please re-upload with context?

Updating the diff to include context.

Could you please re-upload with context?

Done. Yes, looking at the previous diffs, they weren't very obvious. The context should help clarify the proposed change.

I'd suggest running the DTrace test suite with this change if you haven't. make -C cddl/usr.sbin/dtrace WITH_DTRACE_TESTS= all install should install them to /usr/tests/cddl/usr.sbin/dtrace.

This revision is now accepted and ready to land.Nov 19 2020, 3:52 PM

I'd suggest running the DTrace test suite with this change if you haven't. make -C cddl/usr.sbin/dtrace WITH_DTRACE_TESTS= all install should install them to /usr/tests/cddl/usr.sbin/dtrace.

Thanks for the pointer! The test results are the same before and after my change.