WALA icon indicating copy to clipboard operation
WALA copied to clipboard

Document need for NormalReturnCaller statement to do a backward slice from return value of a call

Open marionette-sarka opened this issue 5 years ago • 6 comments

I tried to do a backward slice, but I didn't get the results I expected.

The configuration is as follows.

  • Slicer.DataDependenceOptions.FULL
  • Slicer.ControlDependenceOptions.NO_EXCEPTIONAL_EDGES
  • CallGraphBuilder: makeZeroOneContainerCFABuilder
  • slice seed: list.get(0)
  • java version: 1.8.0_211
  • WALA version: 1.5.5

The code to be analyzed:

public class ArraySample {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();

        list.add(2);
        list.add(3);

        System.out.println(list.get(0));
    }
}

slice result:

List<Integer> list = new ArrayList<>();
list.get(0)

The slice results I expect.:

List<Integer> list = new ArrayList<>();
list.add(2);
list.add(3);
list.get(0)

Is this the correct result? If so, how can I get the results I expect?

Could you give me some advice if convenient.

marionette-sarka avatar Aug 22 '20 07:08 marionette-sarka

I think this is due to trickiness with slicing based on results of invocations. You want to set your slice seed to be a NormalReturnCaller statement. See this thread. Does that fix the problem? Assuming it does I will keep this issue open until the documentation is improved. Sorry for this trouble.

msridhar avatar Aug 22 '20 21:08 msridhar

@msridhar Thank you for your reply.

I set the NormalReturnCaller as a slice seed and tried a backward slice, but I was not able to get the expected results.

Slice result is only slice seed(list.get(0)).

marionette-sarka avatar Aug 23 '20 07:08 marionette-sarka

@malionet-sarka see the test I added in #803. With a NormalReturnCaller statement things are working there. So you can check and see where your code differs. Let us know.

msridhar avatar Aug 23 '20 16:08 msridhar

Correction: I switched #803 to use 0-1-container CFA builder. I still get the add calls in the slice, but for some reason it is now missing the calls to Integer.valueOf() to box the int parameters at the calls to add. I will investigate further. Still, @malionet-sarka you should be seeing the add() calls in your slice.

msridhar avatar Aug 23 '20 16:08 msridhar

@msridhar Thank you for your reply and test code.

I compared the presented code with my own code and modified it to work well.

I found out that there was a mistake in my Exclusions configuration. I'm sorry for the stupid mistake.

However, I didn't know about NormalReturnCaller, so this was a good insight for me.

Thank you very much.

marionette-sarka avatar Aug 24 '20 07:08 marionette-sarka

No problem! I'll leave this issue open until documentation is fixed.

msridhar avatar Aug 24 '20 16:08 msridhar