This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: stack trace: Don't repeat addr2line calls if name lookup fails


Andrew noticed that a lot of time is wasted repeating addr2line calls during stack trace printing even for binaries that do not have any debug info. This patch makes NameFinder add any binaries for which addr2line fails to a "blacklist", and avoids calling addr2line on that binary again.

I'm checking this in to trunk.

Bryce


2006-05-11  Bryce McKinlay  <mckinlay@redhat.com>

	* gnu/gcj/runtime/NameFinder.java (blacklist): New static field.
	(lookup): If addr2line fails to find an address, flag the binary as
	having no debug info and avoid calling addr2line on it again.

Index: NameFinder.java
===================================================================
--- NameFinder.java	(revision 113708)
+++ NameFinder.java	(working copy)
@@ -20,8 +20,11 @@
 import java.io.OutputStreamWriter;
 import java.io.IOException;
 import java.io.File;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
 
 
 /**
@@ -54,6 +57,10 @@
   private String sourceFile;
   private int lineNum;
   private HashMap procs = new HashMap();
+  /**
+   * Set of binary files that addr2line should not be called on.
+   */
+  private static Set blacklist = Collections.synchronizedSet(new HashSet());
 
   private static final boolean use_addr2line
           = Boolean.valueOf(System.getProperty
@@ -150,7 +157,7 @@
     sourceFile = null;
     lineNum = -1;
     
-    if (! use_addr2line)
+    if (! use_addr2line || blacklist.contains(file))
       return;
     Addr2Line addr2line = (Addr2Line) procs.get(file);
     if (addr2line == null)
@@ -179,6 +186,12 @@
 	  String lineNumStr = result.substring(split + 1, result.length());
 	  lineNum = Integer.parseInt (lineNumStr);
 	}
+      else
+        {
+	  /* This binary has no debug info (assuming addr was valid). 
+	     Avoid repeat addr2line invocations. */
+ 	  blacklist.add(binaryFile);
+	}
       }
     catch (IOException ioe)
       {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]