1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Check if the line number == 0 and keep on trying.

This commit is contained in:
Alain Magloire 2003-03-12 15:09:23 +00:00
parent f28d3b262d
commit f11a0b5d1f

View file

@ -305,11 +305,17 @@ public class Elf {
addr2line = new Addr2line(file); addr2line = new Addr2line(file);
long value = st_value; long value = st_value;
// We try to get the nearest match // 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) { for (int i = 0; i <= 20; i += 4, value += i) {
line = addr2line.getLine(value); line = addr2line.getLine(value);
if (!line.startsWith("??")) { if (line != null) {
break; // bail out int colon = line.lastIndexOf(':');
String number = line.substring(colon + 1);
if (!number.startsWith("0")) {
break; // bail out
}
} }
} }
func = addr2line.getFunction(value); func = addr2line.getFunction(value);