I have only recently started to work with Wala for my master thesis.
I would like to include local parameters and static attributes in the
slice, which are currently not found.
For local parameters I could work this out.
private static int getLineNumber(int parameterIndex, Statement
statement, SSAAbstractInvokeInstruction ssa) {
PointerKey pointerKey =
pa.getHeapModel().getPointerKeyForLocal(statement.getNode(),
ssa.getUse(parameterIndex));
OrdinalSet<InstanceKey> set = pa.getPointsToSet(pointerKey);
if (!set.iterator().hasNext()) {
return -1;
}
InstanceKey instanceKey = set.iterator().next();
System.out.println("InstanceKey: " + instanceKey);
.....
return lineNumber;
}
Is it possible that I get the line number of the source code by using
the InstanceKey?
For statements this is no problem, but I can't find any idea or solution
for InstanceKeys.
Furthermore, I would like to know how to get the InstanceKey for static
attributes.
Or is my approach wrong and there is an easier/better way to get the
line number of the source code of local parameters and attributes?
Thanks for your help in advance.
Greeting,
Marcel
_______________________________________________
Wala-wala mailing list
Wala...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wala-wala
--
Hi Raffi,
Thanks for your tip. I took a closer look at the code and
InstanceKey again.
InstanceKey unfortunately does not know SourcePosition. As far as
I understood the code, you get SoucePosition or the line number
via the instructionIndex. The problem is, the local variables are
not directly mapped in the IR and therefore have no
instructionIndex.
With this I mean the following point:
http://wala.sourceforge.net/wiki/index.php/UserGuide:Slicer
"Warning: exclusion of copy statements from slice".
Marcel
Hi Manu,
Unfortunately, this approach does not work either, since it also
accesses instructions that do not exist. That is why there was a
NullPointerExpetion.
It's best if I show you a sample of what I'm testing it on.
private static int keyTwo = 256;
public static void main(String[] args) {
String s = "AES";
Read read = Read.getInstance(s);
SecRand secRand = new SecRand();
int key = 256;
String hallo = "hallo";
test(hallo);
read.init(key, secRand, keyTwo);
read.generate();
}
This example does not recognize "int key = 256" and string s =
"AES", as expected.
I am looking at "read.init(key, secRand, keyTwo);". The statement
is:
NORMAL main:invokevirtual < Application, LRead,
init(ILSecRand;I)V > 5,8,6,11 @37 exception:12 Node: <
Application, LReadWrite, main([Ljava/lang/String;)V > Context:
Everywhere
If I output the statements (IR) as PDF, this one looks like this.
invokevirtual < Application, LRead, init(ILSecRand;I)V >
v5,v8:#256,v6,v11 @37 exception:v12
This means v8 is "key", v6 is "secRand" and v11 is "keyTwo". So I
try to get the line number from v8 somehow.
The PointerKey for this is: pointerKey[Node: < Application,
LReadWrite, main([Ljava/lang/String;)V > Context: Everywhere,
v8]
But from this key there is no InstanceKey through
"pa.getPointsToSet(pointerKey)". I've only just realized it.
Therefore it is also possible that Wala has completely deleted
this information. Because that would mean that it would be
impossible to find out the LineNumber.
But maybe not, it's just a theory.
Marcel