https://github.com/euske/fgyama
Static source code analyzer that extracts an interprocedural dataflow graph from Java source code.
https://github.com/euske/fgyama
dataflow-analysis program-analysis software-engineering source-code-analysis
Last synced: about 2 hours ago
JSON representation
Static source code analyzer that extracts an interprocedural dataflow graph from Java source code.
- Host: GitHub
- URL: https://github.com/euske/fgyama
- Owner: euske
- Created: 2017-04-30T02:32:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-30T02:59:56.000Z (over 2 years ago)
- Last Synced: 2023-04-30T04:43:09.029Z (over 2 years ago)
- Topics: dataflow-analysis, program-analysis, software-engineering, source-code-analysis
- Language: Java
- Homepage:
- Size: 2.88 MB
- Stars: 5
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FGyama
FGyama, or Flow Graph yama is a static source code analyzer
that extracts an interprocedural dataflow graph from
Java source code. It's designed to be scalable so that
it can be applied to a large code base.
## What It Does
### Input
public class Hello {
public static void main(String[] args) {
String name = args[0];
System.out.println("Hello, "+name);
}
}
### Output (SVG)

### Output (XML)
## Node types (kinds):
### Basic Operations
| Kind | Data | Input(s) |
| ------------ | ------------------- | -------------------------------|
| value | Actual value | |
| valueset | Value count | value0, value1, ... |
| op_assign | Assignment operator | L, R |
| op_prefix | Prefix operator | (default) |
| op_infix | Infix operator | L, R |
| op_postfix | Postfix operator | (default) |
| op_typecast | Casting type | (default) |
| op_typecheck | Checking type | (default) |
| op_iter | | (default) |
| ref_var | | (default) |
| ref_array | | (default), array, index |
| ref_field | | (default), obj |
| assign_var | | (default) |
| assign_array | | (default), array, index |
| assign_field | | (default), obj |
### Function Call
| Kind | Data | Input(s) |
| ------------ | ------------------- | -------------------------------|
| call | Method IDs | @type, #arg0, ..., #bypass, .field, %type |
| new | Method ID | @type, #arg0, ..., #bypass, .field, %type |
| input | | |
| output | | (default) |
| return | | (default) |
| receive | | (default), Fields |
| throw | | !type |
| catch | | exc0, ... |
| catchjoin | | !type |
### Control Flow
| Kind | Data | Input(s) |
| ------------ | ------------------- | -------------------------------|
| join | | cond, true, false |
| begin | Loop ID | init, cont |
| end | Loop ID | (default), cond, _repeat |
| repeat | Loop ID | (default), _end |
| case | Label count | (default), match0, ... |
## How to Build
### Prerequisites
* Java/Maven
* Eclipse JDT (automatically downloaded)
* Graphviz http://graphviz.org/
### Compiling
$ mvn clean package
### Testing
$ mvn exec:java -Dexec.args="./tests/Hello.java" > Hello.graph
or
$ ./tools/java2df.sh ./tests/Hello.java > Hello.graph
then
$ python tools/graph2gv.py Hello.graph | dot -Tsvg > Hello.svg
## How to Use
XmlExporter exporter = new XmlExporter(System.out);
Java2DF converter = new Java2DF();
converter.loadDefaults(); // Load the standard classes.
converter.loadJarFile("path/to/my.jar"); // Add a jar.
converter.addSourceFile("path/to/Hello.java"); // Add a source code.
// Perform analysis for every user-defined class.
for (DFSourceKlass klass : converter.getSourceKlasses()) {
converter.analyzeKlass(exporter, klass);
}
exporter.close();
### Options
* `-v`: increases verbosity.
* `-i filelist`: takes a filename list.
* `-o output`: specifies the output file.
* `-C classpath`: add a jar file / directory to the classpath.
* `-S`: strict mode. (stops at a first error)
* `-F`: pretty printing XML.
## Development
### Coding style
(c-add-style "me"
'("Java"
(c-offsets-alist . (
(arglist-cont . c-lineup-argcont)
(arglist-intro . +)
))
))
### TODOs
* Handle consecutive SwitchCases.
* Correct local scope handling.
* Java language spec.: https://docs.oracle.com/javase/specs/
* Moar unittests.