Patch: Improve demangling w.r.t. possible underscore prefix
Mon Feb 17 15:01:00 GMT 2003
Ranjit Mathew writes:
> This patch proposes to add GCC's USER_LABEL_PREFIX to the
> symbols returned by addr2line so that they are at par with those
> returned by addr2name.awk or dladdr( ), i.e. on systems where an
> underscore is used as a prefix for names exported from C/C++/Java
> programs, this allows c++filt to correctly demangle names generated
> by addr2line, which uses symbolic debugging information instead of
> the actual exported labels that are used by dladdr and
> addr2name.awk (via "nm").
> The train of reasoning leading to this patch can be found in the
> thread starting from this message:
> __USER_LABEL_PREFIX__ is a predefined macro in the GCC preprocessor
> that stands for the string (*not* string constant) that is prefixed
> to a method name when it is exported as a label.
> The XGLUE/GLUE idiom you see in the patch is borrowed from the
> GCC sources and has been the only way I could make this
> macro work as needed. I do not completely understand why the double
> macro indirection is the only way it works. :-( (Search for
> "__USER_LABEL_PREFIX__" within the subfolders of the "gcc/config"
> folder in the GCC sources for instances of its usage within GCC.)
> I have checked this patch with the current 3.3 snapshot on
> Win32 (MinGW). I would greatly appreciate if someone could also
> test this out on some other platform, say Linux, especially one
> that does not have such a prefix, before committing it.
> With this patch in place, stacktraces on Win32 finally show up
> as one would expect them to, complete with class names
> and method signatures!
It seems like it will break if ever __USER_LABEL_PREFIX__is not '_'.
Why can't you just cat __USER_LABEL_PREFIX__ to the start of the name?
Surround the whole thing by #ifdef __USER_LABEL_PREFIX__.
More information about the Java