1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

fixed problem with not getting line no. all the time

This commit is contained in:
David Inglis 2003-11-06 18:40:24 +00:00
parent 14df45f11f
commit 91f05a8d02

View file

@ -83,17 +83,21 @@ public class Addr2line {
* hello.c:39
*/
public int getLineNumber(long address) throws IOException {
int lineno = -1;
String line = getLine(address);
int colon;
if (line != null && (colon = line.lastIndexOf(':')) != -1) {
try {
lineno = Integer.parseInt(line.substring(colon + 1));
lineno = (lineno == 0) ? -1 : lineno;
} catch(Exception e) {
// We try to get the nearest match
// 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, address += i) {
String line = getLine(address);
if (line != null) {
int colon = line.lastIndexOf(':');
String number = line.substring(colon + 1);
if (!number.startsWith("0")) {
return Integer.parseInt(number);
}
}
}
return lineno;
return -1;
}
public void dispose() {