Demangling of method names and addr2line/c++filt

Ranjit Mathew
Fri Feb 14 12:48:00 GMT 2003

>  > Ok. Based on Mark's suggestion a while ago, how does this sound:
>  >
>  > 1. We modify gnu/gcj/runtime/ to pass "-n" to c++filt if
>  >    the "gnu.gcj.runtime.strip_leading_underscore" system property is
>  >    to "true" - it would be "false" by default. (BTW, does it mean that
>  >    explicitly pass "-_" to c++filt otherwise?)
> This seems rather complex, although I wouldn't argue against such a
> patch.  Can we not make it a compile time rather than a runtime
> choice?  We might be able to #include the same file that c++filt
> includes.

The problem is that we need to strip out (or not) an underscore
*depending on the actual source* of the mangled symbol:

  1. dladdr - gets from the exported labels, stripping allowed.
  2. addr2name.awk - uses nm, therefore, same as that for dladdr.
  3. addr2line - uses debug info, therefore stripping not allowed
     (if target prefixes underscore to method name labels).

Note that for dladdr and addr2name.awk it is "stripping allowed" and
not "strip", as what is done by default by c++filt is target-dependent
and likely to be the correct behaviour.

The final logic then simply looks like:

  if ( usingAddr2Line && (USER_LABEL_PREFIX[0]=='_'))
    /* Explicitly pass "-n" to c++filt */

IMHO, this looks like the safest approach.

If this is OK, I can work towards a patch for this.


More information about the Java mailing list