srcML / srcSlice

Lightweight tool for slicing
34 stars 16 forks source link

can't see the slines field in Old Version #28

Closed PhamAn12 closed 3 years ago

PhamAn12 commented 4 years ago

I used the old version to check my c program for slicing. But I can't see the slices field in the output . Is that an error ?

cnewman commented 4 years ago

If you're referring to slines, then srcSlice doesn't output slines directly.

It outputs 'use' and 'def'. Slines = use U def where U is a union operation. So you just have to combine those together to get slines.

If you did not mean slines, please let me know.

PhamAn12 commented 4 years ago

That's exactly what I want to ask. Thank you for your answer. I tried the input program with variable Struct, and the results seem to be inaccurate. That's my input a.c :

#include <stdio.h> 

// An example function that takes two parameters 'x' and 'y' 
// as input and returns max of two input numbers 
struct nguoi {
    int ngaysinh;
    int thangsing;
};
int max(int x, int y) 
{ 
    if (x > y) 
      return x; 
    else
      return y; 
} 

// main function that doesn't receive any parameter and 
// returns integer. 
int main(void) 
{ 
    int a = 10, b = 20; 
    struct nguoi cc;
    cc.ngaysinh = 1;
    cc.thangsing = 2;
    // Calling above function to find max of 'a' and 'b' 
    int m = max(a, b); 

    printf("m is %d", m); 
    return 0; 
} 

And the output like that : (At output.cpp, I call TestSlice function in srcSliceToCsv function) Time is: 0.000517

Variable: m Slines: {0,} variables dependant on this one: {} is aliase for: {} cfuntions: {printf 2,} def: {0,} use: {0,}


Variable: xycc Slines: {0,} variables dependant on this one: {} is aliase for: {} cfuntions: {} def: {0,} use: {}


Variable: cc Slines: {0,} variables dependant on this one: {} is aliase for: {} cfuntions: {} def: {0,} use: {0,}


Variable: b Slines: {0,} variables dependant on this one: {} is aliase for: {} cfuntions: {max 2,} def: {0,} use: {0,}


Variable: Slines: {0,} variables dependant on this one: {} is aliase for: {} cfuntions: {} def: {0,} use: {}


Variable: a Slines: {0,} variables dependant on this one: {} is aliase for: {} cfuntions: {max 1,} def: {0,} use: {0,}


Variable: y Slines: {0,} variables dependant on this one: {} is aliase for: {} cfuntions: {} def: {0,} use: {0,}


Variable: x Slines: {0,} variables dependant on this one: {} is aliase for: {} cfuntions: {} def: {0,} use: {0,}

where was i wrong ? Have you covered all the cases yet?

cnewman commented 4 years ago

Typically, this happens when you've run srcML without --position turned on.

i.e., srcml --position (input file)

--position turns on line position information in the srcML archive, which srcSlice requires to run correctly.

In the newer srcSlice version we tell you when we see that this has happened, but the old version, unfortunately, does not. Hopefully, the new version will be completed soon.