[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Line numbers for SootMethod, SootField, SootClass



javac does not insert any line numbers into bytecode for methods or
fields. Since Soot reads bytecode, there is no way for it to get any
such infromation.

Ondrej

On Tue, Jan 21, 2003 at 06:12:30PM -0000, 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
>