Wrong testcase for sheet 4 task 1

Moderator: Implementing code analyses for large software systems

errt
Mausschubser
Mausschubser
Beiträge: 61
Registriert: 18. Okt 2012 19:12

Wrong testcase for sheet 4 task 1

Beitrag von errt »

When implementing task 1 a), we came to the conclusion that the testcase for TargetClass2 is incorrect. As in the TargetClass1 testcase, the branch parameter is asserted to be false. This would mean the code is actually alive (as the branch condition is inverted), which is correct in TargetClass1 (as 3,4,5 is a pythagoras triple), but wrong for TargetClass2 (as v = 0).

Johannes Spaeth
Erstie
Erstie
Beiträge: 11
Registriert: 30. Okt 2014 13:29

Re: Wrong testcase for sheet 4 task 1

Beitrag von Johannes Spaeth »

Hi,

speaking of the Java source code, you are right.
But as we analyze Jimple, the reporting is also based on the Jimple code, where the conditions are somewhat different!

So have a look into the Jimple code, what needs to be reported. I hope it helps!

Johannes

errt
Mausschubser
Mausschubser
Beiträge: 61
Registriert: 18. Okt 2012 19:12

Re: Wrong testcase for sheet 4 task 1

Beitrag von errt »

That's exactly what we did:

The jimple code of the branch in TargetClass1 is

Code: Alles auswählen

if h != b goto label1;
. As h = 25 and b = 25, this branch is never taken.
The jimple code of the branch in TargetClass2 is

Code: Alles auswählen

$b0 = v cmpl 0.0;
if $b0 <= 0 goto label1;
. Now, v = 0, so $b0 is 0, too. This branch therefore is always taken. We therefore have to report differently to the first test, but the testcase asserts the same as for TargetClass1.

Johannes Spaeth
Erstie
Erstie
Beiträge: 11
Registriert: 30. Okt 2014 13:29

Re: Wrong testcase for sheet 4 task 1

Beitrag von Johannes Spaeth »

Hi,

now I see the point, but the error was in TargetClass1, as there is actually no dead code. So I added an else Stmt in the targetclass, which is then of course dead at this point.

So for

Code: Alles auswählen

if h != b goto label1;
you must report true as this branch (starting at label1) is then dead (becaue h == b always holds).

So please update the template from the repository!

Antworten

Zurück zu „Implementing code analyses for large software systems (ICA)“