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

How to dump call graph, pointer flow graph, and points-to set? #111

Closed
koushik0329 opened this issue Jul 10, 2024 · 11 comments
Closed

How to dump call graph, pointer flow graph, and points-to set? #111

koushik0329 opened this issue Jul 10, 2024 · 11 comments

Comments

@koushik0329
Copy link

Overall Description

Hello sir,

We have been using Tai-e and tried running the command to generate a .dot file. Here is the original command we used:
java -cp tai-e-all.jar pascal.taie.Main -cp foo.jar;bar.jar -m baz.Main -java 8 -a pta=cs:2-type;time-limit:60

For our project, we modified the command as follows:
java -cp tai-e-all-0.2.2.jar pascal.taie.Main -cp Person1.jar -m Person -java 8 -a pta=advanced:zipper-e;dump:true

the output is
8 -a pta=advanced:zipper-e;dump:true
Tai-e starts ...
Output directory: /home/koushik/O2PTA/tests/zipper_direct_flow/output
Writing options to /home/koushik/O2PTA/tests/zipper_direct_flow/output/options.yml
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
Writing log to /home/koushik/O2PTA/tests/zipper_direct_flow/output/tai-e.log
Writing analysis plan to /home/koushik/O2PTA/tests/zipper_direct_flow/output/tai-e-plan.yml
WorldBuilder starts ...
6699 classes with 64241 methods in the world
WorldBuilder finishes, elapsed time: 4.24s
pta starts ...
[Pointer analysis] elapsed time: 23.21s
-------------- Pointer analysis statistics: --------------
#var pointers: 5,7955 (insens) / 5,7955 (sens)
#objects: 6380 (insens) / 6380 (sens)
#var points-to: 386,4368 (insens) / 386,4368 (sens)
#static field points-to: 8396 (sens)
#instance field points-to: 83,4823 (sens)
#array points-to: 16,3107 (sens)
#reachable methods: 8307 (insens) / 8307 (sens)
#call graph edges: 4,5913 (insens) / 4,5913 (sens)

Zipper starts ...
Building OAG starts ...
Building OAG finishes, elapsed time: 0.82s
Building PCE starts ...
Building PCE finishes, elapsed time: 0.61s
68881 nodes in OFG
215102 edges in OFG
Building and analyzing PFG starts ...
Building and analyzing PFG finishes, elapsed time: 2.09s
#types: 1092
#avg. nodes in PFG: 439
#avg. edges in PFG: 1248
#precision-critical methods: 1522
Zipper finishes, elapsed time: 4.13s
[Pointer analysis] elapsed time: 3.69s
-------------- Pointer analysis statistics: --------------
#var pointers: 5,7955 (insens) / 5,7955 (sens)
#objects: 6380 (insens) / 6380 (sens)
#var points-to: 386,4368 (insens) / 386,4368 (sens)
#static field points-to: 8396 (sens)
#instance field points-to: 83,4823 (sens)
#array points-to: 16,3107 (sens)
#reachable methods: 8307 (insens) / 8307 (sens)
#call graph edges: 4,5913 (insens) / 4,5913 (sens)

pta finishes, elapsed time: 33.43s
Tai-e finishes, elapsed time: 38.02s
dump:true: command not found

Thank you for your assistance.
Best regards, Koushik Reddy Kambham

Expected Behavior

In the output folder, we found .yml files instead of the expected .dot files. Could you please guide us on how to generate the .dot file using Tai-e?

Current Behavior

In the output folder, we found .yml files instead of the expected .dot files. Could you please guide us on how to generate the .dot file using Tai-e?

Tai-e Arguments

Click here to see Tai-e Options
{{The content of 'output/options.yml' file}}
Click here to see Tai-e Analysis Plan
{{The content of 'output/tai-e-plan.yml' file}}
We have been using Tai-e and tried running the command to generate a .dot file. Here is the original command we used: java -cp tai-e-all.jar pascal.taie.Main -cp foo.jar;bar.jar -m baz.Main -java 8 -a pta=cs:2-type;time-limit:60

