Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Elf addr2line fix

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.71
diff -u -r1.71 ChangeLog
--- ChangeLog	28 Feb 2003 21:30:01 -0000	1.71
+++ ChangeLog	11 Mar 2003 19:54:44 -0000
@@ -1,3 +1,12 @@
+2003-03-11 Alain Magloire
+
+	* utils/org/eclipse/cdt/utils/elf/Elf.java (Symbol:getLineInfo):
+	The address value may not align with the debug information, for example when
+	adding Profiling etc .. we try to get the nearest symbol as a fallback.
+	We've seen this behaviour on PPC and ARM boards.
+	* utils/org/eclipse/cdt/utils/CPPFilt.java:
+	Remove unused fields.
+
 2003-02-26 Alain Magloire
 
 	The second part to finish the cdt-core-home/docs/binaryparser.html
Index: utils/org/eclipse/cdt/utils/CPPFilt.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/CPPFilt.java,v
retrieving revision 1.1
diff -u -r1.1 CPPFilt.java
--- utils/org/eclipse/cdt/utils/CPPFilt.java	26 Jun 2002 20:38:33 -0000	1.1
+++ utils/org/eclipse/cdt/utils/CPPFilt.java	11 Mar 2003 19:54:44 -0000
@@ -17,7 +17,6 @@
 	private Process cppfilt;
 	private BufferedReader stdout;
 	private BufferedWriter stdin;
-	private String function;
 			
 	public CPPFilt() throws IOException {
 		String[] args = {"c++filt"};
Index: utils/org/eclipse/cdt/utils/elf/Elf.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java,v
retrieving revision 1.9
diff -u -r1.9 Elf.java
--- utils/org/eclipse/cdt/utils/elf/Elf.java	29 Jan 2003 14:26:42 -0000	1.9
+++ utils/org/eclipse/cdt/utils/elf/Elf.java	11 Mar 2003 19:54:44 -0000
@@ -303,8 +303,16 @@
 			if ( line == null ) {
 				if ( addr2line == null )
 					addr2line = new Addr2line(file);
-				line = addr2line.getLine(st_value + 19);
-				func = addr2line.getFunction(st_value + 19);
+				long value = st_value;
+				// We try to get the nearest match
+				// since the symbol may not quite align with debug info.
+				for (int i = 0; i <= 20; i += 4, value += i) {
+					line = addr2line.getLine(value);
+					if (!line.startsWith("??")) {
+						break; // bail out
+					}
+				}
+				func = addr2line.getFunction(value);
 			}
 			return line;
 		}



Back to the top