Skip to content

Commit

Permalink
gdb stuff (#3)
Browse files Browse the repository at this point in the history
* save wip

* restructure

* move to .config

* update

* adding more commands

* make dashboard outputable to file

* move types into `.pyi` files

* more typechecking

* remove unused imports

* some more types

* print registers

* print surrounding assembly

* simplify

* make order configurable

* simplify

* don't sort every outputable
  • Loading branch information
JensDll authored Jul 27, 2023
1 parent 6d7667e commit 4f0bf9a
Show file tree
Hide file tree
Showing 51 changed files with 1,511 additions and 62 deletions.
5 changes: 1 addition & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@ space_redirects = true
keep_padding = true
function_next_line = false

[*.py]
[{*.py,*.pyi}]
indent_size = 4

[.gdbinit]
trim_trailing_whitespace = false
24 changes: 0 additions & 24 deletions .gdbinit

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v3.5.3

- name: Running ShellCheck
run: ./scripts/lint.sh
run: ./scripts/shellcheck.sh
160 changes: 160 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Python.gitignore
# https://github.com/github/gitignore/blob/main/Python.gitignore

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
# Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
# poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
# pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# Other stuff
.gdb_history
dev.gdb
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8.17
11 changes: 1 addition & 10 deletions .rsyncignore
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
.git/
.github/
scripts/
.gitignore
.gitmodules
.rsyncignore
bootstrap.sh
Microsoft.PowerShell_profile.ps1
setup.reg
texlive2023profile
__pycache__/
20 changes: 10 additions & 10 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ root="$(
pwd -P
)"
declare -r root
declare -r unix="$root/unix"

shopt -s expand_aliases

source "$root/.bash_aliases"
# shellcheck source=./unix/.bash_aliases
source "$unix/.bash_aliases"

__bootstrap() {
# https://manpages.debian.org/rsync/rsync
rsync --no-perms --archive --verbose --human-readable --exclude-from="$root/.rsyncignore" "$root/" "$HOME"
rsync --no-perms --archive --verbose --human-readable --safe-links --copy-links --exclude-from="$root/.rsyncignore" "$unix/" "$HOME"

if type -f nvim > /dev/null 2>&1; then
__bootstrap_nvim
Expand All @@ -27,32 +29,30 @@ __bootstrap_nvim() {

local -r nvim_config_home="${MAPFILE[0]}"
local -r default_nvim_config_home="$HOME/.config/nvim"
local -r local_nvim_config_home="$root/.config/nvim"
local -r local_nvim_config_home="$unix/.config/nvim"

local -r nvim_data_home="${MAPFILE[1]}"
local -r default_nvim_data_home="$HOME/.local/share/nvim"
local -r local_nvim_data_home="$root/.local/share/nvim"
local -r local_nvim_data_home="$unix/.local/share/nvim"

if [[ -d $local_nvim_config_home && $default_nvim_config_home != "$nvim_config_home" ]]; then
cat << EOF
[Neovim] Detected a non-default ($default_nvim_config_home) config directory, also copying files to: $nvim_config_home
[Neovim] See https://neovim.io/doc/user/starting.html#standard-path
[Neovim] See: https://neovim.io/doc/user/starting.html#standard-path
EOF

rsync --no-perms --archive --verbose --human-readable "$default_nvim_config_home/" "$nvim_config_home"
rsync --no-perms --archive --safe-links --copy-links --human-readable "$default_nvim_config_home/" "$nvim_config_home"
fi

if [[ -d $local_nvim_data_home && $default_nvim_data_home != "$nvim_data_home" ]]; then
cat << EOF
[Neovim] Detected a non-default ($default_nvim_data_home) data directory, also copying files to: $nvim_data_home
[Neovim] See https://neovim.io/doc/user/starting.html#standard-path
[Neovim] See: https://neovim.io/doc/user/starting.html#standard-path
EOF

rsync --no-perms --archive --verbose --human-readable "$default_nvim_data_home/" "$nvim_data_home"
rsync --no-perms --archive --safe-links --copy-links --human-readable "$default_nvim_data_home/" "$nvim_data_home"
fi
}

Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.pyright]
# https://microsoft.github.io/pyright/#/configuration?id=main-configuration-options
include = ['unix', 'windows', 'misc', 'scripts']
exclude = ['**/__pycache__']
ignore = ['gdb']
pythonVersion = '3.8'

[tool.black]
# https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#t-target-version
target-version = ['py38']

[tool.isort]
# https://pycqa.github.io/isort/docs/configuration/options.html#python-version
py_version = 38
# https://pycqa.github.io/isort/docs/configuration/options.html#profile
profile = 'black'
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
black==23.7.0
pyright==1.1.318
isort==5.12.0
mypy=1.4.1
5 changes: 3 additions & 2 deletions scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ root="$(
pwd -P
)"
declare -r root
declare -r unix="$root/unix"

shfmt -w "$root" "$root/.bash_aliases" "$root/.bash_logout" "$root/.bashrc" "$root/.profile"
shfmt -w "$root" "$unix/.bash_aliases" "$unix/.bash_logout" "$unix/.bashrc" "$unix/.profile"

stylua "$root/.config/nvim"
stylua "$unix/.config/nvim"
10 changes: 0 additions & 10 deletions scripts/lint.sh

This file was deleted.

11 changes: 11 additions & 0 deletions scripts/shellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

root="$(
cd "$(dirname "${BASH_SOURCE[0]}")/.." > /dev/null 2>&1 || exit
pwd -P
)"
declare -r root
declare -r unix="$root/unix"

shellcheck --external-sources "$root"/**/*.sh "$unix"/.local/**/*.sh \
"$unix/.bash_aliases" "$unix/.bash_logout" "$unix/.bashrc" "$unix/.profile"
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions unix/.config/gdbdash/gdbdash/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import gdb # pyright: ignore [reportMissingModuleSource]

from .dashboard import Dashboard


def custom_prompt(current_prompt): # type: (str) -> str
# https://sourceware.org/gdb/current/onlinedocs/gdb.html/gdb_002eprompt.html#gdb_002eprompt
prompt = gdb.prompt.substitute_prompt(r">>> ")
return prompt


def start():
gdb.prompt_hook = custom_prompt
Dashboard()
5 changes: 5 additions & 0 deletions unix/.config/gdbdash/gdbdash/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .command import Command
from .configure import BoolOption, Configurable, IntOption, StrOption
from .enable import Togglable
from .order import Orderable
from .output import Outputable
Loading

0 comments on commit 4f0bf9a

Please sign in to comment.