For our project, we modified the command as follows:
java -cp tai-e-all-0.2.2.jar pascal.taie.Main -cp Person1.jar -m Person -java 8 -a pta=advanced:zipper-e;dump:true

Tai-e Log

Click here to see Tai-e Log
{{The content of 'output/tai-e.log' file}}
We have been using Tai-e and tried running the command to generate a .dot file. Here is the original command we used: java -cp tai-e-all.jar pascal.taie.Main -cp foo.jar;bar.jar -m baz.Main -java 8 -a pta=cs:2-type;time-limit:60

For our project, we modified the command as follows:
java -cp tai-e-all-0.2.2.jar pascal.taie.Main -cp Person1.jar -m Person -java 8 -a pta=advanced:zipper-e;dump:true

Additional Information

No response

@zhangt2333
Copy link
Member

Could you specify which details you would like to include in the .dot file? Tai-e currently supports the following graphs:

  • Call Graph
  • Control Flow Graph
  • Interprocedural Control Flow Graph
  • Taint Flow Graph
  • Object Allocation Graph
  • Object Flow Graph

Additionally, we highly recommend using the latest version of Tai-e (v0.5.1-SNAPSHOT). A stable version will be available shortly.

@koushik0329
Copy link
Author

Call Graph and constraint graph

@zhangt2333
Copy link
Member

If you want to dump Call Graph to disk, please refer to this comment: #112 (comment).

Regarding the constraint graph, are you referring to constraints such as the statement x=y generating the constraint pts(y) ⊆ pts(x)?

@koushik0329
Copy link
Author

Yes that's the constraint graph

@koushik0329
Copy link
Author

koushik0329 commented Jul 12, 2024

And also can you help me on how to dump points-to set of all variables ?

@zhangt2333
Copy link
Member

Yes that's the constraint graph

Currently, Tai-e does not support dumping the PointerFlowGraph using the existing options. However, you can achieve this manually according to the following example:

public static void main(String[] args) throws Exception {
    pascal.taie.Main.main(
            "-pp",
            "-cp", "src/test/resources/pta/basic",
            "-m", "New",
            "-a", "pta=implicit-entries:false;only-app:true;dump:true;"
    );
    // access PointerFlowGraph through reflection as it is not publicly exposed now
    PointerAnalysisResult result = World.get().getResult(PointerAnalysis.ID);
    Field pfgField = Class.forName("pascal.taie.analysis.pta.PointerAnalysisResultImpl")
            .getDeclaredField("pfg");
    pfgField.setAccessible(true);
    PointerFlowGraph pfg = (PointerFlowGraph) pfgField.get(result);
    // dump the PointerFlowGraph
    new DotDumper().dump(pfg, new File(World.get().getOptions()
            .getOutputDir(), "pfg.dot"));
}

And also can you help me on how to dump points-to set of all variables ?

To do this, use the following option: "-a", "pta=dump:true;" (-a "pta=dump:true;")

For more details, refer to the Tai-e documentation on specific analysis options. The relevant pta analysis option can be found in

dump: false # whether dump points-to results (with contexts)
dump-ci: false # whether dump points-to results (without contexts)
dump-yaml: false # whether dump points-to results in yaml format

@koushik0329
Copy link
Author

Thank you very much for your patience. It helped me a lot.

@silverbullettt silverbullettt changed the title Issue while generating .dot file output How to dump call graph, pointer flow graph, and points-to set? Jul 18, 2024
@koushik0329
Copy link
Author

Running Zipper and dumping constraint graph, call graph, points to set - all are not working at same time.

java -cp tai-e-all-0.2.2-output.jar pascal.taie.Main -cp Person.jar -m Person -java 8 -a pta=advanced:zipper -a "pta=only-app:true;dump:true;" -a "cg=dump:true;dump-call-edges:true;"

When I run this command, the flag to dump constraint graph, call graph and points-to-set are overriding the flag to run zipper, so the zipper is not able to run.

The output when the run the above command is

Tai-e starts ...
Output directory: /home/koushik/O2PTA/tests/zipper_direct_flow/output
Writing options to /home/koushik/O2PTA/tests/zipper_direct_flow/output/options.yml
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
Writing log to /home/koushik/O2PTA/tests/zipper_direct_flow/output/tai-e.log
Writing analysis plan to /home/koushik/O2PTA/tests/zipper_direct_flow/output/tai-e-plan.yml
WorldBuilder starts ...
6699 classes with 64241 methods in the world
WorldBuilder finishes, elapsed time: 4.84s
pta starts ...
[Pointer analysis] elapsed time: 0.34s
-------------- Pointer analysis statistics: --------------
#var pointers:                27 (insens) / 27 (sens)
#objects:                     11 (insens) / 11 (sens)
#var points-to:               27 (insens) / 27 (sens)
#static field points-to:      0 (sens)
#instance field points-to:    4 (sens)
#array points-to:             1 (sens)
#reachable methods:           25 (insens) / 25 (sens)
#call graph edges:            14 (insens) / 14 (sens)
----------------------------------------
Dumping points-to set (with contexts) to /home/koushik/O2PTA/tests/zipper_direct_flow/output/pta-results.txt
Dumping pointer flow graph to /home/koushik/O2PTA/tests/zipper_direct_flow/output/pfg.dot
pta finishes, elapsed time: 0.92s
cg starts ...
Call graph has 25 reachable methods and 14 edges
Dumping call graph to /home/koushik/O2PTA/tests/zipper_direct_flow/output/call-graph.dot
Dumping call edges to /home/koushik/O2PTA/tests/zipper_direct_flow/output/call-edges.txt
cg finishes, elapsed time: 0.06s
Tai-e finishes, elapsed time: 6.29s

When I run only zipper i.e.,
java -cp tai-e-all-0.2.2-output.jar pascal.taie.Main -cp Person.jar -m Person -java 8 -a pta=advanced:zipper

we can see the zipper is working

Tai-e starts ...
Output directory: /home/koushik/O2PTA/tests/zipper_direct_flow/output
Writing options to /home/koushik/O2PTA/tests/zipper_direct_flow/output/options.yml
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
Writing log to /home/koushik/O2PTA/tests/zipper_direct_flow/output/tai-e.log
Writing analysis plan to /home/koushik/O2PTA/tests/zipper_direct_flow/output/tai-e-plan.yml
WorldBuilder starts ...
6699 classes with 64241 methods in the world
WorldBuilder finishes, elapsed time: 3.14s
pta starts ...
[Pointer analysis] elapsed time: 15.59s
-------------- Pointer analysis statistics: --------------
#var pointers:                5,7955 (insens) / 5,7955 (sens)
#objects:                     6380 (insens) / 6380 (sens)
#var points-to:               386,4368 (insens) / 386,4368 (sens)
#static field points-to:      8396 (sens)
#instance field points-to:    83,4823 (sens)
#array points-to:             16,3107 (sens)
#reachable methods:           8307 (insens) / 8307 (sens)
#call graph edges:            4,5913 (insens) / 4,5913 (sens)
----------------------------------------
Zipper starts ...
Building OAG starts ...
Building OAG finishes, elapsed time: 0.56s
Building PCE starts ...
Building PCE finishes, elapsed time: 0.38s
68881 nodes in OFG
215102 edges in OFG
Building and analyzing PFG starts ...
Building and analyzing PFG finishes, elapsed time: 1.10s
#types: 1092
#avg. nodes in PFG: 439
#avg. edges in PFG: 1248
#precision-critical methods: 2591
Zipper finishes, elapsed time: 2.45s
[Pointer analysis] elapsed time: 3.04s
-------------- Pointer analysis statistics: --------------
#var pointers:                5,7955 (insens) / 5,7955 (sens)
#objects:                     6380 (insens) / 6380 (sens)
#var points-to:               386,4368 (insens) / 386,4368 (sens)
#static field points-to:      8396 (sens)
#instance field points-to:    83,4823 (sens)
#array points-to:             16,3107 (sens)
#reachable methods:           8307 (insens) / 8307 (sens)
#call graph edges:            4,5913 (insens) / 4,5913 (sens)
----------------------------------------
pta finishes, elapsed time: 23.10s
Tai-e finishes, elapsed time: 26.52s

