The Itanium C++ ABI states the string passed to __cxa_demnagle "may be either an external name, i.e. with a "_Z" prefix, or an internal NTBS mangling, e.g. of a type for type_info."
llvm-symbolizer passes all names to cxa_demangle, which fails for many names on FreeBSD. Our cxa_demangle is currently not very strict about rejecting invalid names, and returns "unsigned int" for a function "main". On other platforms I believe llvm-symbolizer would produce incorrect output for functions with the same name as a mangled type - for example, returning "float" for a function "f".
This change checks that the name starts with the _Z prefix before passing it to __cxa_demangle.