From 71be7c5a75a594b2205c3a29f56af900bc54a4ba Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Tue, 11 Mar 2003 20:03:06 +0000 Subject: [PATCH] The address may no line with the debug information. --- .../utils/org/eclipse/cdt/utils/elf/Elf.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java index 0fbeefb8b13..5769bd0e417 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/elf/Elf.java @@ -303,8 +303,16 @@ public class Elf { 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; }