Add rust demangling support
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).
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
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
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.
Updated by Electric Monk over 4 years ago
commit 6a6cfa5d0723a95a9ad915bdb8ca2c9731449041 Author: Jason King <email@example.com> Date: 2019-07-05T01:08:28.000Z 11267 Add rust demangling support Reviewed by: Michal Nowak <firstname.lastname@example.org> Reviewed by: Toomas Soome <email@example.com> Approved by: Richard Lowe <firstname.lastname@example.org>