diff --git a/README.md b/README.md index 4a42f67f..9e802c85 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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) @@ -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]. diff --git a/utils/helpers.py b/utils/helpers.py index bd3da5b6..49f05802 100644 --- a/utils/helpers.py +++ b/utils/helpers.py @@ -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, @@ -59,6 +61,7 @@ def convert(text): class C(): +# asm = '\033[38;5;33m' header = '\033[95m' blue = '\033[94m' okgreen = '\033[92m' @@ -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): diff --git a/utils/prettify.py b/utils/prettify.py index 274f250f..e36808a7 100644 --- a/utils/prettify.py +++ b/utils/prettify.py @@ -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):