Feature #11267


Add rust demangling support

Added by Jason King over 4 years ago. Updated over 4 years ago.

lib - userland libraries
Start date:
Due date:
% Done:


Estimated time:
Gerrit CR:
External Bug:


Upstream of Joyent OS-7478:

With the replacement of the closed source C++ demangler, the design deliberately left open the possibilities of demangling other languages with the library. We should go ahead and extend it to support demangling rust given the high amount of interest in using it with SmartOS.

Specifically, it supports demangling rust names up to 1.35. The not yet (as of the time of issue creation) released 1.36 rust changes the demangling format, however it does so in a manner that will not interfere. Basically the demangling library will merely not recognize any names mangled using the 1.36 and later format at this time (that will be a future feature).

Actions #1

Updated by Jason King over 4 years ago

Also upstream of Joyent OS-7723 (the rust demangler adds a build dependency on libcustr that was missed in OS-7478). It makes the most sense to upstream both as a single change.

Actions #2

Updated by Jason King over 4 years ago

It seems appropriate to also upstream Joyent OS-7695 at the same time as this:

OS-7478 introduced support for demangling rust names. One of the consequences of that was that the language parameter used by mdb(1) was changed from C++ to auto detect. This unfortunately exposed a corner case not caught earlier – both EINVAL and ENOTSUP are both legitimate demangler failure modes – the former being when the name itself appears to be a known language, but fails demangling, while the latter when the demangler cannot determine which language the mangled name is from (which can only happen when the language is set to SYSDEM_LANG_AUTO).

The fix is simple – on failure, also check for ENOTSUP and don't print any warnings when this occurs. It also means the warnings can be ignored as annoying spam, as it happens on names that wouldn't be demangled in the first place (so mdb will just print out the original symbol name).

The other consumers of the demangler never bothered to report any errors in the demangler – at best they used the old DEMANGLE_ESPACE to retry with a larger buffer, but unlike mdb, never output any demangling errors.

Actions #3

Updated by Electric Monk over 4 years ago

git commit 6a6cfa5d0723a95a9ad915bdb8ca2c9731449041

commit  6a6cfa5d0723a95a9ad915bdb8ca2c9731449041
Author: Jason King <>
Date:   2019-07-05T01:08:28.000Z

    11267 Add rust demangling support
    Reviewed by: Michal Nowak <>
    Reviewed by: Toomas Soome <>
    Approved by: Richard Lowe <>

Actions #4

Updated by Joshua M. Clulow over 4 years ago

  • Status changed from New to Closed

Also available in: Atom PDF