diff --git a/README.md b/README.md index 360b555..eab295b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,100 @@ +## Object Code Graph (ocgraph) + +## How to Run + +Custom python script: + +```python +from ocgraph.interface.analyzer import Analyzer +from ocgraph.interface.drawer import Drawer +from ocgraph.interface.coverage_reader import CoverageReader + +from ocgraph.coverage_tracer import CoverageTracer +from ocgraph.configuration.configuration import CovTraceConfiguration + +# Create configuration +config = OcGraphConfiguration(disassembler="objdump", arch="sparc") + +# Read input text +lines = read_lines("a.out") + +# Analyze input text +analyser = Analyzer(config=config) +analyser.parse_lines(lines=lines) + +# Update analyzed input with coverage data +cov_reader = CoverageReader(instructions=analyser.instructions config=config) +cov_reader.update_by_csv(args.coverage) + +drawer = Drawer(analyser.configuration) +drawer.draw_cfg(name=analyser.function_name, basic_blocks=analyser.basic_blocks, output="a.pdf") +``` + +As python module: + +```cmd +python3 -m ocgraph -f a.out -d objdump -a sparc -c cov.csv -o a.pdf +``` + +As command line script: + +```cmd +./asm2cfg -f a.out -d objdump -a sparc -c cov.csv -o a.pdf +``` + + +## Design + + +```mermaid +--- +title: OcGraph design +--- +classDiagram + + class Configuration { + __init__(arch, disassembler, logging): + +dict disassembler_option + +dict architecture_option + +dict preset_logging + } + class Disassembler { + Name + parse_line() + ...() + } + class Architecture { + is_branch() + ...() + } + class Logger { Name } + + Configuration --* Disassembler + Configuration --* Architecture + Configuration --* Logger + + class Analyzer { + __init__(config) + parse_file(file_path): basic_blocks + } + class CoverageReader { + __init__(basic_blocks, config) + update_by_csv(file_path) + } + class Drawer { + __init__(config) + draw_cfg(basic_blocks, output) + } + class __main__ { + main() + } + + __main__ --> Configuration + __main__ --> Analyzer + __main__ --> CoverageReader + __main__ --> Drawer + +``` # asm2cfg ![CI status](https://github.com/Kazhuu/asm2cfg/actions/workflows/ci.yml/badge.svg)