This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Patch: Improve demangling w.r.t. possible underscore prefix
- From: Andrew Haley <aph at redhat dot com>
- To: Ranjit Mathew <rmathew at hotmail dot com>
- Cc: java at gcc dot gnu dot org
- Date: Mon, 17 Feb 2003 11:42:02 +0000 (GMT)
- Subject: Patch: Improve demangling w.r.t. possible underscore prefix
- References: <3E4FA8F6.69C93B68@hotmail.com>
Ranjit Mathew writes:
> Hi,
>
> 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:
>
> http://gcc.gnu.org/ml/java/2003-02/msg00145.html
>
> __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__.
Andrew.