[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Line numbers for SootMethod, SootField, SootClass
Hi,
The LineNumberTable is an attribute of *Code* attribute. Its format
contains startpc and line number. So naturally the line number tags are
attached to Unit (which corresponds to bytecode in class files). There is
not line number tag for SootMethod, SootField, and SootClass. You should
traverse the method body (Units) and check the line number tags. Hope this
clarifies your question.
Cheers,
Feng
---------------------------------------------------------------------
Feng Qian fqian@sable.mcgill.ca
Sable Research Group http://www.sable.mcgill.ca
School of Computer Science, McGill University Montreal, Canada
On Tue, 21 Jan 2003, Eric Bodden wrote:
> Hi!
>
> I just wanted to know if it is somehow possible to extract line numbers
> for the objects stated above? I already tried by applying getTags() and
> looking for a LineNumberTag. But all these objects do not seem to have a
> tag.
>
> Here the code I used:
> --
> /**
> * extract the Soot line mumber if given
> * @param sootObject the SootClass, SootMethod or SootField whose
> linenumber should
> * be extracted
> * @return the appropriate line number or -1 if there ws no number
> found
> */
> public static int extractLineNumber(AbstractHost sootObject) {
> int line = -1;
> for (Iterator j = sootObject.getTags().iterator(); j.hasNext() &&
> line<0; ) {
> Tag tag = (Tag)j.next();
> if (tag instanceof LineNumberTag) {
> byte[] value = tag.getValue();
> line = ((value[0] & 0xff) << 8) | (value[1] & 0xff);
> }
> System.out.println(tag.getClass().getName());
> }
> return line;
> }
> --
>
> It always returns -1 and sootObject.getTags().size() is always 0 :-/
>
> Thanks,
> Eric
>
> ------------------------------------------------------------
> Eric Bodden
> University of Kent at Canterbury
>
>