https://github.com/j3rn/analyzer
https://github.com/j3rn/analyzer
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/j3rn/analyzer
- Owner: J3RN
- License: other
- Created: 2023-01-16T15:26:56.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-11T21:48:01.000Z (almost 3 years ago)
- Last Synced: 2025-02-07T09:13:11.495Z (over 1 year ago)
- Language: Haskell
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# analyzer
A tool that allows you to query a call-graph.
## Usage
This tool accepts the call-graph as a CSV (e.g. generated by [viz](https://github.com/j3rn/viz)) with just a `source` and `target` column.
### Commands
#### dot
```
$ analyzer dot INPUTFILE [-o|--out FILE] [--sink SINK] [--source SOURCE]
```
Creates a visualization of the call graph in GraphViz DOT format.
The `--sink` flag specifies a filter that limits paths shown in the graph to those that terminate in the specified function. For instance, if you wanted to generate a call graph of all paths that terminate in `MyApp.Repo.all/1` from an `out.csv` file, you would write:
```
$ analyzer dot out.csv --sink MyApp.all/1
```
Multiple `--sink`s can be specified and are permitted and are "OR"ed together. For instance if you wanted to generate a call graph of all paths that terminate in `MyApp.Repo.all/1` or `MyApp.Repo.get/2`, you would write:
```
$ analyzer dot out.csv --sink MyApp.all/1 --sink MyApp.Repo.get/2
```
The `--source` flag specifies a filter that limits paths shown in the graph to those that begin with the specified function. For instance if you wanted to generate a call graph of all paths beginning at `MyApp.Feature.do_thing/2`, you would write:
```
$ analyzer dot out.csv --source MyApp.Feature.do_thing/2
```
Multiple `--source`s can be specified; multiple of the same or "OR"ed together.
The `--source` and `--sink` flags can be combined to limit the output to paths from sources to sinks. For instance, if you wanted to generate a call graph of all paths from `MyApp.Feature.do_thing/2` to `MyApp.Repo.all/1`, you would write:
```
$ analyzer dot out.csv --source MyApp.Feature.do_thing/2 --sink MyApp.Repo.all/1
```
Order of the flags does not matter.
#### paths
```
$ analyzer paths INPUTFILE SOURCE SINK
```
Lists all of the code paths from `SOURCE` to `SINK`. Each list is specified by a series of lines, each line containing the name of a single function, starting at `SOURCE` and ending at `SINK`.
#### callers
```
$ analyzer callers INPUTFILE CALLEE.
```
Lists all of the functions that call `CALLEE`.
#### dependents
```
$ analyzer dependents INPUTFILE DEPENDENCY
```
Lists all of the functions that call `DEPENDENCY`, recursively.
#### callees
```
$ analyzer callees INPUTFILE CALLER
```
Lists all of the functions that `CALLER` calls.
#### dependencies
```
$ analyzer dependencies INPUTFILE DEPENDENT
```
Lists all of the functions `DEPENDENT` calls, recursively.
## Building
This project is written in Haskell and uses [Stack](https://docs.haskellstack.org/en/stable/). Once you have Stack installed and the project cloned to your machine, you should be able to build the project by running `stack build` in the project directory. To install the project to your `~/.local/bin`, run `stack install`.