[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Line number resolving
If you have a SootMethod, you cen get its body (basically, the
instructions) by a call to getBody(). Then you get the chain of Units
(the instructions themselves) by calling getUnits(). Iterate over these,
and look for ones that have Invoke expressions (see containsInvokeExpr()
method in Stmt; Jimple Unit's can be cast to Stmt's). You can also use
getTag() on the Unit's to get the tag containing the line number. For
the rest, I think it was answered a month ago when someone else asked a
related question, so I'm attaching my reply to that question.
Hope this helps.
Ondrej
On Sat, Dec 14, 2002 at 11:38:43AM -0500, Ondrej Lhotak wrote:
> I'm assuming that you are looking for the declared type of a. When the
> program runs, the actual object could be any subtype of it.
>
> You will first need to make sure your InvokeExpr is an
> InstanceInvokeExpr. An InstanceInvokeExpr has a receiver; an InvokeExpr
> may not, if it is a call to a static method, for example. From an
> InstanceInvokeExpr, you can call getBase() to get the receiver of the
> call (the a, in your example). You then call getType() on it to get its
> declared type. You should be able to cast the type to a RefType,
> and then call getSootClass() on it to get the corresponding SootClass.
>
> Hope that helps.
>
> Ondrej
>
> On Fri, Dec 13, 2002 at 12:28:02PM -0500, Matthew J Rummel wrote:
> > Mr. Soot,
> >
> > I have a question regarding InvokeExprs. (At least I think they are
> > called InvokeExprs). Say you have an expression in the code where 'a' is
> > an instance of a class and 'doSomthing()' is a method in that class:
> >
> > a.doSomthing()
> >
> > its it possible to get the SootClass that a is an instance of every time
> > you come across a call to a method like this? I have look through the API
> > and cannot come up with a good way to do this.
> >
> >
> >
> > -Matt
On Wed, Jan 15, 2003 at 03:12:04PM -0000, Eric Bodden wrote:
> > This seems like a reasonable approach. Soot should propagate
> > the source line numbers to tags in Jimple statements. You should then
> be able to
> > output from Soot whatever information you need about a Jimple
> > statement along with the source line number. If you come across
> problems with
> > this, please let us know.
>
> Hi!
>
> So i have now implemented this preprocessor which builds a new "single
> statement per line sourcefile and enables a 1:1 mapping between the
> original statement and the new location. That works fine so far. But now
> when I have the SootClass of the .class file belonging to this new
> representation, what exactly do I have to do to resolve the static type
> by line? (assumed, there is e.g. a method call in that line) Could you
> perhaps give s short scratch?
>
> Thank you very much
> Eric
>