Page MenuHomeFreeBSD

Improve ctfconvert handling of C++ object files.

Authored by will on Sep 26 2014, 8:42 PM.



This is an amalgamation of several fixes:

  • Undo the default empty string in die_name(); this syncs with upstream. Many things check the return of die_name() for NULL and these cases must trigger or else other bugs will occur.
  • die_sou_resolve(): Rather than crash, consider a SOU as unresolvable if its type descriptor references a currently unknown DIE. The top-level will retry until it either finds the type or it will bail.
  • die_function_create():
    • Don't require function arguments to have names. C/C++ don't require this, and CTF doesn't care if there isn't one, because it already has arg0/arg1/.../argN and args.
    • Ensure that the variadic argument can't be reached in the second loop.
    • Emit the 'function has %d arguments' debug message even if the function had no arguments, for information purposes and also inform whether the function is variadic.
Test Plan

Run ctfconvert on sbin/devd/'s object file, note that it still exits
with an error, but does not crash. This checkin is intended as a step
forward, not a full solution.

Diff Detail

rS FreeBSD src repository
No Linters Available
No Unit Test Coverage

Event Timeline

will updated this revision to Diff 1796.Sep 26 2014, 8:42 PM
will retitled this revision from to Improve ctfconvert handling of C++ object files..
will updated this object.
will edited the test plan for this revision. (Show Details)
will added a reviewer: markj.
markj added inline comments.Oct 1 2014, 6:14 AM

Shouldn't this be

if ((ml->ml_name = die_name(dw, mem)) == NULL)
    ml->ml_name = xstrdup("");

? I see some code in merge.c that expects ml_name to be non-NULL.

(Note that upstream omits the xstrdup call, but that's almost certainly a bug.)


Sorry, I'm a bit confused by this. Is this meant to be a temporary workaround?

will added a comment.May 7 2017, 6:14 AM

I don't remember much of the context of this, but apparently I have some unsubmitted comments (probably made nearly 3 years ago).
IIRC, I eventually concluded that running ctfconvert on C++ was a bit of a fool's errand, since DTrace doesn't support C++ symbols, and AFAIK that hasn't changed. You have to use the mangled symbol names to dtrace C++.
I'm fine with dropping this Diff.


It does look like equiv_su() requires ml->ml_name to be non-NULL. Need to audit callers of die_name() to see if there are other cases.


No, it's effectively an assert. It's a safeguard; it ensures that the loop below doesn't have to check for varargs.

will abandoned this revision.Jan 15 2018, 11:52 PM

Dropping this for lack of interest.