You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Produces incorrect slices given the following source code (line numbers included for clarity):
1 void bar(int a, int b) {
2 if (a != 0) return;
3 if (b == 42) return;
4 printf("%d %d\n", a, b);
5 }
6
7 int foo(int x) {
8 int v = 0;
9 for (int i = 0; i < x; ++i) {
10 v++;
11 }
12 bar(x, v);
13 return 0;
14 }
15
16 int main() {
17 int n = 3;
18 return foo(n);
19 }
In the first line of the srcSlice output, n is correctly defined and used. However, I also expected n to appear in cfuncs{foo(1)}. Additionally, variable v is incorrectly stated to be used on lines 2 & 4 which appears to actually be where variable x should be used.
Is this the expected output? If not, is this resolved when building most recent version from source?
Okay so, after building srcSlice from master, the slice might still be slightly incorrect on the above example:
==========================================================================
Name and type: n
Contains Declaration: 1 Containing class:
Dvars: {}
Aliases: {}
Cfunctions: {printf 2,bar 1,foo 1,}
Use: {4,12,}
Def: {1,7,17,}
Control Edges: {(0, 17),}
==========================================================================
==========================================================================
Name and type: v
Contains Declaration: 1 Containing class:
Dvars: {}
Aliases: {}
Cfunctions: {printf 3,bar 2,}
Use: {4,10,12,}
Def: {1,8,}
Control Edges: {(8, 10),(8, 12),(10, 12),}
==========================================================================
==========================================================================
Name and type: x
Contains Declaration: 1 Containing class:
Dvars: {}
Aliases: {}
Cfunctions: {printf 2,bar 1,}
Use: {4,12,}
Def: {1,7,}
Control Edges: {(7, 12),}
==========================================================================
==========================================================================
Name and type: b
Contains Declaration: 1 Containing class:
Dvars: {}
Aliases: {}
Cfunctions: {printf 3,}
Use: {4,}
Def: {1,}
Control Edges: {(1, 4),}
==========================================================================
==========================================================================
Name and type: a
Contains Declaration: 1 Containing class:
Dvars: {}
Aliases: {}
Cfunctions: {printf 2,}
Use: {4,}
Def: {1,}
Control Edges: {(1, 4),}
==========================================================================
I expected variable n to be used on lines 2, 4, 9, 12, 18.
I expected variable v to be used on lines 3, 4, 10, 12.
I expected variable x to be used on lines 2, 4, 9, 12.
I expected variable b to be used on lines 3, 4.
I expected variable a to be used on lines 2, 4.
These are still better than the results from my original post, but what I got was still slightly different than what I expected. Please let me know if I'm interpreting this incorrectly.
Yes, there have been several updates to srcML which may affect the quality of srcSlice output, beside the known bugs that already existed. The tool needs maintenance and I have very little time to give it the attention it needs.
I will be working on it some in the last couple weeks before the semester begins again. We will see how much I am able to complete.
If there are any specific issues or features of srcSlice that you can elaborate on, I would be happy to take a look and submit pull requests where I can.
Activity
archived-c commentedon Oct 12, 2020
Okay so, after building srcSlice from master, the slice might still be slightly incorrect on the above example:
I expected variable
nto be used on lines 2, 4, 9, 12, 18.I expected variable
vto be used on lines 3, 4, 10, 12.I expected variable
xto be used on lines 2, 4, 9, 12.I expected variable
bto be used on lines 3, 4.I expected variable
ato be used on lines 2, 4.These are still better than the results from my original post, but what I got was still slightly different than what I expected. Please let me know if I'm interpreting this incorrectly.
Thanks
cnewman commentedon Jan 8, 2021
Yes, there have been several updates to srcML which may affect the quality of srcSlice output, beside the known bugs that already existed. The tool needs maintenance and I have very little time to give it the attention it needs.
I will be working on it some in the last couple weeks before the semester begins again. We will see how much I am able to complete.
archived-c commentedon Jan 11, 2021
Understandable, thanks for the reply.
If there are any specific issues or features of srcSlice that you can elaborate on, I would be happy to take a look and submit pull requests where I can.