Could you help with this issue so that we can use the flags of zipper, app-only and dump at the same time?

@zhangt2333
Copy link
Member

-a pta=advanced:zipper -a "pta=only-app:true;dump:true;"

Try merging the options like -a pta=advanced:zipper;only-app:true;dump:true;

@koushik0329
Copy link
Author

Even I tried that and only-app , dump are not working

when I tried merging the options, the output is

Tai-e starts ...
Output directory: /home/koushik/O2PTA/tests/zipper_direct_flow/output
Writing options to /home/koushik/O2PTA/tests/zipper_direct_flow/output/options.yml
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
Writing log to /home/koushik/O2PTA/tests/zipper_direct_flow/output/tai-e.log
Writing analysis plan to /home/koushik/O2PTA/tests/zipper_direct_flow/output/tai-e-plan.yml
WorldBuilder starts ...
6699 classes with 64241 methods in the world
WorldBuilder finishes, elapsed time: 4.17s
pta starts ...
[Pointer analysis] elapsed time: 17.59s
-------------- Pointer analysis statistics: --------------
#var pointers:                5,7955 (insens) / 5,7955 (sens)
#objects:                     6380 (insens) / 6380 (sens)
#var points-to:               386,4368 (insens) / 386,4368 (sens)
#static field points-to:      8396 (sens)
#instance field points-to:    83,4823 (sens)
#array points-to:             16,3107 (sens)
#reachable methods:           8307 (insens) / 8307 (sens)
#call graph edges:            4,5913 (insens) / 4,5913 (sens)
----------------------------------------
Zipper starts ...
Building OAG starts ...
Building OAG finishes, elapsed time: 0.57s
Building PCE starts ...
Building PCE finishes, elapsed time: 0.46s
68881 nodes in OFG
215102 edges in OFG
Building and analyzing PFG starts ...
Building and analyzing PFG finishes, elapsed time: 1.19s
#types: 1092
#avg. nodes in PFG: 439
#avg. edges in PFG: 1248
#precision-critical methods: 2591
Zipper finishes, elapsed time: 2.66s
[Pointer analysis] elapsed time: 3.00s
-------------- Pointer analysis statistics: --------------
#var pointers:                5,7955 (insens) / 5,7955 (sens)
#objects:                     6380 (insens) / 6380 (sens)
#var points-to:               386,4368 (insens) / 386,4368 (sens)
#static field points-to:      8396 (sens)
#instance field points-to:    83,4823 (sens)
#array points-to:             16,3107 (sens)
#reachable methods:           8307 (insens) / 8307 (sens)
#call graph edges:            4,5913 (insens) / 4,5913 (sens)
----------------------------------------
pta finishes, elapsed time: 25.19s
Tai-e finishes, elapsed time: 29.75s
only-app:true: command not found
dump:true: command not found

@zhangt2333
Copy link
Member

I have no idea according to the provided information.

Please provide a reproducible example to demonstrate the issue, via File Upload or GitHub Repository. So that I can directly help you debug it.
❤️ If you can provide a minimal reproducible example like MinimalReproducibleExample-0069, it would be highly appreciated.
👍 Alternatively, you can package and upload the entire Tai-e project in the text box.

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

No branches or pull requests

3 participants