soot
soot copied to clipboard
Jimple type assigner ignores the LocalVariableTable
Describe the bug
The LocalVariableTable included in the class I am currently analyzing is being ignored by the Jimple type assigner. The input class was compiled using javac, with the -g option.
From what I understand Soot by default uses a heuristic to compute the type of local variables. For the analysis I am currently performing I cannot afford to lose this debug type information. Inferred types can be ambiguous for "integer" types, as it is shown in my simple example.
I was initially not sure if this should be considered a bug. Since the name contents of the variable table are being considered correctly when using the jb.use-original-names option, I would have also expected the type information to be included in the analysis.
Input file The java class that I am currently analyzing is the following:
public class Unit {
public void singleAssignmentMethod() {
int a = 1;
}
}
To reproduce Given my current javac version:
javac 11.0.13
And Soot version:
org.soot-oss:soot:4.1.0
First, I compiled the input class as follows:
javac -g Unit.java
It is then possible to check for the presence of the LocalVariableTable by running the following command on the output class:
javap -l Unit.class
Finally, I use the Soot API to compute the JimpleBody of singleAssignmentMethod. The options I am currently using are the following:
Options.v().setPhaseOption("jb", "use-original-names:true");
Options.v().set_output_format(Options.output_format_jimple);
Options.v().set_whole_program(true);
Expected behavior The Jimple code generated from the input method specified above is:
public void singleAssignmentMethod()
{
boolean a;
foo.bar.Unit this;
this := @this: foo.bar.Unit;
a = 1;
return;
}
Since the LocalVariableTable specifies a to be a variable of type I, I would instead expect:
public void singleAssignmentMethod()
{
int a;
foo.bar.Unit this;
this := @this: foo.bar.Unit;
a = 1;
return;
}
@paganma did you find the answer to this question? I'm facing the same issue in Soot version 4.1.1. Local variable table shows information for constant variables, but this information is not being used by Soot for the Jimple body creation.
Nevermind, it is related to this other issue: https://github.com/soot-oss/soot/issues/1641