Skip to content

Commit

Permalink
Doc: rework README
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Weiss committed Jun 20, 2023
1 parent 495295e commit 3599d66
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 3599d66

Please sign in to comment.