subrepo:
  subdir:   "tools/asm_differ"
  merged:   "4b38c88"
upstream:
  origin:   "https://github.com/simonlindholm/asm-differ"
  branch:   "main"
  commit:   "4b38c88"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"
This commit is contained in:
Mr-Wiseguy
2022-02-02 23:03:08 -05:00
parent 32a1a8061d
commit 428c761091
10 changed files with 3118 additions and 0 deletions

2
tools/asm_differ/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.mypy_cache/
__pycache__/

12
tools/asm_differ/.gitrepo Normal file
View File

@@ -0,0 +1,12 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
;
[subrepo]
remote = https://github.com/simonlindholm/asm-differ
branch = main
commit = 4b38c884c1efdc3bfa8b14f13015a69368a8d3a2
parent = 32a1a8061de197c4f10d4904cd72a22dd7cf905c
method = merge
cmdver = 0.4.3

View File

@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
language_version: python3.6

24
tools/asm_differ/LICENSE Normal file
View File

@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org>

View File

@@ -0,0 +1,56 @@
# asm-differ
Nice differ for assembly code. Currently supports MIPS, PPC, AArch64, and ARM32; should be easy to hack to support other instruction sets.
![](screenshot.png)
## Dependencies
- Python >= 3.6
- `python3 -m pip install --user colorama watchdog python-Levenshtein` (also `dataclasses` if on 3.6)
## Usage
Create a file `diff_settings.sh` in some directory (see the one in this repo for an example). Then from that directory, run
```bash
/path/to/diff.sh [flags] (function|rom addr)
```
Recommended flags are `-mwo` (automatically run `make` on source file changes, and include symbols in diff). See `--help` for more details.
### Tab completion
[argcomplete](https://kislyuk.github.io/argcomplete/) can be optionally installed (with `python3 -m pip install argcomplete`) to enable tab completion in a bash shell, completing options and symbol names using the linker map. It also requires a bit more setup:
If invoking the script **exactly** as `./diff.py`, the following should be added to the `.bashrc` according to argcomplete's instructions:
```bash
eval "$(register-python-argcomplete ./diff.py)"
```
If that doesn't work, run `register-python-argcomplete ./diff.py` in your terminal and copy the output to `.bashrc`.
If setup correctly (don't forget to restart the shell), `complete | grep ./diff.py` should output:
```bash
complete -o bashdefault -o default -o nospace -F _python_argcomplete ./diff.py
```
Note for developers or for general troubleshooting: run `export _ARC_DEBUG=` to enable debug output during tab-completion, it may show otherwise silenced errors. Use `unset _ARC_DEBUG` or restart the terminal to disable.
### Contributing
Contributions are very welcome! Some notes on workflow:
`black` is used for code formatting. You can either run `black diff.py` manually, or set up a pre-commit hook:
```bash
pip install pre-commit black
pre-commit install
```
Type annotations are used for all Python code. `mypy` should pass without any errors.
PRs that skip the above are still welcome, however.
The targeted Python version is 3.6. There are currently no tests.

View File

@@ -0,0 +1,67 @@
table.diff {
border: none;
font-family: Monospace;
white-space: pre;
}
tr.data-ref {
background-color: gray;
}
.immediate {
color: lightblue;
}
.stack {
color: yellow;
}
.register {
color: yellow;
}
.delay-slot {
font-weight: bold;
color: gray;
}
.diff-change {
color: lightblue;
}
.diff-add {
color: green;
}
.diff-remove {
color: red;
}
.source-filename {
font-weight: bold;
}
.source-function {
font-weight: bold;
text-decoration: underline;
}
.source-other {
font-style: italic;
}
.rotation-0 {
color: magenta;
}
.rotation-1 {
color: cyan;
}
.rotation-2 {
color: green;
}
.rotation-3 {
color: red;
}
.rotation-4 {
color: yellow;
}
.rotation-5 {
color: pink;
}
.rotation-6 {
color: blue;
}
.rotation-7 {
color: lime;
}
.rotation-8 {
color: gray;
}

2923
tools/asm_differ/diff.py Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
def apply(config, args):
config["baseimg"] = "target.bin"
config["myimg"] = "source.bin"
config["mapfile"] = "build.map"
config["source_directories"] = ["."]
# config["show_line_numbers_default"] = True
# config["arch"] = "mips"
# config["map_format"] = "gnu" # gnu or mw
# config["mw_build_dir"] = "build/" # only needed for mw map format
# config["makeflags"] = []
# config["objdump_executable"] = ""

17
tools/asm_differ/mypy.ini Normal file
View File

@@ -0,0 +1,17 @@
[mypy]
check_untyped_defs = True
disallow_any_generics = True
disallow_incomplete_defs = True
disallow_untyped_calls = True
disallow_untyped_decorators = True
disallow_untyped_defs = True
no_implicit_optional = True
warn_redundant_casts = True
warn_return_any = True
warn_unused_ignores = True
ignore_missing_imports = True
python_version = 3.6
files = diff.py
[mypy-diff_settings]
ignore_errors = True

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB