Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inquire about running gdart on a specific function in large code #4

Open
BEbillionaireUSD opened this issue Nov 12, 2024 · 2 comments

Comments

@BEbillionaireUSD
Copy link

BEbillionaireUSD commented Nov 12, 2024

Hi, Thanks for this wonderful work.
I'm wondering how to run symbolic execution on a specific function. For example

public class Example {
    private static int i;
    public static void main(String[] args) {
       foo(3);
      bar(2);
    }

    public static int foo(int x) {
	return 1/x;
    }
     public static int bar(int x) {
	return x+1;
    }

}

What should I do if I just want to run gdart on bar?

@mmuesly
Copy link
Member

mmuesly commented Nov 12, 2024

Hi, you are welcome. It is necessary to write a test harness (A main method potentially in another class) that calls only bar. We do not support any kind of annotations that do this for you at the moment.

You can use the Verifier Stub Class to create nonDeterministic values in the test harness that can be used as parameters to bar.
The test driver might look similar to this skeleton:

public class DriverBar {
    public static ... main(String...){
      int x = Verfier.nondetInt()
      bar(x)
    }
}

Then run GDart on the DriverBar class. I hope this helps you to get started.

@BEbillionaireUSD
Copy link
Author

BEbillionaireUSD commented Nov 13, 2024

Thanks for your reply! I followed your guidance, and it seems to work, but my function involves too many loops, so it takes a very long time. Could you please tell me how to set some extra constraints on the function's parameter(s)?
For example, 0<=x<=10?

In addition, can I record the specific paths with respect to a specific input?
For example, in

public static int bar(int x) {
    if(x>=1){
	return x+1;
    }else if (x<0){
    return x + 3;
   } else {
    return x;
   }
}

When setting x==2, gdart is expected to return x+1 only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants