From f11a0b5d1fe2496fcf8dc50ccbe6b4d8a54c93b8 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Wed, 12 Mar 2003 15:09:23 +0000 Subject: [PATCH] Check if the line number == 0 and keep on trying. --- .../utils/org/eclipse/cdt/utils/elf/Elf.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 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 5769bd0e417..31cc77f959c 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 @@ -305,11 +305,17 @@ public class Elf { addr2line = new Addr2line(file); long value = st_value; // We try to get the nearest match - // since the symbol may not quite align with debug info. + // since the symbol may not exactly align with debug info. + // In C line number 0 is invalid, line starts at 1 for file, we use + // this for validation. for (int i = 0; i <= 20; i += 4, value += i) { line = addr2line.getLine(value); - if (!line.startsWith("??")) { - break; // bail out + if (line != null) { + int colon = line.lastIndexOf(':'); + String number = line.substring(colon + 1); + if (!number.startsWith("0")) { + break; // bail out + } } } func = addr2line.getFunction(value);