Skip to content

Commit

Permalink
Merge pull request eveem-org#1 from eveem-org/explain
Browse files Browse the repository at this point in the history
--explain mode
  • Loading branch information
kolinko authored Oct 9, 2019
2 parents e78d89e + a1bbedb commit 8e6d544
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pip3 install -r requirements.txt
You *need* **python3.8** to run Panoramix. Yes, there was no way around it.

```
python3.8 panoramix.py address [func_name] [--verbose|--silent]
python3.8 panoramix.py address [func_name] [--verbose|--silent|--explain]
```

e.g.
Expand All @@ -23,11 +23,18 @@ or
python3.8 panoramix.py kitties
```


Output goes to two places:
- `console`
- ***`cache_pan/`*** directory - .pan, .json, .asm files

If you want to see how Panoramix works under the hood, try the `--explain` mode:

```
python3.8 panoramix.py kitties paused --explain
python3.8 panoramix.py kitties pause --explain
python3.8 panoramix.py kitties tokenMetadata --explain
```

### Optional parameters:

func_name -- name of the function to decompile (note: storage names won't be discovered in this mode)
Expand Down Expand Up @@ -82,4 +89,4 @@ But if you manage to figure out a way to do it without Tilde (and maintain reada

# How Panoramix works

See the source code comments, starting with panoramix.py. Also, those slides.
See the source code comments, starting with panoramix.py. Also, those slides[tbd].
12 changes: 11 additions & 1 deletion utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
import os
import re


COLOR_HEADER = '\033[95m'
COLOR_BLUE = '\033[94m'
COLOR_OKGREEN = '\033[92m'
COLOR_WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
ENDC = '\033[;1m'
COLOR_BOLD = '\033[1m'
COLOR_UNDERLINE = '\033[4m'
COLOR_GREEN = '\033[32m'
COLOR_GRAY = '\033[38;5;8m'
COLOR_ASM = '\033[38;5;33m'

'''
slowly refactoring into low-caps names,
Expand Down Expand Up @@ -59,6 +61,7 @@ def convert(text):


class C():
# asm = '\033[38;5;33m'
header = '\033[95m'
blue = '\033[94m'
okgreen = '\033[92m'
Expand All @@ -72,6 +75,13 @@ class C():
fail = '\033[91m'
end = endc

green_back = '\033[42;1m\033[38;5;0m'
blue_back = '\033[43;1m\033[38;5;0m'


def asm(s):
return '\033[38;5;33m' + s + C.endc

every = set([header, blue, okgreen, warning, red, bold, underline, green, gray, endc])

def color(exp, color, add_color=True):
Expand Down
14 changes: 14 additions & 0 deletions utils/prettify.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@

logger = logging.getLogger(__name__)

import sys

prev_trace = None
def explain(title, trace):
if '--explain' not in sys.argv:
return

if trace == prev_trace:
return

print('\n'+C.green_back+f" {title}: "+C.end+'\n')
pprint_trace(trace)
prev_trace = trace


def make_ast(trace):
def store_to_set(line):
Expand Down

0 comments on commit 8e6d544

Please sign in to comment.