[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Unable to fetch getLineNumber/Addr2line object using ElfBinaryObject.java

Hi All,

I am unable to fetch getLineNumber  of any symbol obtained using ELFBinayObject.java and ElfBinaryParser.java, I executed as following :

ElfBinaryObject elfBinaryObject = (ElfBinaryObject) elfParser.createBinaryObject(path);
ISymbol[] symbols = elfBinaryObject.getSymbols();
for(int i = 0; i< symbols.length ; i++){
System.out.println("Line : " + symbols[i].getLineNumber(<some offset value>) + "-- ");
}

it always returns -1.

I have checked the code  Symbol.java, there they internally returning the value as -1 only.
       //public void getElfBinaryObject
/*
* (non-Javadoc)
* @see org.eclipse.cdt.core.IBinaryParser.ISymbol#getLineNumber(long)
*/
public int getLineNumber(long offset) {
return -1;
}

We can achieve the line number by modifying the above code as follows :

public int getLineNumber(long offset) {
int line = -1;
try {
Addr2line addr2line = (Addr2line) binaryObj.getAddressFactory();   // This doesn't work..... 
if (addr2line != null) {
line = addr2line.getLineNumber(addr.add(offset));
addr2line.dispose();
}
} catch (IOException e){
}
return line;
}

But for this we doesn't have any way to fetch Addr2Line using ElfBinaryObject.java or ELF.java or the property IAddressFactory.

Please tell how to achieve to find Addr2line object or getLineNumber , as we do in GNUElfBinaryObject.java.
I am working in Windows OS , using Java API's. Please tell me if any patch related to it is been released so far or any other solution for this.


Thanks & Regards,
Kamakshi