[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: relating a unit to a sourceFile
david shepherd wrote:
> Has anyone solved the problem of, when given a Unit,
> finding the source file name? I realize that
> lineNumber has been implemented, and that getting the
> source file name as an attribute is probably simply a
> matter of adding attributes at some time in the
> translation from .class to a jimple representation,
> but I want to avoid searching for this spot if someone
> else has already solved the problem . . .
Here's what I've done...
// Get source file name
SootClass c = ...
try {
sourceFile = new String(
c.getTag("SourceFile").getValue(), "UTF8");
} catch (Exception e) {
sourceFile = "unknown";
}
Note that the source file is an attribute of the SootClass.
Cheers,
-Archie
__________________________________________________________________________
Archie Cobbs * Packet Design * http://www.packetdesign.com