Skip to content

Commit 3ff1b1b

Browse files
committed
fixing counting
1 parent 10a2bde commit 3ff1b1b

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

src/main/java/it/unipr/EVMLiSA.java

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.apache.commons.cli.Options;
3737
import org.apache.commons.cli.ParseException;
3838
import org.apache.commons.collections4.SetUtils;
39-
import org.apache.commons.collections4.SetUtils.SetView;
4039
import org.apache.logging.log4j.LogManager;
4140
import org.apache.logging.log4j.Logger;
4241

@@ -234,7 +233,7 @@ else if (cmd.hasOption("bytecode")) {
234233
}
235234

236235
EVMLiSA.analyzeContract(contract);
237-
System.err.println(contract);
236+
// System.err.println(contract);
238237
EVMLiSAExecutor.shutdown();
239238
}
240239

@@ -571,27 +570,27 @@ private static StatisticsObject<?> computeJumps(JumpSolver checker, Set<Statemen
571570
}
572571
if (topStackValuesPerJump == null) {
573572
// If all stacks are bottom, then we have a
574-
// maybeFakeMissedJump
573+
// definitelyUnreachable
575574
definitelyUnreachable++;
576575
continue;
577576
}
578577
if (!topStackValuesPerJump.contains(StackElement.TOP)) {
579578
// If the elements at the top of the stacks are all
580-
// different from NUMERIC_TOP, then we are sure that it
581-
// is definitelyFakeMissedJumps
579+
// different from TOP, then we are sure that it
580+
// is resolved
582581
resolvedJumps++;
583582
continue;
584583
}
585-
if (soundlySolved != null && !soundlySolved.contains(jumpNode)) {
584+
if (checker.getMaybeUnsoundJumps().contains(jumpNode)) {
585+
maybeUnsoundJumps++;
586+
continue;
587+
}
588+
if (!soundlySolved.contains(jumpNode)) {
586589
unsoundJumps++;
587590
log.error("{} not solved", jumpNode);
588591
log.error("getTopStackValuesPerJump: {}", topStackValuesPerJump);
589592
continue;
590593
}
591-
if (checker.getMaybeUnsoundJumps().contains(jumpNode)) {
592-
maybeUnsoundJumps++;
593-
continue;
594-
}
595594

596595
resolvedJumps++;
597596
}
@@ -642,23 +641,28 @@ private static StatisticsObject<?> computePaperJumps(JumpSolver checker, Set<Sta
642641
if (cfg.getAllPushedJumps().contains(jumpNode))
643642
// stacks of pushed jumps are not stored for optimization
644643
resolved++;
645-
else if (!cfg.reachableFrom(entryPoint, jumpNode) || checker.getUnreachableJumps().contains(jumpNode))
646-
// getUnreachableJumps() contains jumps where the whole value state went to bottom
647-
unreachable++;
648-
else if (checker.getMaybeUnsoundJumps().contains(jumpNode))
644+
else if (soundlySolved.contains(jumpNode))
645+
// soundlySolved contains getMaybeUnsoundJumps() (whole value state went to top)
646+
// and getUnsoundJumps() (at least one stack has top on front)
647+
unknown++;
648+
else if (checker.getUnsoundJumps().contains(jumpNode) || checker.getMaybeUnsoundJumps().contains(jumpNode))
649+
// getUnsoundJumps() contains jumps where at least one top stack is top
649650
// getMaybeUnsoundJumps() contains jumps where the whole value state went to top
650651
unknown++;
652+
else if (!cfg.reachableFrom(entryPoint, jumpNode) || checker.getUnreachableJumps().contains(jumpNode))
653+
// getUnreachableJumps() contains jumps where the whole value state went to bottom
654+
unreachable++;
651655
else {
652656
Set<StackElement> topStacks = checker.getTopStackValuesPerJump(jumpNode);
653-
if (topStacks.isEmpty())
657+
if (topStacks.isEmpty())
654658
unreachable++;
655-
else if (topStacks.stream().allMatch(StackElement::isBottom))
659+
else if (topStacks.stream().allMatch(StackElement::isBottom))
656660
erroneous++;
657-
else if (topStacks.stream().anyMatch(StackElement::isTop))
661+
else if (topStacks.stream().anyMatch(StackElement::isTop))
658662
unknown++;
659-
else
663+
else
660664
resolved++;
661-
}
665+
}
662666

663667
PaperStatisticsObject stats = PaperStatisticsObject.newStatisticsObject()
664668
.totalOpcodes(cfg.getOpcodeCount())

0 commit comments

Comments
 (0)