diff options
Diffstat (limited to 'libjava/gnu/gcj/runtime/NameFinder.java')
-rw-r--r-- | libjava/gnu/gcj/runtime/NameFinder.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libjava/gnu/gcj/runtime/NameFinder.java b/libjava/gnu/gcj/runtime/NameFinder.java index 1d729d252ac..19820c1bd6b 100644 --- a/libjava/gnu/gcj/runtime/NameFinder.java +++ b/libjava/gnu/gcj/runtime/NameFinder.java @@ -103,6 +103,11 @@ public class NameFinder private BufferedReader addr2lineIn; /** + * Flag set if using addr2name.awk instead of addr2line from binutils. + */ + private boolean usingAddr2name = false; + + /** * Creates a new NameFinder. Call close to get rid of any resources * created while using the <code>lookup</code> methods. */ @@ -142,6 +147,7 @@ public class NameFinder { String[] exec = new String[] {"addr2name.awk", executable}; addr2line = runtime.exec(exec); + usingAddr2name = true; } catch (IOException ioe2) { addr2line = null; } } @@ -181,6 +187,11 @@ public class NameFinder native private String getAddrAsString(RawData addrs, int n); /** + * Returns the label that is exported for the given method name. + */ + native private String getExternalLabel(String name); + + /** * If nth element of stack is an interpreted frame, return the * element representing the method being interpreted. */ @@ -212,6 +223,15 @@ public class NameFinder addr2lineOut.flush(); name = addr2lineIn.readLine(); file = addr2lineIn.readLine(); + + // addr2line uses symbolic debugging information instead + // of the actually exported labels as addr2name.awk does. + // This name might need some modification, depending on + // the system, to make it a label like that returned + // by addr2name.awk or dladdr. + if (! usingAddr2name) + if (name != null && ! "??".equals (name)) + name = getExternalLabel (name); } catch (IOException ioe) { addr2line = null; } } @@ -371,7 +391,7 @@ public class NameFinder int line = -1; if (fileName != null) { - int colon = file.indexOf(':'); + int colon = file.lastIndexOf(':'); if (colon > 0) { fileName = file.substring(0, colon); |