├── .circleci └── config.yml ├── .coveragerc ├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug-report.md │ ├── config.yml │ └── feature-request.md └── workflows │ ├── macos.yml │ ├── ubuntu-prompt-toolkit.yml │ ├── ubuntu.yml │ └── windows.yml ├── .gitignore ├── .isort.cfg ├── .pre-commit-config.yaml ├── .readthedocs.yaml ├── .travis.yml ├── COPYING ├── ChangeLog-spell-corrected.diff ├── MANIFEST.in ├── Makefile ├── NEWS.md ├── README.rst ├── __init__.py ├── __pkginfo__.py ├── admin-tools ├── check-3.0-3.2-versions.sh ├── check-3.11-versions.sh ├── check-3.3-3.5-versions.sh ├── check-3.6-3.10-versions.sh ├── check-newest-versions.sh ├── checkout_common.sh ├── make-dist-3.0-3.2.sh ├── make-dist-3.3-3.5.sh ├── make-dist-3.6-3.10.sh ├── make-dist-newest.sh ├── make-docs.sh ├── merge-for-3.0.sh ├── merge-for-3.11.sh ├── merge-for-3.3.sh ├── merge-for-3.6.sh ├── pyenv-3.0-3.2-versions ├── pyenv-3.11-versions ├── pyenv-3.3-3.5-versions ├── pyenv-3.6-3.10-versions ├── pyenv-newest-versions ├── setup-master.sh ├── setup-python-3.0.sh ├── setup-python-3.11.sh ├── setup-python-3.3.sh └── setup-python-3.6.sh ├── appveyor.yml ├── appveyor ├── install.ps1 └── run_with_env.cmd ├── bin └── trepan3k ├── celery ├── README.md └── ctrepan.py ├── docs ├── .gitignore ├── Makefile ├── commands.rst ├── commands │ ├── Makefile │ ├── breakpoints.rst │ ├── breakpoints │ │ ├── Makefile │ │ ├── break.rst │ │ ├── clear.rst │ │ ├── condition.rst │ │ ├── delete.rst │ │ ├── disable.rst │ │ ├── enable.rst │ │ └── tbreak.rst │ ├── data.rst │ ├── data │ │ ├── Makefile │ │ ├── deparse.rst │ │ ├── disassemble.rst │ │ ├── display.rst │ │ ├── eval.rst │ │ ├── examine.rst │ │ ├── pp.rst │ │ ├── pr.rst │ │ ├── undisplay.rst │ │ └── whatis.rst │ ├── files.rst │ ├── files │ │ ├── Makefile │ │ ├── edit.rst │ │ └── list.rst │ ├── info.rst │ ├── info │ │ ├── Makefile │ │ ├── args.rst │ │ ├── break.rst │ │ ├── builtins.rst │ │ ├── code.rst │ │ ├── display.rst │ │ ├── files.rst │ │ ├── frame.rst │ │ ├── globals.rst │ │ ├── line.rst │ │ ├── lines.rst │ │ ├── locals.rst │ │ ├── macro.rst │ │ ├── pc.rst │ │ ├── program.rst │ │ ├── return.rst │ │ ├── signals.rst │ │ ├── source.rst │ │ └── threads.rst │ ├── running.rst │ ├── running │ │ ├── Makefile │ │ ├── continue.rst │ │ ├── exit.rst │ │ ├── finish.rst │ │ ├── jump.rst │ │ ├── kill.rst │ │ ├── next.rst │ │ ├── quit.rst │ │ ├── restart.rst │ │ ├── run.rst │ │ ├── skip.rst │ │ ├── step.rst │ │ └── stepi.rst │ ├── set.rst │ ├── set │ │ ├── Makefile │ │ ├── asmfmt.rst │ │ ├── autoeval.rst │ │ ├── autolist.rst │ │ ├── autopc.rst │ │ ├── autopython.rst │ │ ├── basename.rst │ │ ├── cmdtrace.rst │ │ ├── confirm.rst │ │ ├── dbg_trepan.rst │ │ ├── different.rst │ │ ├── events.rst │ │ ├── flush.rst │ │ ├── highlight.rst │ │ ├── listsize.rst │ │ ├── maxstring.rst │ │ ├── patsub.rst │ │ ├── skip.rst │ │ ├── style.rst │ │ ├── substitute.rst │ │ ├── trace.rst │ │ └── width.rst │ ├── show.rst │ ├── show │ │ ├── Makefile │ │ ├── aliases.rst │ │ ├── args.rst │ │ ├── asmfmt.rst │ │ ├── autoeval.rst │ │ ├── autolist.rst │ │ ├── autopc.rst │ │ ├── autopython.rst │ │ ├── basename.rst │ │ ├── cmdtrace.rst │ │ ├── confirm.rst │ │ ├── dbg_trepan.rst │ │ ├── different.rst │ │ ├── events.rst │ │ ├── flush.rst │ │ ├── highlight.rst │ │ ├── listsize.rst │ │ ├── maxstring.rst │ │ ├── skip.rst │ │ ├── style.rst │ │ ├── trace.rst │ │ └── width.rst │ ├── stack.rst │ ├── stack │ │ ├── Makefile │ │ ├── backtrace.rst │ │ ├── down.rst │ │ ├── frame.rst │ │ └── up.rst │ ├── support.rst │ └── support │ │ ├── Makefile │ │ ├── alias.rst │ │ ├── bpython.rst │ │ ├── debug.rst │ │ ├── help.rst │ │ ├── ipython.rst │ │ ├── macro.rst │ │ ├── python.rst │ │ ├── source.rst │ │ └── unalias.rst ├── conf.py ├── entry-exit.rst ├── features.rst ├── index.rst ├── install.rst ├── make.bat ├── manpages │ └── trepan3kc.rst ├── options.rst ├── syntax.rst └── syntax │ ├── arange.rst │ ├── command.rst │ ├── examples.rst │ ├── filename.rst │ ├── location.rst │ ├── range.rst │ └── suffixes.rst ├── make-check-filter.py ├── pyproject.toml ├── requirements-dev.txt ├── requirements.txt ├── rst2html.py ├── setup.cfg ├── setup.py ├── test ├── Makefile ├── __init__.py ├── data │ ├── Makefile │ ├── highlight-310.right │ ├── highlight-38.right │ ├── highlight-pyp35.right │ ├── highlight-pypy.right │ ├── highlight.cmd │ ├── highlight.right │ ├── macro-pypy.right │ ├── macro-pypy35.right │ ├── macro.cmd │ ├── macro.right │ ├── noscript-pypy.right │ ├── noscript.cmd │ ├── noscript.right │ ├── step-310.right │ ├── step-311.right │ ├── step-38.right │ ├── step-pypy.right │ ├── step.cmd │ └── step.right ├── example │ ├── eval.py │ ├── fib-exec.py │ ├── fib.py │ ├── gcd-dbgcall-explicit-profile.py │ ├── gcd-dbgcall-noprofile.py │ ├── gcd-dbgcall.py │ ├── gcd.py │ ├── hanoi.py │ └── multi-line.py ├── functional │ ├── __init__.py │ ├── example │ │ ├── jump.py │ │ ├── skip.py │ │ └── step │ │ │ └── step_computed_value.py │ ├── fn_helper.py │ ├── stringarray.py │ ├── test_break.py │ ├── test_finish.py │ ├── test_jump.py │ ├── test_next.py │ ├── test_sig.py │ ├── test_skip.py │ └── test_step.py ├── integration │ ├── .gitignore │ ├── Makefile │ ├── helper.py │ ├── setup.cfg │ ├── setup.py │ ├── test-general.py │ ├── test_highlight.py │ ├── test_noscript.py │ └── test_step.py └── unit │ ├── Makefile │ ├── cmdhelper.py │ ├── inout │ ├── __init__.py │ └── test_inout_input.py │ ├── interfaces │ ├── __init__.py │ └── test_intf_user.py │ ├── lib │ ├── __init__.py │ ├── test_lib_brkpt.py │ ├── test_lib_bytecode.py │ ├── test_lib_complete.py │ ├── test_lib_core.py │ ├── test_lib_display.py │ ├── test_lib_eval.py │ ├── test_lib_file.py │ ├── test_lib_format.py │ ├── test_lib_kill.py │ ├── test_lib_pp.py │ ├── test_lib_printing.py │ ├── test_lib_sig.py │ ├── test_lib_stack.py │ └── test_lib_thread.py │ ├── processor │ ├── __init__.py │ ├── command │ │ ├── __init__.py │ │ ├── test_cmd_alias.py │ │ ├── test_cmd_break.py │ │ ├── test_cmd_disassemble.py │ │ ├── test_cmd_finish.py │ │ ├── test_cmd_help.py │ │ ├── test_cmd_info_files.py │ │ ├── test_cmd_list.py │ │ ├── test_cmd_p.py │ │ ├── test_cmd_quit.py │ │ ├── test_cmd_run.py │ │ └── test_cmd_step.py │ ├── test_proc_cmdbreak.py │ ├── test_proc_cmdfns.py │ ├── test_proc_cmdproc.py │ ├── test_proc_complete.py │ └── test_proc_subcmd.py │ ├── test_api.py │ ├── test_clifns.py │ ├── test_exception.py │ ├── test_inout_tcp.py │ ├── test_misc.py │ └── test_options.py ├── tox.ini └── trepan ├── __init__.py ├── __main__.py ├── api.py ├── bwcli.py ├── bwprocessor ├── __init__.py ├── command │ ├── __init__.py │ ├── base_cmd.py │ ├── mock.py │ ├── quit.py │ └── step.py ├── location.py ├── main.py └── msg.py ├── client.py ├── clifns.py ├── debugger.py ├── exception.py ├── inout ├── Makefile ├── __init__.py ├── base.py ├── fifoclient.py ├── fifoserver.py ├── input.py ├── output.py ├── ptk_bindkeys.py ├── scriptin.py ├── stringarray.py ├── tcpclient.py ├── tcpfns.py └── tcpserver.py ├── interface.py ├── interfaces ├── __init__.py ├── bullwinkle.py ├── client.py ├── comcodes.py ├── script.py ├── server.py └── user.py ├── lib ├── __init__.py ├── breakpoint.py ├── bytecode.py ├── chdir.py ├── complete.py ├── core.py ├── default.py ├── deparse.py ├── disassemble.py ├── display.py ├── eval.py ├── file.py ├── format.py ├── pp.py ├── printing.py ├── sighandler.py ├── stack.py └── thred.py ├── misc.py ├── options.py ├── post_mortem.py ├── processor ├── __init__.py ├── cmd_addrlist.py ├── cmdbreak.py ├── cmdfns.py ├── cmdlist.py ├── cmdproc.py ├── command │ ├── .gitignore │ ├── __init__.py │ ├── alias.py │ ├── backtrace.py │ ├── base_cmd.py │ ├── base_subcmd.py │ ├── base_submgr.py │ ├── bpython.py │ ├── break.py │ ├── cd.py │ ├── clear.py │ ├── condition.py │ ├── continue.py │ ├── debug.py │ ├── delete.py │ ├── deparse.py │ ├── deval.py │ ├── disable.py │ ├── disassemble.py │ ├── display.py │ ├── down.py │ ├── edit.py │ ├── enable.py │ ├── eval.py │ ├── examine.py │ ├── exit.py │ ├── finish.py │ ├── frame.py │ ├── handle.py │ ├── help.py │ ├── help │ │ ├── .gitignore │ │ ├── README.md │ │ ├── arange.rst │ │ ├── command.rst │ │ ├── examples.rst │ │ ├── filename.rst │ │ ├── location.rst │ │ ├── range.rst │ │ └── suffixes.rst │ ├── info.py │ ├── info_subcmd │ │ ├── __init__.py │ │ ├── args.py │ │ ├── break.py │ │ ├── builtins.py │ │ ├── code.py │ │ ├── display.py │ │ ├── files.py │ │ ├── frame.py │ │ ├── globals.py │ │ ├── line.py │ │ ├── lines.py │ │ ├── locals.py │ │ ├── macro.py │ │ ├── offsets.py │ │ ├── pc.py │ │ ├── program.py │ │ ├── return.py │ │ ├── signals.py │ │ ├── source.py │ │ └── threads.py │ ├── ipython.py │ ├── jump.py │ ├── kill.py │ ├── list.py │ ├── load.py │ ├── macro.py │ ├── mock.py │ ├── next.py │ ├── p.py │ ├── pp.py │ ├── python.py │ ├── quit.py │ ├── reload.py │ ├── restart.py │ ├── run.py │ ├── set.py │ ├── set_subcmd │ │ ├── __demo_helper__.py │ │ ├── __init__.py │ │ ├── asmfmt.py │ │ ├── autoeval.py │ │ ├── autolist.py │ │ ├── autopc.py │ │ ├── autopython.py │ │ ├── basename.py │ │ ├── cmdtrace.py │ │ ├── confirm.py │ │ ├── dbg_trepan.py │ │ ├── different.py │ │ ├── events.py │ │ ├── highlight.py │ │ ├── listsize.py │ │ ├── maxstring.py │ │ ├── patsub.py │ │ ├── skip.py │ │ ├── style.py │ │ ├── substitute.py │ │ ├── tempdir.py │ │ ├── trace.py │ │ └── width.py │ ├── show.py │ ├── show_subcmd │ │ ├── __demo_helper__.py │ │ ├── __init__.py │ │ ├── aliases.py │ │ ├── args.py │ │ ├── asmfmt.py │ │ ├── autoeval.py │ │ ├── autolist.py │ │ ├── autopc.py │ │ ├── autopython.py │ │ ├── basename.py │ │ ├── confirm.py │ │ ├── dbg_trepan.py │ │ ├── highlight.py │ │ ├── history.py │ │ ├── listsize.py │ │ ├── style.py │ │ ├── styles.py │ │ ├── substitute.py │ │ ├── tempdir.py │ │ └── width.py │ ├── skip.py │ ├── source.py │ ├── step.py │ ├── stepi.py │ ├── tbreak.py │ ├── unalias.py │ ├── undisplay.py │ ├── up.py │ └── whatis.py ├── complete_ptk.py ├── complete_rl.py ├── frame.py ├── location.py ├── parse │ ├── __init__.py │ ├── parser.py │ ├── scanner.py │ ├── semantics.py │ └── tok.py ├── print.py ├── subcmd.py └── trace.py ├── version.py └── vprocessor.py /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | source = trepan 3 | 4 | [report] 5 | exclude_lines = 6 | pragma: no cover 7 | pass 8 | def __repr__ 9 | if __name__ *== *.__main__.: 10 | raise AssertionError 11 | raise NotImplementedError 12 | omit = 13 | */site-packages/nose/* 14 | */site-packages/* 15 | ./test/* 16 | ./dev/* 17 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # This is an EditorConfig file 2 | # https://EditorConfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | end_of_line = lf 8 | insert_final_newline = true 9 | charset = utf-8 10 | indent_style = tab 11 | indent_size = 4 12 | insert_final_newline = true 13 | 14 | [*.yml] 15 | indent_style = space 16 | indent_size = 2 17 | end_of_line = lf 18 | insert_final_newline = true 19 | 20 | [*.py] 21 | indent_style = space 22 | indent_size = 4 23 | end_of_line = lf 24 | insert_final_newline = true 25 | 26 | # Tab indentation (no size specified) 27 | [Makefile] 28 | indent_style = tab 29 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [rocky] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: rocky 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: False 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Tell us about a new feature that you would like to see in trepan3k 4 | 5 | --- 6 | 7 | ## Description 8 | 9 | 11 | 12 | ## Background 13 | 14 | 16 | 17 | ## Priority 18 | 19 | 26 | 27 | ## Tests 28 | 33 | -------------------------------------------------------------------------------- /.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | name: trepan3k (macos) 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: macos-latest 12 | strategy: 13 | matrix: 14 | os: [macOS] 15 | python-version: ['3.11', '3.12'] 16 | steps: 17 | - uses: actions/checkout@v4 18 | - name: Set up Python ${{ matrix.python-version }} 19 | uses: actions/setup-python@v5 20 | with: 21 | python-version: ${{ matrix.python-version }} 22 | - name: Install dependencies 23 | run: | 24 | python -m pip install --upgrade pip 25 | # Until the next xdis release 26 | pip install --local -e git+https://github.com/rocky/python-xdis.git#egg=xdis 27 | # Until the next pytracer release 28 | pip install git+https://github.com/rocky/pytracer#egg=tracer 29 | # Until the next pyficache release 30 | pip install git+https://github.com/rocky/python-filecache#egg=pyficache 31 | pip install -e .[dev] 32 | - name: Test trepan3k 33 | run: | 34 | make check 35 | -------------------------------------------------------------------------------- /.github/workflows/ubuntu-prompt-toolkit.yml: -------------------------------------------------------------------------------- 1 | name: trepan3k (ubuntu full) 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | strategy: 13 | matrix: 14 | python-version: ['3.12'] 15 | steps: 16 | - uses: actions/checkout@v4 17 | - name: Set up Python ${{ matrix.python-version }} 18 | uses: actions/setup-python@v5 19 | with: 20 | python-version: ${{ matrix.python-version }} 21 | - name: Install dependencies 22 | run: | 23 | python -m pip install --upgrade pip 24 | # Until the next xdis release 25 | pip install --local -e git+https://github.com/rocky/python-xdis.git#egg=xdis 26 | # Until the next pytracer release 27 | # pip install git+https://github.com/rocky/pytracer#egg=tracer 28 | # Until the next pyficache release 29 | pip install git+https://github.com/rocky/python-filecache#egg=pyficache 30 | pip install -e .[dev,full] 31 | - name: Test trepan3k 32 | run: | 33 | make check 34 | -------------------------------------------------------------------------------- /.github/workflows/ubuntu.yml: -------------------------------------------------------------------------------- 1 | name: trepan3k (ubuntu) 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | strategy: 13 | matrix: 14 | python-version: ['3.11', '3.12'] 15 | steps: 16 | - uses: actions/checkout@v4 17 | - name: Set up Python ${{ matrix.python-version }} 18 | uses: actions/setup-python@v5 19 | with: 20 | python-version: ${{ matrix.python-version }} 21 | - name: Install dependencies 22 | run: | 23 | python -m pip install --upgrade pip 24 | # Until the next xdis release 25 | pip install --local -e git+https://github.com/rocky/python-xdis.git#egg=xdis 26 | # Until the next pytracer release 27 | # pip install git+https://github.com/rocky/pytracer#egg=tracer 28 | # Until the next pyficache release 29 | pip install git+https://github.com/rocky/python-filecache#egg=pyficache 30 | pip install -e .[dev] 31 | - name: Test trepan3k 32 | run: | 33 | make check 34 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: trepan3k (windows) 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: windows-latest 12 | strategy: 13 | matrix: 14 | os: [windows] 15 | python-version: ['3.11', '3.12'] 16 | steps: 17 | - uses: actions/checkout@v4 18 | - name: Set up Python ${{ matrix.python-version }} 19 | uses: actions/setup-python@v5 20 | with: 21 | python-version: ${{ matrix.python-version }} 22 | - name: Install dependencies 23 | run: | 24 | python -m pip install --upgrade pip 25 | # Until the next xdis release 26 | pip install --local -e git+https://github.com/rocky/python-xdis.git#egg=xdis 27 | # Until the next pytracer release 28 | pip install git+https://github.com/rocky/pytracer#egg=tracer 29 | # Until the next pyficache release 30 | pip install git+https://github.com/rocky/python-filecache#egg=pyficache 31 | pip install -e .[dev] 32 | - name: Test trepan3k 33 | run: | 34 | make check 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.egg 2 | *.egg-info 3 | *.py? 4 | *~ 5 | .idea 6 | .python-version 7 | /*.egg 8 | /.cache 9 | /.coverage 10 | /.eggs 11 | /.tox 12 | /ChangeLog 13 | /build 14 | /dist 15 | /how-to-make-a-release.txt 16 | /python3-trepan.html 17 | /tmp 18 | -------------------------------------------------------------------------------- /.isort.cfg: -------------------------------------------------------------------------------- 1 | [settings] 2 | multi_line_output = 3 3 | include_trailing_comma = True 4 | force_grid_wrap = 0 5 | use_parentheses = True 6 | line_length = 88 7 | known_crunch = cr, zz9d, zz9lib, pycrunch, silhouette 8 | sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,CRUNCH,LOCALFOLDER 9 | default_section = THIRDPARTY 10 | combine_as_imports = 1 11 | profile = black 12 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | default_language_version: 2 | python: python 3 | repos: 4 | - repo: https://github.com/pre-commit/pre-commit-hooks 5 | rev: v4.5.0 6 | hooks: 7 | - id: check-merge-conflict 8 | - id: debug-statements 9 | stages: [commit] 10 | - id: end-of-file-fixer 11 | stages: [commit] 12 | - repo: https://github.com/pycqa/isort 13 | rev: 5.13.2 14 | hooks: 15 | - id: isort 16 | stages: [commit] 17 | - repo: https://github.com/psf/black 18 | rev: 23.12.1 19 | hooks: 20 | - id: black 21 | language_version: python3 22 | stages: [commit] 23 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yaml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Set the version of Python and other tools you might need 9 | build: 10 | os: ubuntu-22.04 11 | tools: 12 | python: "3.11" 13 | 14 | # Build documentation in the docs/ directory with Sphinx 15 | sphinx: 16 | configuration: docs/conf.py 17 | 18 | # We recommend specifying your dependencies to enable reproducible builds: 19 | # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html 20 | # python: 21 | # install: 22 | # - requirements: docs/requirements.txt 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | env: 4 | - TRAVIS=true 5 | 6 | sudo: false 7 | 8 | python: 9 | - '3.4' 10 | - '3.5' 11 | - '3.6' 12 | - '3.7' 13 | # - 'pypy3' 14 | 15 | install: 16 | # - pip install -e git://github.com/rocky/python-xdis.git#egg=xdis 17 | # - pip install -e git://github.com/rocky/python-filecache.git#egg=pyficache 18 | - pip install -e . 19 | - pip install -r requirements-dev.txt 20 | 21 | script: 22 | - make test 23 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include COPYING 2 | include ChangeLog 3 | include Makefile 4 | include NEWS.md 5 | include README.rst 6 | include __pkginfo__.py 7 | include requirements-dev.txt 8 | include test/Makefile 9 | include test/Makefile 10 | recursive-include test/data *.cmd *.right 11 | recursive-include test/example *.py 12 | recursive-include test/functional *.py 13 | recursive-include test/integration *.py 14 | recursive-include test/unit *.py 15 | recursive-include trepan *.py 16 | recursive-include trepan/processor/command/help * 17 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | trepan 4 | ~~~~~~ 5 | 6 | Trepan Debugger 7 | 8 | :copyright: Copyright 2013 9 | :license: GPL3, see LICENSE for details. 10 | """ 11 | 12 | """ Copyright (C) 2013 Rocky Bernstein """ 13 | 14 | __docformat__ = 'restructuredtext' 15 | __all__ = ['trepan'] 16 | -------------------------------------------------------------------------------- /admin-tools/check-3.0-3.2-versions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | function finish { 3 | cd $trepan3k_owd 4 | } 5 | 6 | # FIXME put some of the below in a common routine 7 | trepan3k_owd=$(pwd) 8 | # trap finish EXIT 9 | 10 | cd $(dirname ${BASH_SOURCE[0]}) 11 | if ! source ./pyenv-3.0-3.2-versions ; then 12 | exit $? 13 | fi 14 | 15 | if ! source ./setup-python-3.0.sh ; then 16 | exit $? 17 | fi 18 | 19 | cd .. 20 | for version in $PYVERSIONS; do 21 | if ! pyenv local $version ; then 22 | exit $? 23 | fi 24 | python --version 25 | make clean && pip install -e . 26 | if ! make check; then 27 | exit $? 28 | fi 29 | echo === $version === 30 | done 31 | finish 32 | -------------------------------------------------------------------------------- /admin-tools/check-3.11-versions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | function finish { 3 | cd $trepan3k_owd 4 | } 5 | 6 | # FIXME put some of the below in a common routine 7 | trepan3k_owd=$(pwd) 8 | # trap finish EXIT 9 | 10 | cd $(dirname ${BASH_SOURCE[0]}) 11 | if ! source ./pyenv-3.11-versions ; then 12 | exit $? 13 | fi 14 | 15 | . ./setup-python-3.11.sh 16 | 17 | cd .. 18 | for version in $PYVERSIONS; do 19 | if ! pyenv local $version ; then 20 | exit $? 21 | fi 22 | python --version 23 | make clean && pip install -e . 24 | if ! make check; then 25 | exit $? 26 | fi 27 | echo === $version === 28 | done 29 | -------------------------------------------------------------------------------- /admin-tools/check-3.3-3.5-versions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | function finish { 3 | cd $trepan3k_owd 4 | } 5 | 6 | # FIXME put some of the below in a common routine 7 | trepan3k_owd=$(pwd) 8 | # trap finish EXIT 9 | 10 | cd $(dirname ${BASH_SOURCE[0]}) 11 | if ! source ./pyenv-3.3-3.5-versions ; then 12 | exit $? 13 | fi 14 | 15 | if ! source ./setup-python-3.3.sh ; then 16 | exit $? 17 | fi 18 | 19 | cd .. 20 | for version in $PYVERSIONS; do 21 | if ! pyenv local $version ; then 22 | exit $? 23 | fi 24 | python --version 25 | make clean && pip install -e . 26 | if ! make check; then 27 | exit $? 28 | fi 29 | echo === $version === 30 | done 31 | finish 32 | -------------------------------------------------------------------------------- /admin-tools/check-3.6-3.10-versions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | function finish { 3 | cd $trepan3k_owd 4 | } 5 | 6 | # FIXME put some of the below in a common routine 7 | trepan3k_owd=$(pwd) 8 | # trap finish EXIT 9 | 10 | cd $(dirname ${BASH_SOURCE[0]}) 11 | if ! source ./pyenv-3.6-3.10-versions ; then 12 | exit $? 13 | fi 14 | 15 | . ./setup-python-3.6.sh 16 | 17 | cd .. 18 | for version in $PYVERSIONS; do 19 | if ! pyenv local $version ; then 20 | exit $? 21 | fi 22 | python --version 23 | make clean && pip install -e . 24 | if ! make check; then 25 | exit $? 26 | fi 27 | echo === $version === 28 | done 29 | -------------------------------------------------------------------------------- /admin-tools/check-newest-versions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | function finish { 3 | cd $trepan3k_owd 4 | } 5 | 6 | # FIXME put some of the below in a common routine 7 | trepan3k_owd=$(pwd) 8 | # trap finish EXIT 9 | 10 | cd $(dirname ${BASH_SOURCE[0]}) 11 | if ! source ./pyenv-newest-versions ; then 12 | exit $? 13 | fi 14 | 15 | . ./setup-master.sh 16 | 17 | cd .. 18 | for version in $PYVERSIONS; do 19 | if ! pyenv local $version ; then 20 | exit $? 21 | fi 22 | python --version 23 | make clean && pip install -e . 24 | if ! make check; then 25 | exit $? 26 | fi 27 | echo === $version === 28 | done 29 | -------------------------------------------------------------------------------- /admin-tools/checkout_common.sh: -------------------------------------------------------------------------------- 1 | # Common checkout routine 2 | export PATH=$HOME/.pyenv/bin/pyenv:$PATH 3 | bs=${BASH_SOURCE[0]} 4 | mydir=$(dirname $bs) 5 | 6 | function setup_version { 7 | local repo=$1 8 | version=$2 9 | echo Running setup $version on $repo ... 10 | (cd ./$repo && . ./admin-tools/setup-${version}.sh) 11 | return $? 12 | } 13 | 14 | function checkout_finish { 15 | branch=$1 16 | cd $trepan3k_owd 17 | git checkout $branch && pyenv local $PYTHON_VERSION && git pull 18 | rc=$? 19 | return $rc 20 | } 21 | -------------------------------------------------------------------------------- /admin-tools/make-dist-3.0-3.2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PACKAGE=trepan3k 3 | 4 | # FIXME put some of the below in a common routine 5 | function finish { 6 | cd $make_trepan_dist_30_owd 7 | } 8 | 9 | make_trepan_dist_30_owd=$(pwd) 10 | 11 | trap finish EXIT 12 | 13 | cd $(dirname ${BASH_SOURCE[0]}) 14 | 15 | if ! source ./pyenv-3.0-3.2-versions ; then 16 | exit $? 17 | fi 18 | if ! source ./setup-python-3.0.sh ; then 19 | exit $? 20 | fi 21 | 22 | cd .. 23 | source $PACKAGE/version.py 24 | if [[ ! -n $__version__ ]]; then 25 | echo "You need to set __version__ first" 26 | fi 27 | echo $__version__ 28 | 29 | for pyversion in $PYVERSIONS; do 30 | echo --- $pyversion --- 31 | if [[ ${pyversion:0:4} == "pypy" ]] ; then 32 | echo "$pyversion - PyPy does not get special packaging" 33 | continue 34 | fi 35 | if ! pyenv local $pyversion ; then 36 | exit $? 37 | fi 38 | # pip bdist_egg create too-general wheels. So 39 | # we narrow that by moving the generated wheel. 40 | 41 | # Pick out first two number of version, e.g. 3.5.1 -> 35 42 | first_two=$(echo $pyversion | cut -d'.' -f 1-2 | sed -e 's/\.//') 43 | rm -fr build 44 | python setup.py bdist_egg bdist_wheel 45 | mv -v dist/${PACKAGE}-$__version__-{py3,$first_two}-none-any.whl 46 | done 47 | 48 | python ./setup.py sdist 49 | tarball=dist/${PACKAGE}-${__version__}.tar.gz 50 | if [[ -f $tarball ]]; then 51 | mv -v $tarball dist/${PACKAGE}_30-${__version__}.tar.gz 52 | fi 53 | finish 54 | -------------------------------------------------------------------------------- /admin-tools/make-dist-3.3-3.5.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PACKAGE=trepan3k 3 | 4 | # FIXME put some of the below in a common routine 5 | function finish { 6 | cd $make_dist_33_owd 7 | } 8 | 9 | make_trepan_dist_33_owd=$(pwd) 10 | trap finish EXIT 11 | 12 | cd $(dirname ${BASH_SOURCE[0]}) 13 | 14 | if ! source ./pyenv-3.3-3.5-versions ; then 15 | exit $? 16 | fi 17 | if ! source ./setup-python-3.3.sh ; then 18 | exit $? 19 | fi 20 | 21 | . ./setup-python-3.3.sh 22 | 23 | cd .. 24 | source trepan/version.py 25 | if [[ ! -n $__version__ ]]; then 26 | echo "You need to set __version__ first" 27 | exit 1 28 | fi 29 | echo $__version__ 30 | 31 | for pyversion in $PYVERSIONS; do 32 | echo --- $pyversion --- 33 | if [[ ${pyversion:0:4} == "pypy" ]] ; then 34 | echo "$pyversion - PyPy does not get special packaging" 35 | continue 36 | fi 37 | if ! pyenv local $pyversion ; then 38 | exit $? 39 | fi 40 | # pip bdist_egg create too-general wheels. So 41 | # we narrow that by moving the generated wheel. 42 | 43 | # Pick out first two number of version, e.g. 3.5.1 -> 35 44 | first_two=$(echo $pyversion | cut -d'.' -f 1-2 | sed -e 's/\.//') 45 | rm -fr build 46 | python setup.py bdist_egg bdist_wheel 47 | mv -v dist/${PACKAGE}-$__version__-{py2.py3,$first_two}-none-any.whl 48 | done 49 | 50 | python ./setup.py sdist 51 | tarball=dist/${PACKAGE}-${__version__}.tar.gz 52 | 53 | if [[ -f $tarball ]]; then 54 | mv -v $tarball dist/${PACKAGE}_33-${__version__}.tar.gz 55 | fi 56 | finish 57 | -------------------------------------------------------------------------------- /admin-tools/make-dist-3.6-3.10.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PACKAGE=trepan3k 3 | 4 | # FIXME put some of the below in a common routine 5 | function finish { 6 | cd $make_dist_36_owd 7 | } 8 | 9 | make_trepan_dist_36_owd=$(pwd) 10 | trap finish EXIT 11 | 12 | cd $(dirname ${BASH_SOURCE[0]}) 13 | 14 | if ! source ./pyenv-3.6-3.10-versions ; then 15 | exit $? 16 | fi 17 | if ! source ./setup-python-3.6.sh ; then 18 | exit $? 19 | fi 20 | 21 | . ./setup-python-3.6.sh 22 | 23 | cd .. 24 | source trepan/version.py 25 | if [[ ! -n $__version__ ]]; then 26 | echo "You need to set __version__ first" 27 | exit 1 28 | fi 29 | echo $__version__ 30 | 31 | for pyversion in $PYVERSIONS; do 32 | echo --- $pyversion --- 33 | if [[ ${pyversion:0:4} == "pypy" ]] ; then 34 | echo "$pyversion - PyPy does not get special packaging" 35 | continue 36 | fi 37 | if ! pyenv local $pyversion ; then 38 | exit $? 39 | fi 40 | # pip bdist_egg create too-general wheels. So 41 | # we narrow that by moving the generated wheel. 42 | 43 | # Pick out first two number of version, e.g. 3.5.1 -> 35 44 | first_two=$(echo $pyversion | cut -d'.' -f 1-2 | sed -e 's/\.//') 45 | rm -fr build 46 | python setup.py bdist_egg bdist_wheel 47 | mv -v dist/${PACKAGE}-$__version__-{py2.py3,$first_two}-none-any.whl 48 | done 49 | 50 | python ./setup.py sdist 51 | tarball=dist/${PACKAGE}-${__version__}.tar.gz 52 | 53 | if [[ -f $tarball ]]; then 54 | mv -v $tarball dist/${PACKAGE}_36-${__version__}.tar.gz 55 | fi 56 | finish 57 | -------------------------------------------------------------------------------- /admin-tools/make-dist-newest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PACKAGE=trepan 3 | 4 | # FIXME put some of the below in a common routine 5 | function finish { 6 | cd $owd 7 | } 8 | 9 | cd $(dirname ${BASH_SOURCE[0]}) 10 | owd=$(pwd) 11 | trap finish EXIT 12 | 13 | if ! source ./pyenv-newest-versions ; then 14 | exit $? 15 | fi 16 | if ! source ./setup-master.sh ; then 17 | exit $? 18 | fi 19 | 20 | cd .. 21 | source $PACKAGE/version.py 22 | echo $VERSION 23 | 24 | for pyversion in $PYVERSIONS; do 25 | if ! pyenv local $pyversion ; then 26 | exit $? 27 | fi 28 | # pip bdist_egg create too-general wheels. So 29 | # we narrow that by moving the generated wheel. 30 | 31 | # Pick out first two number of version, e.g. 3.5.1 -> 35 32 | first_two_dot=$(echo $pyversion | cut -d'.' -f 1-2 ) 33 | first_two=$(echo $pyversion | cut -d'.' -f 1-2 | sed -e 's/\.//') 34 | rm -fr build 35 | # We can't use a universal wheel because depdencies on the decompiler changes 36 | # for 3.7 and 3.8 37 | python setup.py bdist_egg bdist_wheel 38 | if [[ $first_two =~ py* ]]; then 39 | if [[ $first_two =~ pypy* ]]; then 40 | # For PyPy, remove the what is after the dash, e.g. pypy37-none-any.whl instead of pypy37-7-none-any.whl 41 | first_two=${first_two%-*} 42 | fi 43 | mv -v dist/${PACKAGE}-$__version__-{py3,$first_two}-none-any.whl 44 | else 45 | mv -v dist/${PACKAGE}-$__version__-{py3,py$first_two}-none-any.whl 46 | fi 47 | done 48 | 49 | python ./setup.py sdist 50 | # mv -v dist/${PACKAGE}-$VERSION.tar.gz dist/${PACKAGE}3k-$VERSION.tar.gz 51 | -------------------------------------------------------------------------------- /admin-tools/make-docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get location of file in a cwd-position-independent and invocation-independent way.. 4 | bs=${BASH_SOURCE[0]} 5 | MY_DIR=$(dirname $bs) 6 | cd $MY_DIR 7 | MY_DIR=$(pwd) 8 | 9 | # Set names of locations 10 | DOCS_DIR=$MY_DIR/../docs 11 | CONF=$DOCS_DIR/conf.py 12 | DOCS_BUILD=$MY_DIR/build_docs 13 | 14 | # Clean out filesystem from preview runs 15 | rm -fr $DOCS_BUILD || /bin/true 16 | 17 | # # Build HTML... 18 | # mkdir -p $DOCS_BUILD/html 19 | # cd $DOCS_BUILD/html 20 | # sphinx-build -T -b html -C $DOCS_DIR -E -D language=en $DOCS_DIR . 21 | # mkdir -p $DOCS_BUILD/doctrees-readthedocs 22 | 23 | # # and JSON files 24 | # mkdir -p $DOCS_BUILD/json 25 | # cd $DOCS_BUILD/html 26 | # sphinx-build -T -b json -C $DOCS_DIR -E -D language=en $DOCS_DIR . 27 | 28 | # Build PDF via LaTeX 29 | mkdir -p $DOCS_BUILD/latex 30 | cd $DOCS_BUILD/latex 31 | sphinx-build -b latex -D language=en $DOCS_DIR . 32 | rc=$? 33 | if (( $? != 0 )); then 34 | print 2>&1 "Something went wrong with sphinx-build, exit code: $?" 35 | exit $rc 36 | fi 37 | if [[ ! -r trepan.tex ]]; then 38 | print 2>&1 "Failed to create trepan.tex" 39 | exit 1 40 | fi 41 | 42 | pdflatex -interaction=nonstopmode ./trepan.tex 43 | makeindex -s python.ist trepan.idx 44 | pdflatex -interaction=nonstopmode ./trepan.tex 45 | -------------------------------------------------------------------------------- /admin-tools/merge-for-3.0.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | trepan_merge_30_owd=$(pwd) 3 | PYTHON_VERSION=3.1 4 | pyenv local $PYTHON_VERSION 5 | cd $(dirname ${BASH_SOURCE[0]}) 6 | if . ./setup-python-3.0.sh; then 7 | git merge python-3.3-to-3.5 8 | fi 9 | cd $trepan_merge_30_owd 10 | -------------------------------------------------------------------------------- /admin-tools/merge-for-3.11.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | trepan_merge_311_owd=$(pwd) 3 | PYTHON_VERSION=3.11 4 | pyenv local $PYTHON_VERSION 5 | cd $(dirname ${BASH_SOURCE[0]}) 6 | if . ./setup-python-3.11.sh; then 7 | git merge master 8 | fi 9 | cd $trepan_merge_311_owd 10 | -------------------------------------------------------------------------------- /admin-tools/merge-for-3.3.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | trepan_merge_33_owd=$(pwd) 3 | PYTHON_VERSION=3.3 4 | pyenv local $PYTHON_VERSION 5 | cd $(dirname ${BASH_SOURCE[0]}) 6 | if . ./setup-python-3.3.sh; then 7 | git merge python-3.6-to-3.10 8 | fi 9 | cd $trepan_merge_33_owd 10 | -------------------------------------------------------------------------------- /admin-tools/merge-for-3.6.sh: -------------------------------------------------------------------------------- 1 | #/bin/bash 2 | trepan_merge_36_owd=$(pwd) 3 | PYTHON_VERSION=3.6 4 | pyenv local $PYTHON_VERSION 5 | cd $(dirname ${BASH_SOURCE[0]}) 6 | if . ./setup-python-3.6.sh; then 7 | git merge python-3.11 8 | fi 9 | cd $trepan_merge_36_owd 10 | -------------------------------------------------------------------------------- /admin-tools/pyenv-3.0-3.2-versions: -------------------------------------------------------------------------------- 1 | # -*- shell-script -*- 2 | # Sets PYVERSIONS to be pyenv versions that 3 | # we can use in the python-3.0-to-3.2 branch. 4 | 5 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then 6 | echo "This script should be *sourced* rather than run directly through bash" 7 | exit 1 8 | fi 9 | export PYVERSIONS='3.0 3.1 3.2' 10 | -------------------------------------------------------------------------------- /admin-tools/pyenv-3.11-versions: -------------------------------------------------------------------------------- 1 | # -*- shell-script -*- 2 | # Sets PYVERSIONS to be pyenv versions that 3 | # we can use in the master 4 | 5 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then 6 | echo "This script should be *sourced* rather than run directly through bash" 7 | exit 1 8 | fi 9 | 10 | export PYVERSIONS='3.11' 11 | -------------------------------------------------------------------------------- /admin-tools/pyenv-3.3-3.5-versions: -------------------------------------------------------------------------------- 1 | # -*- shell-script -*- 2 | # Sets PYVERSIONS to be pyenv versions that 3 | # we can use in the python-3.3-to-3.5 branch. 4 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then 5 | echo "This script should be *sourced* rather than run directly through bash" 6 | exit 1 7 | fi 8 | export PYVERSIONS='3.5 3.3 3.4 pypy3.5-7.0.0' 9 | -------------------------------------------------------------------------------- /admin-tools/pyenv-3.6-3.10-versions: -------------------------------------------------------------------------------- 1 | # -*- shell-script -*- 2 | # Sets PYVERSIONS to be pyenv versions that 3 | # we can use in the master 4 | 5 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then 6 | echo "This script should be *sourced* rather than run directly through bash" 7 | exit 1 8 | fi 9 | 10 | # export PYVERSIONS='3.6 pypy3.6 3.7 pypy3.7 pypy3.8 pypy3.9 pyston 3.8 3.9 3.10' 11 | export PYVERSIONS='3.6 3.7 3.8 3.9 3.10' 12 | -------------------------------------------------------------------------------- /admin-tools/pyenv-newest-versions: -------------------------------------------------------------------------------- 1 | # -*- shell-script -*- 2 | # Sets PYVERSIONS to be pyenv versions that 3 | # we can use in the master 4 | 5 | if [[ $0 == ${BASH_SOURCE[0]} ]] ; then 6 | echo "This script should be *sourced* rather than run directly through bash" 7 | exit 1 8 | fi 9 | 10 | export PYVERSIONS='3.12 3.13' 11 | -------------------------------------------------------------------------------- /admin-tools/setup-master.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check out master branch and dependent development master branches 3 | PYTHON_VERSION=3.12 4 | 5 | bs=${BASH_SOURCE[0]} 6 | if [[ $0 == $bs ]] ; then 7 | echo "This script should be *sourced* rather than run directly through bash" 8 | exit 1 9 | fi 10 | 11 | mydir=$(dirname $bs) 12 | trepan3k_owd=$(pwd) 13 | cd $mydir 14 | . ./checkout_common.sh 15 | (cd $mydir/../../../rocky && \ 16 | setup_version python-uncompyle6 master && \ 17 | setup_version python-xdis master && \ 18 | setup_version python-filecache master && \ 19 | setup_version shell-term-background master && \ 20 | setup_version pytracer master && \ 21 | setup_version pycolumnize master \ 22 | ) 23 | checkout_finish master 24 | -------------------------------------------------------------------------------- /admin-tools/setup-python-3.0.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check out 3.0-to-3.2 branch and dependent development branches 3 | 4 | bs=${BASH_SOURCE[0]} 5 | if [[ $0 == $bs ]] ; then 6 | echo "This script should be *sourced* rather than run directly through bash" 7 | exit 1 8 | fi 9 | 10 | PYTHON_VERSION=3.0 11 | 12 | export PATH=$HOME/.pyenv/bin/pyenv:$PATH 13 | trepan3k_owd=$(pwd) 14 | mydir=$(dirname $bs) 15 | cd $mydir 16 | . ./checkout_common.sh 17 | (cd $mydir/../../../rocky && \ 18 | setup_version python-uncompyle6 python-3.0 \ 19 | setup_version python-filecache python-3.0 && \ 20 | setup_version shell-term-background python-3.0 && \ 21 | setup_version pytracer python-3.0 \ 22 | setup_version pycolumnize python-3.0 && \ 23 | setup_version python-xdis python-3.0 \ 24 | ) 25 | 26 | checkout_finish python-3.0-to-3.2 27 | -------------------------------------------------------------------------------- /admin-tools/setup-python-3.11.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check out 3.11 branch and dependent development branches 3 | PYTHON_VERSION=3.11 4 | 5 | bs=${BASH_SOURCE[0]} 6 | if [[ $0 == $bs ]] ; then 7 | echo "This script should be *sourced* rather than run directly through bash" 8 | exit 1 9 | fi 10 | 11 | export PATH=$HOME/.pyenv/bin/pyenv:$PATH 12 | trepan3k_owd=$(pwd) 13 | mydir=$(dirname $bs) 14 | cd $mydir 15 | . ./checkout_common.sh 16 | (cd $mydir/../../rocky && \ 17 | setup_version python-uncompyle6 master && \ 18 | setup_version python-filecache master && \ 19 | setup_version shell-term-background master && \ 20 | setup_version pytracer master \ 21 | setup_version pycolumnize master && \ 22 | setup_version python-xdis master \ 23 | ) 24 | 25 | checkout_finish python-3.11 26 | -------------------------------------------------------------------------------- /admin-tools/setup-python-3.3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PYTHON_VERSION=3.3 3 | 4 | bs=${BASH_SOURCE[0]} 5 | if [[ $0 == $bs ]] ; then 6 | echo "This script should be *sourced* rather than run directly through bash" 7 | exit 1 8 | fi 9 | 10 | export PATH=$HOME/.pyenv/bin/pyenv:$PATH 11 | trepan3k_owd=$(pwd) 12 | 13 | mydir=$(dirname $bs) 14 | cd $mydir 15 | . ./checkout_common.sh 16 | (cd $mydir/../../../rocky && \ 17 | setup_version python-uncompyle6 python-3.3 && \ 18 | setup_version python-xdis python-3.3 && \ 19 | setup_version python-filecache python-3.3 && \ 20 | setup_version shell-term-background python-3.3 && \ 21 | setup_version pytracer python-3.3 && \ 22 | setup_version pycolumnize python-3.3 \ 23 | setup_version python-xdis python-3.3 \ 24 | ) 25 | 26 | cd $trepan3k_owd 27 | rm -v */.python-version 2>/dev/null || true 28 | 29 | checkout_finish python-3.3-to-3.5 30 | -------------------------------------------------------------------------------- /admin-tools/setup-python-3.6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Check out 3.6-to-3.10 branch and dependent development branches 3 | PYTHON_VERSION=3.6 4 | 5 | bs=${BASH_SOURCE[0]} 6 | if [[ $0 == $bs ]] ; then 7 | echo "This script should be *sourced* rather than run directly through bash" 8 | exit 1 9 | fi 10 | 11 | export PATH=$HOME/.pyenv/bin/pyenv:$PATH 12 | trepan3k_owd=$(pwd) 13 | mydir=$(dirname $bs) 14 | cd $mydir 15 | . ./checkout_common.sh 16 | (cd $mydir/../../../rocky && \ 17 | setup_version python-uncompyle6 python-3.6 && \ 18 | setup_version python-filecache python-3.6 && \ 19 | setup_version shell-term-background python-3.3 && \ 20 | setup_version pytracer python-3.6 \ 21 | setup_version pycolumnize python-3.6 && \ 22 | setup_version python-xdis python-3.6 \ 23 | ) 24 | 25 | checkout_finish python-3.6-to-3.10 26 | -------------------------------------------------------------------------------- /bin/trepan3k: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from trepan.__main__ import main 3 | main() 4 | -------------------------------------------------------------------------------- /celery/README.md: -------------------------------------------------------------------------------- 1 | Code here may be useful in debugging Celery remote queues. 2 | 3 | This code is barefly functional. Help would be appreciated in cleaning 4 | it up. 5 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /docs/commands.rst: -------------------------------------------------------------------------------- 1 | Command Reference 2 | ***************** 3 | 4 | Following *gdb*, we classify commands into categories. Note though 5 | that some commands, like `quit `_, and `restart `_, are in different categories 6 | and some categories are new, like `set `_, `show `_, and `info `_. 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | commands/breakpoints 12 | commands/data 13 | commands/files 14 | commands/info 15 | commands/running 16 | commands/set 17 | commands/stack 18 | commands/show 19 | commands/support 20 | -------------------------------------------------------------------------------- /docs/commands/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = /usr/bin/env python3 -msphinx 7 | SPHINXPROJ = remake 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | all: html 12 | 13 | # Put it first so that "make" without argument is like "make help". 14 | #: Show help on useful targets 15 | help: 16 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 17 | 18 | #: Make docs used in readthedocs.io 19 | readthedocs: 20 | $(MAKE) html 21 | 22 | html: 23 | $(MAKE) -C .. $@ 24 | 25 | %: html 26 | $(MAKE) -C .. $@ 27 | 28 | .PHONY: help Makefile all 29 | 30 | # Catch-all target: route all unknown targets to Sphinx using the new 31 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 32 | %: Makefile 33 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 34 | -------------------------------------------------------------------------------- /docs/commands/breakpoints/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be handled by the 2 | # by the main (parent) Makefile. So reissue make from there. 3 | .PHONY: html 4 | 5 | html: 6 | $(MAKE) -C ../.. $@ 7 | 8 | %: html 9 | $(MAKE) -C ../.. $@ 10 | -------------------------------------------------------------------------------- /docs/commands/breakpoints/clear.rst: -------------------------------------------------------------------------------- 1 | .. index:: clear 2 | .. _clear: 3 | 4 | Clear (Remove all breakpoints on a line) 5 | ---------------------------------------- 6 | 7 | **clear** [*linenumber*] 8 | 9 | Clear some breakpoints by line number. 10 | 11 | .. seealso:: 12 | 13 | :ref:`delete ` 14 | -------------------------------------------------------------------------------- /docs/commands/breakpoints/condition.rst: -------------------------------------------------------------------------------- 1 | .. index:: condition 2 | .. _condition: 3 | 4 | Condition (add condition to breakpoint) 5 | --------------------------------------- 6 | 7 | **condition** *bp_number* *condition* 8 | 9 | *bp_number* is a breakpoint number. *condition* is an expression which 10 | must evaluate to *True* before the breakpoint is honored. If *condition* 11 | is absent, any existing condition is removed; i.e., the breakpoint is 12 | made unconditional. 13 | 14 | Condition Examples 15 | +++++++++++++++++++ 16 | 17 | :: 18 | 19 | condition 5 x > 10 # Breakpoint 5 now has condition x > 10 20 | condition 5 # Remove above condition 21 | 22 | .. seealso:: 23 | 24 | :ref:`break `, :ref:`tbreak `. 25 | -------------------------------------------------------------------------------- /docs/commands/breakpoints/delete.rst: -------------------------------------------------------------------------------- 1 | .. index:: delete 2 | .. _delete: 3 | 4 | Delete (remove breakpoints) 5 | --------------------------- 6 | 7 | **delete** [*bpnumber* [*bpnumber*...]] 8 | 9 | Delete some breakpoints. 10 | 11 | Arguments are breakpoint numbers with spaces in between. To delete 12 | all breakpoints, give no argument. Without 13 | arguments, clear all breaks (but first ask confirmation). 14 | 15 | .. seealso:: 16 | 17 | :ref:`clear ` 18 | -------------------------------------------------------------------------------- /docs/commands/breakpoints/disable.rst: -------------------------------------------------------------------------------- 1 | .. index:: disable 2 | .. _disable: 3 | 4 | Disable (disable breakpoints) 5 | ----------------------------- 6 | 7 | **disable** *bpnumber* [*bpnumber* ...] 8 | 9 | Disables the breakpoints given as a space separated list of breakpoint 10 | numbers. See also `info break` to get a list. 11 | 12 | .. seealso:: 13 | 14 | :ref:`enable ` 15 | -------------------------------------------------------------------------------- /docs/commands/breakpoints/enable.rst: -------------------------------------------------------------------------------- 1 | .. index:: enable: 2 | .. _enable: 3 | 4 | Enable (enable breakpoints) 5 | --------------------------- 6 | 7 | **enable** *bpnumber* [*bpnumber* ...] 8 | 9 | Enables the breakpoints given as a space separated list of breakpoint 10 | numbers. See also `info break` to get a list. 11 | 12 | .. seealso:: 13 | 14 | :ref:`disable `, :ref:`tbreak ` 15 | -------------------------------------------------------------------------------- /docs/commands/breakpoints/tbreak.rst: -------------------------------------------------------------------------------- 1 | .. index:: tbreak 2 | .. _tbreak: 3 | 4 | Tbreak (temporary breakpoint) 5 | ----------------------------- 6 | 7 | **tbreak** [ *location* ] [**if** *condition*] 8 | 9 | With a line number argument, set a break there in the current file. 10 | With a function name, set a break at first executable line of that 11 | function. Without argument, set a breakpoint at current location. If 12 | a second argument is ``if``, subsequent arguments given an expression 13 | which must evaluate to true before the breakpoint is honored. 14 | 15 | The location line number may be prefixed with a filename or module 16 | name and a colon. Files is searched for using *sys.path*, and the `.py` 17 | suffix may be omitted in the file name. 18 | 19 | Examples: 20 | +++++++++ 21 | 22 | :: 23 | 24 | tbreak # Break where we are current stopped at 25 | tbreak 10 # Break on line 10 of the file we are currently stopped at 26 | tbreak os.path.join # Break in function os.path.join 27 | tbreak os.path:45 # Break on line 45 of os.path 28 | tbreak myfile.py:45 # Break on line 45 of myfile.py 29 | tbreak myfile:45 # Same as above. 30 | 31 | .. seealso:: 32 | 33 | :ref:`break `. 34 | -------------------------------------------------------------------------------- /docs/commands/data.rst: -------------------------------------------------------------------------------- 1 | Data 2 | ==== 3 | 4 | Examining data. 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | data/deparse 10 | data/disassemble 11 | data/display 12 | data/eval 13 | data/examine 14 | data/pp 15 | data/pr 16 | data/undisplay 17 | data/whatis 18 | -------------------------------------------------------------------------------- /docs/commands/data/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be handled by the 2 | # by the main (parent) Makefile. So reissue make from there. 3 | .PHONY: html 4 | 5 | html: 6 | $(MAKE) -C ../.. $@ 7 | 8 | %: html 9 | $(MAKE) -C ../.. $@ 10 | -------------------------------------------------------------------------------- /docs/commands/data/display.rst: -------------------------------------------------------------------------------- 1 | .. index:: display 2 | .. _display: 3 | 4 | Display (set display expression) 5 | -------------------------------- 6 | 7 | **display** [ *format* ] *expression* 8 | 9 | Print value of expression *expression* each time the program stops. 10 | *format* may be used before *expression* and may be one of `/c` for 11 | char, `/x` for hex, `/o` for octal, `/f` for float or `/s` for string. 12 | 13 | For now, display expressions are only evaluated when in the same 14 | code as the frame that was in effect when the display expression 15 | was set. This is a departure from *gdb*, and we may allow for more 16 | flexibility in the future to specify whether this should be the 17 | case or not. 18 | 19 | With no argument, evaluate and display all currently requested 20 | auto-display expressions. 21 | 22 | .. seealso:: 23 | 24 | :ref:`undisplay ` to cancel display requests previously made. 25 | -------------------------------------------------------------------------------- /docs/commands/data/eval.rst: -------------------------------------------------------------------------------- 1 | .. index:: eval 2 | .. _eval: 3 | 4 | Eval (evaluate Python code) 5 | --------------------------- 6 | 7 | **eval** *python-statement* 8 | 9 | Run *python-statement* in the context of the current frame. 10 | 11 | If no string is given, we run the string from the current source code 12 | about to be run. If the command ends `?` (via an alias) and no string is 13 | given, the following translations occur: 14 | 15 | :: 16 | 17 | assert => 18 | {if|elif} : => 19 | while : => 20 | return => 21 | for in : => 22 | = => 23 | 24 | The above is done via regular expression matching. No fancy parsing is 25 | done, say, to look to see if *expr* is split across a line or whether 26 | var an assignment might have multiple variables on the left-hand side. 27 | 28 | Eval Examples 29 | +++++++++++++ 30 | 31 | :: 32 | 33 | eval 1+2 # 3 34 | eval # Run current source-code line 35 | eval? # but strips off leading 'if', 'while', .. 36 | # from command 37 | 38 | .. seealso:: 39 | 40 | :ref:`python `, 41 | :ref:`set autoeval `, :ref:`pr `, 42 | :ref:`pp ` and :ref:`examine `. 43 | -------------------------------------------------------------------------------- /docs/commands/data/examine.rst: -------------------------------------------------------------------------------- 1 | .. index:: examine 2 | .. _examine: 3 | 4 | Examine 5 | ------- 6 | 7 | **examine** *expr1* [*expr2* ...] 8 | 9 | Examine value, type and object attributes of an expression. 10 | 11 | In contrast to normal Python expressions, expressions should not have 12 | blanks which would cause shlex to see them as different tokens. 13 | 14 | Examine Examples 15 | ++++++++++++++++ 16 | 17 | :: 18 | 19 | examine x+1 # ok 20 | examine x + 1 # not ok 21 | 22 | .. seealso:: 23 | 24 | :ref:`pr `, :ref:`pp `, and :ref:`whatis `. 25 | -------------------------------------------------------------------------------- /docs/commands/data/pp.rst: -------------------------------------------------------------------------------- 1 | .. index:: pp 2 | .. _pp: 3 | 4 | Pp (pretty print expression) 5 | ---------------------------- 6 | 7 | **pp** *expression* 8 | 9 | Pretty-print the value of the expression. 10 | 11 | Simple arrays are shown columnized horizontally. Other values are printed 12 | via *pprint.pformat()*. 13 | 14 | See also: 15 | +++++++++ 16 | 17 | :ref:`pr ` and :ref:`examine ` for commands which do more 18 | in the way of formatting. 19 | -------------------------------------------------------------------------------- /docs/commands/data/pr.rst: -------------------------------------------------------------------------------- 1 | .. index:: pr 2 | .. _pr: 3 | 4 | Pr (print expression) 5 | --------------------- 6 | 7 | **pr** *expression* 8 | 9 | Print the value of the expression. Variables accessible are those of the 10 | environment of the selected stack frame, plus globals. 11 | 12 | The expression may be preceded with */fmt* where *fmt* is one of the 13 | format letters 'c', 'x', 'o', 'f', or 's' for chr, hex, oct, 14 | float or str respectively. 15 | 16 | If the length output string large, the first part of the value is 17 | shown and `...` indicates it has been truncated. 18 | 19 | .. seealso:: 20 | 21 | :ref:`pp ` and :ref:`examine ` for commands which do more 22 | in the way of formatting; 23 | -------------------------------------------------------------------------------- /docs/commands/data/undisplay.rst: -------------------------------------------------------------------------------- 1 | .. index:: undisplay 2 | .. _undisplay: 3 | 4 | Undisplay (cancel a display expression) 5 | --------------------------------------- 6 | 7 | **undisplay** *display-number*... 8 | 9 | Cancel some expressions to be displayed when program stops. 10 | Arguments are the code numbers of the expressions to stop displaying. 11 | 12 | No argument cancels all automatic-display expressions and is 13 | the same as `delete display`. 14 | 15 | .. seealso:: 16 | 17 | :ref:`info display ` to see current list of code numbers. 18 | :ref:`whatis ` 19 | -------------------------------------------------------------------------------- /docs/commands/data/whatis.rst: -------------------------------------------------------------------------------- 1 | .. index:: whatis 2 | .. _whatis: 3 | 4 | Whatis 5 | ------ 6 | 7 | **whatis** *arg* 8 | 9 | Prints the information argument which can be a Python expression. 10 | 11 | When possible, we give information about: 12 | 13 | * type of argument 14 | * doc string for the argument (if a module, class, or function) 15 | * comments around the definition of the argument (module) 16 | * the module it was defined in 17 | * where the argument was defined 18 | 19 | We get this most of this information via the *inspect* module. 20 | 21 | .. seealso:: 22 | 23 | the :py:mod:`inspect` module. 24 | -------------------------------------------------------------------------------- /docs/commands/files.rst: -------------------------------------------------------------------------------- 1 | Files 2 | ===== 3 | 4 | Specifying and examining files. 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | files/edit 10 | files/list 11 | -------------------------------------------------------------------------------- /docs/commands/files/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be handled by the 2 | # by the main (parent) Makefile. So reissue make from there. 3 | .PHONY: html 4 | 5 | html: 6 | $(MAKE) -C ../.. $@ 7 | 8 | %: html 9 | $(MAKE) -C ../.. $@ 10 | -------------------------------------------------------------------------------- /docs/commands/files/edit.rst: -------------------------------------------------------------------------------- 1 | .. index:: edit 2 | .. _edit: 3 | 4 | Edit 5 | ---- 6 | 7 | **edit** *location* 8 | 9 | Edit specified file or module. 10 | With no argument, edits file containing most recent line listed. 11 | 12 | .. seealso:: 13 | 14 | :ref:`list ` and :ref:`help syntax location ` for the specification of a location 15 | -------------------------------------------------------------------------------- /docs/commands/info.rst: -------------------------------------------------------------------------------- 1 | Info 2 | ==== 3 | 4 | **info** [ *info-subcommand* ] 5 | 6 | Get information on the program being debugged. 7 | 8 | You can give unique prefix of the name of a subcommand to get 9 | information about just that subcommand. 10 | 11 | Type `info` for a list of info subcommands and what they do. Type help 12 | `info *` for just a list of info subcommands. 13 | 14 | .. toctree:: 15 | :maxdepth: 1 16 | 17 | info/args 18 | info/break 19 | info/builtins 20 | info/code 21 | info/display 22 | info/files 23 | info/frame 24 | info/globals 25 | info/line 26 | info/lines 27 | info/locals 28 | info/macro 29 | info/pc 30 | info/program 31 | info/return 32 | info/signals 33 | info/source 34 | info/threads 35 | -------------------------------------------------------------------------------- /docs/commands/info/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be handled by the 2 | # by the main (parent) Makefile. So reissue make from there. 3 | .PHONY: html 4 | 5 | html: 6 | $(MAKE) -C ../.. $@ 7 | 8 | %: html 9 | $(MAKE) -C ../.. $@ 10 | -------------------------------------------------------------------------------- /docs/commands/info/args.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; args 2 | .. _info_args: 3 | 4 | Info Args 5 | --------- 6 | 7 | **info args** 8 | 9 | Show parameters of the current stack frame. 10 | 11 | .. seealso:: 12 | 13 | :ref:`info locals `, :ref:`info globals `, 14 | :ref:`info frame ` 15 | -------------------------------------------------------------------------------- /docs/commands/info/break.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; break 2 | .. _info_break: 3 | 4 | Info Break 5 | ---------- 6 | 7 | **info breakpoints** [ *bp-number...* ] 8 | 9 | Show the status of specified breakpoints (or all user-settable 10 | breakpoints if no argument). 11 | 12 | The **Disp** column contains one of `keep`, or `del`, to indicate the 13 | disposition of the breakpoint after it gets hit. `del` means that the 14 | breakpoint will be deleted. The **Enb** column indicates if the 15 | breakpoint is enabled. The **Where** column indicates the file/line 16 | number of the breakpoint. 17 | 18 | Also shown are the number of times the breakpoint has been hit, 19 | when that count is at least one, and any conditions the breakpoint 20 | has. 21 | 22 | Example: 23 | ++++++++ 24 | 25 | :: 26 | 27 | (trepan3k) info break 28 | Num Type Disp Enb Where 29 | 1 breakpoint del n at /tmp/fib.py:9 30 | 2 breakpoint keep y at /tmp/fib.py:4 31 | breakpoint already hit 1 time 32 | 3 breakpoint keep y at /tmp/fib.py:6 33 | stop only if x > 0 34 | 35 | .. seealso:: 36 | 37 | :ref:`break `, :ref:`delete ` :ref:`enable `, :ref:`disable`, :ref:`condition ` 38 | -------------------------------------------------------------------------------- /docs/commands/info/builtins.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; builtins 2 | .. _info_builtins: 3 | 4 | Info Builtins 5 | ------------- 6 | 7 | **info builtins** 8 | 9 | Show the builtin-functions for the current stack frame. 10 | -------------------------------------------------------------------------------- /docs/commands/info/code.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; code 2 | .. _info_code: 3 | 4 | **info code** [ *frame-number* | *code-object* ] 5 | 6 | 7 | Info Code 8 | ---------- 9 | 10 | Specific information includes: 11 | 12 | * the number of arguments (not including * or ** args) 13 | * the number of local variables 14 | * maximum stack size used by the frame 15 | * first line associated with the code 16 | * constants used in the bytecode 17 | * whether code is optimized 18 | * Should a new local namespace be created for this code? (This is True for functions and False for modules and exec code.) 19 | * name with which this code object was defined 20 | 21 | .. seealso:: 22 | 23 | :ref:`info frame `, :ref:`info frame `, :ref:`info locals `, 24 | -------------------------------------------------------------------------------- /docs/commands/info/display.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; display 2 | .. _info_display: 3 | 4 | Info Display 5 | ------------ 6 | 7 | **info display** 8 | 9 | Show the display expression evaluated when the program stops. 10 | 11 | .. seealso:: 12 | 13 | :ref:`display `, :ref:`undisplay ` 14 | -------------------------------------------------------------------------------- /docs/commands/info/files.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; files 2 | .. _info_files: 3 | 4 | Info Files 5 | ---------- 6 | 7 | **info files** [ *filename* [ **all** | **brkpts** | **sha1** | **size** ]] 8 | 9 | Show information about the current file. If no filename is given and 10 | the program is running then the current file associated with the 11 | current stack entry is used. Sub options which can be shown about a file are: 12 | 13 | :brkpts: 14 | Line numbers where there are statement boundaries. These lines can be used in breakpoint commands. 15 | :sha1: 16 | A SHA1 hash of the source text. This may be useful in comparing source code 17 | :size: 18 | The number of lines in the file. 19 | :all: 20 | All of the above information. 21 | -------------------------------------------------------------------------------- /docs/commands/info/frame.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; frame 2 | .. _info_frame: 3 | 4 | **info frame** [-v] [ *frame-number* | *frame-object* ] 5 | 6 | 7 | Info Frame 8 | ---------- 9 | 10 | Show the detailed information for *frame-number* or the current frame if 11 | *frame-number* is not specified. You can also give a frame object instead of 12 | a frame number 13 | 14 | Specific information includes: 15 | 16 | * the frame number (if not an object) 17 | * the source-code line number that this frame is stopped in 18 | * the last instruction executed; -1 if the program are before the first instruction 19 | * a function that tracing this frame or `None` 20 | * Whether the frame is in restricted execution 21 | * Exception type and value if there is one 22 | 23 | If `-v` is given we show builtin and global names the frame sees. 24 | 25 | .. seealso:: 26 | 27 | :ref:`info locals `, :ref:`info globals `, 28 | :ref:`info args ` 29 | -------------------------------------------------------------------------------- /docs/commands/info/globals.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; globals 2 | .. _info_globals: 3 | 4 | Info Globals 5 | ------------ 6 | 7 | **info globals** [*var1 ...*] 8 | 9 | **info globals** **\*** 10 | 11 | With no arguments, show all of the global variables of the current stack 12 | frame. If a list of names is provide limit display to just those 13 | variables. 14 | 15 | If `*` is given, just show the variable names, not the values. 16 | 17 | .. seealso:: 18 | 19 | :ref:`info locals `, :ref:`info args `, 20 | :ref:`info frame ` 21 | -------------------------------------------------------------------------------- /docs/commands/info/line.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; line 2 | .. _info_line: 3 | 4 | Info Line 5 | --------- 6 | 7 | **info line** [*location*] 8 | 9 | Show line information for location *location*. 10 | 11 | If no location is given, use the the current stopped line. 12 | 13 | Info Line Examples 14 | ++++++++++++++++++ 15 | 16 | :: 17 | 18 | (trepan3k) info line 19 | Line 3 of "/tmp/python3-trepan/test/example/multi-line.py" 20 | starts at offset 0 of and contains 2 instructions 21 | There are multiple starting offsets this line. Other starting offsets: 4 of 22 | 23 | (trepan3k) info line 5 24 | Line 5 of "/tmp/python3-trepan/test/example/multi-line.py" 25 | starts at offset 16 of and contains 7 instructions 26 | 27 | 28 | .. seealso:: 29 | 30 | :ref:`info program `, :ref:`info frame ` and :ref:`help syntax location `. 31 | -------------------------------------------------------------------------------- /docs/commands/info/lines.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; lines 2 | .. _info_lines: 3 | 4 | Info Lines 5 | ----------- 6 | 7 | **info lines** [**-n** *function-or-module*] 8 | 9 | Show line - function/offset information. 10 | Use **-n** *function-or-module* to filter results. 11 | 12 | 13 | Info Lines Examples 14 | ++++++++++++++++++++ 15 | 16 | :: 17 | 18 | (trepan3k) info lines 19 | Line - (fn, start offset) table for test/example/gcd.py 20 | 10: @0 21: check_args() @84 36: gcd() @30 21 | 11: @4 22: check_args() @106 37: gcd() @50 22 | 13: @12 23: check_args() @116 38: gcd() @54 23 | 14: check_args() @0 24: check_args() @122 40: @28 24 | 16: check_args() @14 26: @20 41: @36 25 | 17: check_args() @22 30: gcd() @0 43: @42 26 | 18: check_args() @36 31: gcd() @8 44: @60 27 | 19: check_args() @38 34: gcd() @18 45: @84 28 | 20: check_args() @70 35: gcd() @26 29 | (trepan3k) info lines -n 30 | 10: @0 11: @4 13: @12 31 | 40: @28 26: @20 41: @36 32 | 43: @42 44: @60 45: @84 33 | (trepan3k) info lines -n gcd 34 | 30: gcd() @0 31: gcd() @8 34: gcd() @18 35 | 35: gcd() @26 36: gcd() @30 37: gcd() @50 36 | 38: gcd() @54 37 | 38 | .. seealso:: 39 | 40 | :ref:`info program `, :ref:`info program `, :ref:`info pc `, :ref:`info frame ` 41 | -------------------------------------------------------------------------------- /docs/commands/info/locals.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; locals 2 | .. _info_locals: 3 | 4 | Info Locals 5 | ----------- 6 | 7 | **info locals** [*var1 ...*] 8 | 9 | **info locals** **\*** 10 | 11 | With no arguments, show all of the local variables of the current stack 12 | frame. If a list of names is provide limit display to just those 13 | variables. 14 | 15 | If `*` is given, just show the variable names, not the values. 16 | 17 | .. seealso:: 18 | 19 | :ref:`info globals `, :ref:`info args `, 20 | :ref:`info frame ` 21 | -------------------------------------------------------------------------------- /docs/commands/info/macro.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; macro 2 | .. _info_macro: 3 | 4 | Info Macro 5 | ---------- 6 | 7 | | **info macro** 8 | | **info macro** **\*** 9 | | **info macro** *macro1* [*macro2* ..] 10 | | 11 | 12 | In the first form a list of the existing macro names are shown 13 | in column format. 14 | 15 | In the second form, all macro names and their definitions are shown. 16 | 17 | In the last form the only definitions of the given macro names is shown. 18 | 19 | .. seealso:: 20 | 21 | :ref:`show aliases ` 22 | -------------------------------------------------------------------------------- /docs/commands/info/pc.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; pc 2 | .. _info_pc: 3 | 4 | Info PC 5 | ------- 6 | 7 | | **info pc** 8 | 9 | 10 | List the current program counter or bytecode offset, 11 | and disassemble the instructions around that. 12 | 13 | .. seealso:: 14 | 15 | :ref:`info line `, :ref:`info program ` 16 | -------------------------------------------------------------------------------- /docs/commands/info/program.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; program 2 | .. _info_program: 3 | 4 | Info Program 5 | ------------ 6 | 7 | **info program** 8 | 9 | Execution status of the program. Listed are: 10 | 11 | * Program name 12 | * Instruction PC 13 | * Reason the program is stopped. 14 | 15 | .. seealso:: 16 | 17 | :ref:`info line `, :ref:`info args `, 18 | :ref:`info frame ` 19 | -------------------------------------------------------------------------------- /docs/commands/info/return.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; return 2 | .. _info_return: 3 | 4 | Info Return 5 | ----------- 6 | 7 | **info return** 8 | 9 | Show the value that is to be returned from a function. This command 10 | is useful after a running a debugger :ref:`finish ` command or 11 | stepping just after a 'return' statement. 12 | -------------------------------------------------------------------------------- /docs/commands/info/signals.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; signals 2 | .. _info_signals: 3 | 4 | Info Signals 5 | ------------ 6 | **info signals** [*signal-name*] 7 | 8 | **info signals** \* 9 | 10 | Show information about how debugger treats signals to the program. 11 | Here are the boolean actions we can take: 12 | 13 | * Stop: enter the debugger when the signal is sent to the debugged program 14 | * Print: print that the signal was received 15 | * Stack: show a call stack 16 | * Pass: pass the signal onto the program 17 | 18 | If *signal-name* is not given, we the above show information for all 19 | signals. If '*' is given we just give a list of signals. 20 | -------------------------------------------------------------------------------- /docs/commands/info/source.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; source 2 | .. _info_source: 3 | 4 | Info Source 5 | ----------- 6 | 7 | **info source** 8 | 9 | Information about the current Python file. 10 | -------------------------------------------------------------------------------- /docs/commands/info/threads.rst: -------------------------------------------------------------------------------- 1 | .. index:: info; threads 2 | .. _info_threads: 3 | 4 | Info Threads 5 | ------------ 6 | **info threads** [ *thread-name* | *thread-number* ] [ **terse** | **verbose** ] 7 | 8 | List all currently-known thread name(s). 9 | 10 | If no thread name is given, we list info for all threads. Unless a 11 | terse listing, for each thread we give: 12 | 13 | * the class, thread name, and status as *Class(Thread-n, status)* 14 | * the top-most call-stack information for that thread. 15 | 16 | Generally the top-most calls into the debugger and dispatcher are 17 | omitted unless set dbg_trepan is *True*. 18 | 19 | If 'verbose' appended to the end of the command, then the entire stack 20 | trace is given for each frame. If 'terse' is appended we just list 21 | the thread name and thread id. 22 | 23 | To get the full stack trace for a specific thread pass in the thread name. 24 | -------------------------------------------------------------------------------- /docs/commands/running/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be handled by the 2 | # by the main (parent) Makefile. So reissue make from there. 3 | .PHONY: html 4 | 5 | html: 6 | $(MAKE) -C ../.. $@ 7 | 8 | %: html 9 | $(MAKE) -C ../.. $@ 10 | -------------------------------------------------------------------------------- /docs/commands/running/continue.rst: -------------------------------------------------------------------------------- 1 | .. index:: continue 2 | 3 | Continue 4 | -------- 5 | 6 | **continue** [[ *file* :] *lineno* | *function* ] 7 | 8 | Leave the debugger read-eval print loop and continue 9 | execution. Subsequent entry to the debugger however may occur via 10 | breakpoints or explicit calls, or exceptions. 11 | 12 | If a line position or function is given, a temporary breakpoint is set at that 13 | position before continuing. 14 | 15 | Continue Examples: 16 | ++++++++++++++++++ 17 | 18 | :: 19 | 20 | continue # Continue execution 21 | continue 5 # Continue with a one-time breakpoint at line 5 22 | continue basename # Go to os.path.basename if we have basename imported 23 | continue /usr/lib/python2.7/posixpath.py:110 # Possibly the same as 24 | # the above using file 25 | # and line number 26 | 27 | .. seealso:: 28 | 29 | :ref:`step ` :ref:`jump `, :ref:`next `, and :ref:`finish ` provide other ways to progress execution. 30 | -------------------------------------------------------------------------------- /docs/commands/running/exit.rst: -------------------------------------------------------------------------------- 1 | .. index:: exit 2 | 3 | Exit 4 | ---- 5 | 6 | **exit** [*exitcode*] 7 | 8 | Hard exit of the debugged program. 9 | 10 | The program being debugged is exited via *sys.exit()*. If a return code 11 | is given, that is the return code passed to *sys.exit()*, the 12 | return code that will be passed back to the OS. 13 | 14 | .. seealso:: 15 | 16 | :ref:`quit ` and :ref:`kill ` 17 | -------------------------------------------------------------------------------- /docs/commands/running/finish.rst: -------------------------------------------------------------------------------- 1 | .. index:: finish 2 | .. _finish: 3 | 4 | Finish (step out) 5 | ----------------- 6 | 7 | **finish** [*level*] 8 | 9 | Continue execution until leaving the current function. When *level* is 10 | specified, that many frame levels need to be popped. Note that *yield* 11 | and exceptions raised my reduce the number of stack frames. Also, if a 12 | thread is switched, we stop ignoring levels. 13 | 14 | See the :ref:`break ` command if you want to stop at a 15 | particular point in a program. 16 | 17 | .. seealso:: 18 | 19 | :ref:`step ` :ref:`skip `, :ref:`jump `, :ref:`continue `, and :ref:`finish ` provide other ways to progress 20 | -------------------------------------------------------------------------------- /docs/commands/running/jump.rst: -------------------------------------------------------------------------------- 1 | .. index:: jump 2 | 3 | Jump 4 | ---- 5 | 6 | **jump** *lineno* 7 | 8 | Set the next line that will be executed. 9 | 10 | There are a number of limitations on what line can be set. 11 | 12 | You can't jump: 13 | 14 | * into the body of a for loop 15 | * into an ``except`` block from outside 16 | * outside or inside of a code block you are stopped 17 | 18 | Jumping to a previous line is one way to reexecuting code. 19 | Jumping to a return statement may get you back to the caller 20 | function without running more code in the current frame. 21 | 22 | .. seealso:: 23 | 24 | :ref:`skip `, 25 | :ref:`next `, :ref:`step `, :ref:`continue `, and 26 | :ref:`finish ` provide other ways to progress. 27 | 28 | :ref:`eval ` can be used to run Python code without changing the execution line. 29 | -------------------------------------------------------------------------------- /docs/commands/running/kill.rst: -------------------------------------------------------------------------------- 1 | .. index:: kill 2 | 3 | Kill 4 | ---- 5 | 6 | **kill** [ *signal-number* ] [unconditional] 7 | 8 | Send this process a POSIX signal ('9' for 'SIGKILL' or 'kill -SIGKILL') 9 | 10 | 9 is a non-maskable interrupt that terminates the program. If program 11 | is threaded it may be expedient to use this command to terminate the program. 12 | 13 | However other signals, such as those that allow for the debugged to 14 | handle them can be sent. 15 | 16 | Giving a negative number is the same as using its 17 | positive value. 18 | 19 | Kill Examples: 20 | ++++++++++++++ 21 | 22 | :: 23 | 24 | kill # non-interuptable, nonmaskable kill 25 | kill 9 # same as above 26 | kill -9 # same as above 27 | kill! # same as above, but no confirmation 28 | kill unconditional # same as above 29 | kill 15 # nicer, maskable TERM signal 30 | kill! 15 # same as above, but no confirmation 31 | 32 | .. seealso:: 33 | 34 | :ref:`quit ` for less a forceful termination command; `exit` for another way to force termination. 35 | :ref:`run ` and :ref:`restart ` are ways to restart the debugged program. 36 | -------------------------------------------------------------------------------- /docs/commands/running/next.rst: -------------------------------------------------------------------------------- 1 | .. index:: next 2 | .. _next: 3 | 4 | Next (step over) 5 | ---------------- 6 | 7 | **next** [ **+** | **-** ] [ *count* ] 8 | 9 | Step one statement ignoring steps into function calls at this level. 10 | 11 | With an integer argument, perform `next` that many times. However if 12 | an exception occurs at this level, or we *return*, *yield* or the 13 | thread changes, we stop regardless of count. 14 | 15 | A suffix of `+` on the command or an alias to the command forces to 16 | move to another line, while a suffix of `-` does the opposite and 17 | disables the requiring a move to a new line. If no suffix is given, 18 | the debugger setting 'different-line' determines this behavior. 19 | 20 | .. seealso:: 21 | 22 | :ref:`stepi `, ref:`skip `, :ref:`jump `, :ref:`continue `, and 23 | :ref:`finish ` provide other ways to progress execution. 24 | -------------------------------------------------------------------------------- /docs/commands/running/quit.rst: -------------------------------------------------------------------------------- 1 | .. index:: quit 2 | 3 | Quit 4 | ---- 5 | **quit** [**unconditionally**] 6 | 7 | Gently terminate the debugged program. 8 | 9 | The program being debugged is aborted via a *DebuggerQuit* 10 | exception. 11 | 12 | When the debugger from the outside (e.g. via a `trepan` command), the 13 | debugged program is contained inside a try block which handles the 14 | *DebuggerQuit* exception. However if you called the debugger was 15 | started in the middle of a program, there might not be such an 16 | exception handler; the debugged program still terminates but generally 17 | with a traceback showing that exception. 18 | 19 | If the debugged program is threaded, we raise an exception in each of 20 | the threads ending with our own. However this might not quit the 21 | program. 22 | 23 | .. seealso:: 24 | 25 | :ref:`kill ` or `kill` for more forceful termination commands. :ref:`run ` and :ref:`restart ` are other ways to restart the debugged program. 26 | -------------------------------------------------------------------------------- /docs/commands/running/restart.rst: -------------------------------------------------------------------------------- 1 | .. index:: restart 2 | 3 | Restart 4 | ------- 5 | **restart** 6 | 7 | Restart debugger and program via an *exec()* call. All state is lost, 8 | and new copy of the debugger is used. 9 | 10 | .. seealso:: 11 | 12 | :ref:`run ` for another way to restart the debugged program. :ref:`quit `, or :ref:`kill ` for termination commands. 13 | -------------------------------------------------------------------------------- /docs/commands/running/run.rst: -------------------------------------------------------------------------------- 1 | .. index:: run 2 | 3 | Run 4 | --- 5 | **run** 6 | 7 | Soft restart debugger and program via a *DebuggerRestart* 8 | exception. 9 | 10 | .. seealso:: 11 | 12 | :ref:`restart ` for another way to restart the debugged program. 13 | :ref:`quit `, or :ref:`kill ` for termination commands. 14 | -------------------------------------------------------------------------------- /docs/commands/running/skip.rst: -------------------------------------------------------------------------------- 1 | .. index:: skip 2 | 3 | Skip 4 | ---- 5 | 6 | **skip** [*count*] 7 | 8 | Skip over (don't run) the next line that will be executed. 9 | 10 | .. seealso:: 11 | 12 | :ref:`next `, :ref:`step `, :ref:`jump `, :ref:`continue `, and 13 | :ref:`finish ` provide other ways to progress execution. 14 | -------------------------------------------------------------------------------- /docs/commands/running/stepi.rst: -------------------------------------------------------------------------------- 1 | .. index:: stepi 2 | .. _stepi: 3 | 4 | Step Instruction 5 | ---------------- 6 | 7 | **stepi** [*count*] 8 | 9 | Execute the current line, stopping at the instruction bytecode. 10 | 11 | With an integer argument, step bytecode instructions that many times. 12 | 13 | 14 | Step Instruction Examples: 15 | ++++++++++++++++++++++++++ 16 | 17 | :: 18 | 19 | stepi # step 1 event, *any* event 20 | si 1 # same as above 21 | 22 | Related and similar is the ``step`` command. 23 | 24 | .. seealso:: 25 | 26 | :ref:`step ` command. :ref:`next `, :ref:`skip `, :ref:`jump ` (there's no `hop` yet), :ref:`continue `, and :ref:`finish ` provide other ways to progress execution. 27 | -------------------------------------------------------------------------------- /docs/commands/set.rst: -------------------------------------------------------------------------------- 1 | .. _set: 2 | 3 | **set** [ *set-subcommand* ] 4 | 5 | Modifies parts of the debugger environment. 6 | 7 | You can give unique prefix of the name of a subcommand to get information 8 | about just that subcommand. 9 | 10 | Type `set` for a list of set subcommands and what they do. Type help set * 11 | for just the list of set subcommands. 12 | 13 | All of the "set" commands have a corresponding :ref:`show ` command. 14 | 15 | Set 16 | === 17 | 18 | Modifies parts of the debugger environment. You can see these 19 | environment settings with the :ref:`show ` command. 20 | 21 | .. toctree:: 22 | :maxdepth: 1 23 | 24 | set/asmfmt 25 | set/autoeval 26 | set/autolist 27 | set/autopc 28 | set/autopython 29 | set/basename 30 | set/cmdtrace 31 | set/confirm 32 | set/dbg_trepan 33 | set/different 34 | set/events 35 | set/flush 36 | set/highlight 37 | set/listsize 38 | set/maxstring 39 | set/patsub 40 | set/skip 41 | set/style 42 | set/substitute 43 | set/trace 44 | set/width 45 | -------------------------------------------------------------------------------- /docs/commands/set/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be handled by the 2 | # by the main (parent) Makefile. So reissue make from there. 3 | .PHONY: html 4 | 5 | html: 6 | $(MAKE) -C ../.. $@ 7 | 8 | %: html 9 | $(MAKE) -C ../.. $@ 10 | -------------------------------------------------------------------------------- /docs/commands/set/asmfmt.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; asmfmt 2 | .. _set_asmfmt: 3 | 4 | Set Asmfmt 5 | ----------- 6 | 7 | **set asmfmt** {**classic** | **extended** | **bytes** | **extended-bytes**} 8 | 9 | Set the style of format to use in disassembly: 10 | 11 | ``classic``: 12 | has fields: *line* *marker* *offset*, and *opcode operand* 13 | 14 | ``extended``: 15 | like ``classic``, but we try harder to get operand information from previous instructions 16 | 17 | ``bytes``: 18 | like classic but we show the instruction bytes after the offset 19 | 20 | ``extended-bytes`` 21 | ``bytes`` format along with *extended* format 22 | 23 | 24 | Frame Examples: 25 | +++++++++++++++ 26 | 27 | :: 28 | set asmfmt extended # this is the default 29 | set asmfmt classic # no highlight 30 | 31 | .. seealso:: 32 | 33 | :ref:`show asmfmt ` 34 | -------------------------------------------------------------------------------- /docs/commands/set/autolist.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; autolist 2 | .. _set_autolist: 3 | 4 | Set Auto List 5 | ------------- 6 | 7 | **set autolist** [ **on** | **off** ] 8 | 9 | Run the :ref:`list ` command every time you stop in the 10 | debugger. 11 | 12 | With this, you will get output like: 13 | 14 | :: 15 | 16 | -> 1 from subprocess import Popen, PIPE 17 | (trepan3k) next 18 | (/users/fbicknel/Projects/disk_setup/sqlplus.py:2): 19 | ** 2 import os 20 | 1 from subprocess import Popen, PIPE 21 | 2 -> import os 22 | 3 import re 23 | 4 24 | 5 class SqlPlusExecutor(object): 25 | 6 def __init__(self, connection_string='/ as sysdba', sid=None): 26 | 7 self.__connection_string = connection_string 27 | 8 self.session = None 28 | 9 self.stdout = None 29 | 10 self.stderr = None 30 | (trepan3k) next 31 | (/users/fbicknel/Projects/disk_setup/sqlplus.py:3): 32 | ** 3 import re 33 | 1 from subprocess import Popen, PIPE 34 | 2 import os 35 | 3 -> import re 36 | 4 37 | 5 class SqlPlusExecutor(object): 38 | 6 def __init__(self, connection_string='/ as sysdba', sid=None): 39 | 7 self.__connection_string = connection_string 40 | 8 self.session = None 41 | 9 self.stdout = None 42 | 10 self.stderr = None 43 | (trepan3k) 44 | 45 | You may also want to put this this in your debugger startup file. 46 | 47 | .. seealso:: 48 | 49 | :ref:`show autolist ` 50 | -------------------------------------------------------------------------------- /docs/commands/set/autopython.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; autopython 2 | .. _set_autopython: 3 | 4 | Set Autopython 5 | -------------- 6 | **set autopython** [ **on** | **off** ] 7 | 8 | Go into a Python shell on debugger entry. 9 | 10 | .. seealso:: 11 | 12 | :ref:`python ` 13 | -------------------------------------------------------------------------------- /docs/commands/set/basename.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; basename 2 | .. _set_basename: 3 | 4 | Set Basename 5 | ------------ 6 | 7 | **set basename** [ **on** | **off** ] 8 | 9 | 10 | Set short filenames in debugger output. 11 | 12 | Setting this causes the debugger output to give just the basename for 13 | filenames. This is useful in debugger testing or possibly showing 14 | examples where you don't want to hide specific filesystem and 15 | installation information. 16 | 17 | .. seealso:: 18 | 19 | :ref:`show basename ` 20 | -------------------------------------------------------------------------------- /docs/commands/set/cmdtrace.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; cmdtrace 2 | .. _set_cmdtrace: 3 | 4 | Set Cmdtrace 5 | ------------ 6 | 7 | **set cmdtrace** [ **on** | **off** ] 8 | 9 | Set echoing lines read from debugger command files 10 | 11 | .. seealso:: 12 | 13 | :ref:`show cmdtrace ` 14 | -------------------------------------------------------------------------------- /docs/commands/set/confirm.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; confirm 2 | .. _set_confirm: 3 | 4 | Set Confirm 5 | ------------ 6 | 7 | **set confirm** [ **on** | **off** ] 8 | 9 | Set confirmation of potentially dangerous operations. 10 | 11 | Some operations are a bit disruptive like terminating the program. 12 | To guard against running this accidentally, by default we ask for 13 | confirmation. Commands can also be exempted from confirmation by suffixing 14 | them with an exclamation mark (!). 15 | 16 | .. seealso:: 17 | 18 | :ref:`show confirm ` 19 | -------------------------------------------------------------------------------- /docs/commands/set/dbg_trepan.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; dbg_trepan 2 | .. _set_dbg_trepan: 3 | 4 | Set Dbg_trepan 5 | -------------- 6 | 7 | **set dbg_trepan** [ **on** | **off** ] 8 | 9 | Set the ability to debug the debugger. 10 | 11 | Setting this allows visibility and access to some of the debugger's 12 | internals. Specifically variable "frame" contains the current frame and 13 | variable "debugger" contains the top-level debugger object. 14 | 15 | .. seealso:: 16 | 17 | :ref:`show dbg_trepan ` 18 | -------------------------------------------------------------------------------- /docs/commands/set/different.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; different 2 | .. _set_different: 3 | 4 | Set Different 5 | ------------- 6 | 7 | **set** **different** [ **on** | **off** ] 8 | 9 | Set consecutive stops must be on different file/line positions. 10 | 11 | By default, the debugger traces all events possible including line, 12 | exceptions, call and return events. Just this alone may mean that for 13 | any given source line several consecutive stops at a given line may 14 | occur. Independent of this, Python allows one to put several commands in 15 | a single source line of code. When a programmer does this, it might be 16 | because the programmer thinks of the line as one unit. 17 | 18 | One of the challenges of debugging is getting the granualarity of 19 | stepping comfortable. Because of the above, stepping all events can 20 | often be too fine-grained and annoying. By setting different on you can 21 | set a more coarse-level of stepping which often still is small enough 22 | that you won't miss anything important. 23 | 24 | Note that the `step` and `next` debugger commands have '+' and '-' 25 | suffixes if you wan to override this setting on a per-command basis. 26 | 27 | .. seealso:: 28 | 29 | :ref:`set trace ` to change what events you want to filter. 30 | :ref:`show trace `. 31 | -------------------------------------------------------------------------------- /docs/commands/set/events.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; events 2 | .. _set_events: 3 | 4 | Set Events 5 | ---------- 6 | **set events** [*event* ...] 7 | 8 | Sets the events that the debugger will stop on. Event names are: 9 | 10 | .. hlist:: 11 | :columns: 3 12 | 13 | * ``c_call`` 14 | * ``c_exception`` 15 | * ``c_return`` 16 | * `call`` 17 | * ``exception`` 18 | * ``line`` 19 | * ``return`` 20 | 21 | `all` can be used as an abbreviation for listing all event names. 22 | 23 | Changing trace event filters works independently of turning on or off 24 | tracing-event printing. 25 | 26 | Set Events Examples: 27 | ++++++++++++++++++++ 28 | 29 | :: 30 | 31 | set events line # Set trace filter for line events only. 32 | set events call return # Trace calls and returns only 33 | set events all # Set trace filter to all events. 34 | 35 | .. seealso:: 36 | 37 | :ref:`set trace `, :ref:`show trace `, and 38 | :ref:`show events ` 39 | -------------------------------------------------------------------------------- /docs/commands/set/flush.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; flush 2 | .. _set_flush: 3 | 4 | Set Flush 5 | --------- 6 | 7 | **set flush** [ **on** | **off** ] 8 | 9 | Set flushing output after each write 10 | 11 | .. seealso:: 12 | 13 | :ref:`show flush ` 14 | -------------------------------------------------------------------------------- /docs/commands/set/highlight.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; highlight 2 | .. _set_highlight: 3 | 4 | Set Highlight 5 | ------------- 6 | 7 | **set highlight** [ **reset** ] {**plain** | **light** | **dark** | **off**} 8 | 9 | Set whether we use terminal highlighting for ANSI 8-color terminals. Permissible values are: 10 | 11 | :plain: 12 | no terminal highlighting 13 | :off: 14 | same as plain 15 | :light: 16 | terminal background is light (the default) 17 | :dark: 18 | terminal background is dark 19 | 20 | If the first argument is *reset*, we clear any existing color formatting 21 | and recolor all source code output. 22 | 23 | A related setting is *style* which sets the Pygments style for terminal 24 | that support, 256 colors. But even here, it is useful to set 25 | the highlight to tell the debugger for bold and emphasized text what 26 | values to use. 27 | 28 | Set Highlight Examples: 29 | +++++++++++++++++++++++ 30 | 31 | :: 32 | 33 | set highlight off # no highlight 34 | set highlight plain # same as above 35 | set highlight # same as above 36 | set highlight dark # terminal has dark background 37 | set highlight light # terminal has light background 38 | set highlight reset light # clear source-code cache and 39 | # set for light background 40 | set highlight reset # clear source-code cache 41 | 42 | .. seealso:: 43 | 44 | :ref:`show highlight ` and :ref:`set style ` 45 | -------------------------------------------------------------------------------- /docs/commands/set/listsize.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; listsize 2 | .. _set_listsize: 3 | 4 | Set Listsize 5 | ------------ 6 | 7 | **set listsize** *number-of-lines* 8 | 9 | Set the number lines printed in a :ref:`list ` command by default 10 | 11 | .. seealso:: 12 | 13 | :ref:`show listsize ` 14 | -------------------------------------------------------------------------------- /docs/commands/set/maxstring.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; maxstring 2 | .. _set_maxstring: 3 | 4 | Set Maxstring 5 | ------------- 6 | **set maxstring** *number* 7 | 8 | Set the number of characters allowed in showing string values 9 | 10 | .. seealso:: 11 | 12 | :ref:`show maxstring ` 13 | -------------------------------------------------------------------------------- /docs/commands/set/patsub.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; patsub 2 | .. _set_patsub: 3 | 4 | Set Substitution Pattern 5 | ------------------------ 6 | 7 | **set patsub** *from-re* *replace-string* 8 | 9 | Add a substitution pattern rule replacing *patsub* with 10 | *replace-string* anywhere it is found in source file names. If a 11 | substitution rule was previously set for *from-re*, the old rule is 12 | replaced by the new one. 13 | 14 | In the following example, suppose in a docker container /mnt/project is 15 | the mount-point for /home/rocky/project. You are running the code 16 | from the docker container, but debugging this from outside of that. 17 | 18 | 19 | Example: 20 | ++++++++ 21 | 22 | :: 23 | 24 | set patsub ^/mmt/project /home/rocky/project 25 | 26 | .. seealso:: 27 | 28 | :ref:`set substitute ` 29 | -------------------------------------------------------------------------------- /docs/commands/set/skip.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; skip 2 | .. _set_skip: 3 | 4 | Set Skip 5 | -------- 6 | Set stopping before *def* or *class* (function or class) statements. 7 | 8 | Classes may have many methods and stand-alone programs may have many 9 | functions. Often there isn't much value to stopping before defining a 10 | new function or class into Python's symbol table. (More to the point, 11 | it can be an annoyance.) However if you do want this, for example 12 | perhaps you want to debug methods is over-writing one another, then 13 | set this off. 14 | 15 | .. seealso:: 16 | 17 | :ref:`show skip ` 18 | -------------------------------------------------------------------------------- /docs/commands/set/style.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; style 2 | .. _set_style: 3 | 4 | Set Style 5 | --------- 6 | **set style** [*pygments-style*] 7 | 8 | Set the pygments style in to use in formatting text for a 256-color terminal. 9 | Note: if your terminal doesn't support 256 colors, you may be better off 10 | using `--highlight=plain` or `--highlight=dark` instead. To turn off styles 11 | use `set style none`. 12 | 13 | To list the available pygments styles inside the debugger, omit the style name. 14 | 15 | 16 | Examples: 17 | +++++++++ 18 | 19 | :: 20 | 21 | set style # give a list of the style names 22 | set style colorful # Pygments 'colorful' style 23 | set style fdasfda # Probably display available styles 24 | set style none # Turn off style, still use highlight though 25 | 26 | .. seealso:: 27 | 28 | :ref:`show style ` and :ref:`set highlight ` 29 | -------------------------------------------------------------------------------- /docs/commands/set/substitute.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; substitute 2 | .. _set_substitute: 3 | 4 | Set Substitute 5 | -------------- 6 | **set substitute** *from-name* *to-path* 7 | 8 | Add a substitution rule replacing *from-name* into *to-path* in source file names. 9 | If a substitution rule was previously set for *from-name*, the old rule 10 | is replaced by the new one. 11 | 12 | Spaces in "filenames" like `` messes up our normal shell 13 | tokenization, so we have added a hack to ignore ``. 14 | 15 | So, for frozen files like ``, use `importlib._bootstrap` 16 | 17 | Examples: 18 | +++++++++ 19 | 20 | :: 21 | 22 | set substitute importlib._bootstrap /usr/lib/python3.4/importlib/_bootstrap.py 23 | set substitute ./gcd.py /tmp/gcd.py 24 | -------------------------------------------------------------------------------- /docs/commands/set/trace.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; trace 2 | .. _set_trace: 3 | 4 | Set Trace 5 | --------- 6 | 7 | **set trace** [ **on** | **off** ] 8 | 9 | Set event tracing. 10 | 11 | .. seealso:: 12 | 13 | :ref:`set events `, :ref:`set trace `, and 14 | :ref:`show trace ` 15 | -------------------------------------------------------------------------------- /docs/commands/set/width.rst: -------------------------------------------------------------------------------- 1 | .. index:: set; width 2 | .. _set_width: 3 | 4 | Set Width 5 | --------- 6 | **set width** *number* 7 | 8 | Set the number of characters the debugger thinks are in a line. 9 | 10 | .. seealso:: 11 | 12 | :ref:`show width ` 13 | -------------------------------------------------------------------------------- /docs/commands/show.rst: -------------------------------------------------------------------------------- 1 | .. _show: 2 | 3 | **show** [ *subcommand* ] 4 | 5 | A command for showing things about the debugger. You can give unique 6 | prefix of the name of a subcommand to get information about just that 7 | subcommand. 8 | 9 | Type `show` for a list of show subcommands and what they do. Type help 10 | `show *` for just a list of show subcommands. Many of the "show" 11 | commands have a corresponding :ref:`set ` command. 12 | 13 | Show 14 | ==== 15 | 16 | .. toctree:: 17 | :maxdepth: 1 18 | 19 | show/aliases 20 | show/args 21 | show/asmfmt 22 | show/autoeval 23 | show/autolist 24 | show/autopc 25 | show/autopython 26 | show/basename 27 | show/cmdtrace 28 | show/confirm 29 | show/dbg_trepan 30 | show/different 31 | show/events 32 | show/flush 33 | show/highlight 34 | show/listsize 35 | show/maxstring 36 | show/skip 37 | show/style 38 | show/trace 39 | show/width 40 | -------------------------------------------------------------------------------- /docs/commands/show/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be handled by the 2 | # by the main (parent) Makefile. So reissue make from there. 3 | .PHONY: html 4 | 5 | html: 6 | $(MAKE) -C ../.. $@ 7 | 8 | %: html 9 | $(MAKE) -C ../.. $@ 10 | -------------------------------------------------------------------------------- /docs/commands/show/aliases.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; aliases 2 | .. _show_aliases: 3 | 4 | Show Aliases (show debugger command aliases) 5 | -------------------------------------------- 6 | 7 | **show aliases** [ *alias* ...| **\*** ] 8 | 9 | Show command aliases. If parameters are given a list of all aliases 10 | and the command they run are printed. Alternatively one can list 11 | specific alias names for the commands those specific aliases are 12 | attached to. If instead of an alias "*" appears anywhere as an alias 13 | then just a list of aliases is printed, not what commands they are 14 | attached to. 15 | 16 | .. seealso:: 17 | 18 | :ref:`alias ` 19 | -------------------------------------------------------------------------------- /docs/commands/show/args.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; args 2 | .. _show_args: 3 | 4 | Show Args (show arguments when program is started) 5 | -------------------------------------------------- 6 | 7 | **show args** 8 | 9 | Show the argument list to give debugged program when it is started 10 | -------------------------------------------------------------------------------- /docs/commands/show/asmfmt.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; asmfmt 2 | .. _show_asmfmt: 3 | 4 | Show Asmfmt 5 | ----------- 6 | 7 | **show asmfmt** 8 | 9 | Show the disassembly format style used in the ``disassemble`` command. 10 | 11 | Show asmfmt Example: 12 | ++++++++++++++++++++ 13 | 14 | :: 15 | show asmfmt 16 | 17 | .. seealso:: 18 | 19 | :ref:`set_asmfmt ` 20 | -------------------------------------------------------------------------------- /docs/commands/show/autoeval.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; autoeval 2 | .. _show_autoeval: 3 | 4 | Show Autoeval 5 | ------------- 6 | 7 | **show autoeval** 8 | 9 | Show Python evaluation of unrecognized debugger commands. 10 | 11 | .. seealso:: 12 | 13 | :ref:`set autoeval ` 14 | -------------------------------------------------------------------------------- /docs/commands/show/autolist.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; autolist 2 | .. _show_autolist: 3 | 4 | Show Autolist 5 | ------------- 6 | 7 | **show autolist** 8 | 9 | Run a debugger ref:`list ` command automatically on debugger entry. 10 | 11 | .. seealso:: 12 | 13 | :ref:`set autolist ` 14 | -------------------------------------------------------------------------------- /docs/commands/show/autopc.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; autopc 2 | .. _show_autopc: 3 | 4 | Show Autorun Info PC 5 | -------------------- 6 | 7 | **show infopc** 8 | 9 | Run a debugger `info pc `_ command automatically on debugger entry. 10 | 11 | .. seealso:: 12 | 13 | :ref:`set autopc ` 14 | -------------------------------------------------------------------------------- /docs/commands/show/autopython.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; autopython 2 | .. _show_autopython: 3 | 4 | Show Autopython 5 | --------------- 6 | 7 | **show autopython** 8 | 9 | Show whether we go into a Python shell when automatically when the 10 | debugger is entered. 11 | 12 | .. seealso:: 13 | 14 | :ref:`set autopython ` 15 | -------------------------------------------------------------------------------- /docs/commands/show/basename.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; basename 2 | .. _show_basename: 3 | 4 | Show Basename 5 | ------------- 6 | 7 | **show basename** 8 | 9 | Show Python evaluation of unrecognized debugger commands. 10 | 11 | .. seealso:: 12 | 13 | :ref:`set basename ` 14 | -------------------------------------------------------------------------------- /docs/commands/show/cmdtrace.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; cmdtrace 2 | .. _show_cmdtrace: 3 | 4 | Show Cmdtrace 5 | ------------- 6 | 7 | **show cmdtrace** 8 | 9 | Show debugger commands before running them 10 | 11 | .. seealso:: 12 | 13 | :ref:`set cmdtrace ` 14 | -------------------------------------------------------------------------------- /docs/commands/show/confirm.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; confirm 2 | .. _show_confirm: 3 | 4 | Show Confirm 5 | ------------ 6 | 7 | **show confirm** 8 | 9 | Show confirmation of potentially dangerous operations 10 | 11 | .. seealso:: 12 | 13 | :ref:`show confirm ` 14 | -------------------------------------------------------------------------------- /docs/commands/show/dbg_trepan.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; dbg_trepan 2 | .. _show_dbg_trepan: 3 | 4 | Show Dbg_trepan 5 | --------------- 6 | Show debugging the debugger 7 | 8 | .. seealso:: 9 | 10 | :ref:`set dbg_trepan ` 11 | -------------------------------------------------------------------------------- /docs/commands/show/different.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; different 2 | .. _show_different: 3 | 4 | Show Different 5 | -------------- 6 | Show consecutive stops on different file/line positions 7 | 8 | .. seealso:: 9 | 10 | :ref:`set different ` 11 | -------------------------------------------------------------------------------- /docs/commands/show/events.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; events 2 | .. _show_events: 3 | 4 | Show Events 5 | ----------- 6 | **show events** 7 | 8 | Show the kinds of events the debugger will stop on. 9 | 10 | .. seealso:: 11 | 12 | :ref:`set events ` 13 | -------------------------------------------------------------------------------- /docs/commands/show/flush.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; flush 2 | .. _show_flush: 3 | 4 | Show Flush 5 | ------------ 6 | 7 | **show flush** 8 | 9 | Show if we are flushing output after each write 10 | 11 | .. seealso:: 12 | 13 | :ref:`set flush ` 14 | -------------------------------------------------------------------------------- /docs/commands/show/highlight.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; highlight 2 | .. _show_highlight: 3 | 4 | Show Highlight 5 | -------------- 6 | **show highlight** 7 | 8 | Show whether we use terminal highlighting. 9 | 10 | .. seealso:: 11 | 12 | :ref:`set highlight ` 13 | -------------------------------------------------------------------------------- /docs/commands/show/listsize.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; listsize 2 | .. _show_listsize: 3 | 4 | Show Listsize 5 | ------------- 6 | 7 | **show listsize** 8 | 9 | Show the number lines printed in a :ref:`list ` command by default 10 | 11 | .. seealso:: 12 | 13 | :ref:`set listsize ` 14 | -------------------------------------------------------------------------------- /docs/commands/show/maxstring.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; maxstring 2 | .. _show_maxstring: 3 | 4 | Show Maxstring 5 | -------------- 6 | 7 | **show maxstring** 8 | 9 | Show maximum string length to use in string-oriented output 10 | 11 | .. seealso:: 12 | 13 | :ref:`set maxstring ` 14 | -------------------------------------------------------------------------------- /docs/commands/show/skip.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; skip 2 | .. _show_skip: 3 | 4 | Show Skip 5 | --------- 6 | 7 | **show skip** 8 | 9 | Show whether debugger steps over lines which define functions and classes 10 | 11 | .. seealso:: 12 | :ref:`set skip ` 13 | -------------------------------------------------------------------------------- /docs/commands/show/style.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; style 2 | .. _show_style: 3 | 4 | Show Style 5 | ---------- 6 | **show style** *pygments-style* 7 | 8 | Show the pygments style used in formatting 256-color terminal text. 9 | 10 | .. seealso:: 11 | 12 | :ref:`set style ` and :ref:`show highlight ` 13 | -------------------------------------------------------------------------------- /docs/commands/show/trace.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; trace 2 | .. _show_trace: 3 | 4 | Show Trace 5 | ---------- 6 | 7 | **show trace** 8 | 9 | Show event tracing. 10 | 11 | .. seealso:: 12 | 13 | :ref:`set trace `, :ref:`show events ` 14 | -------------------------------------------------------------------------------- /docs/commands/show/width.rst: -------------------------------------------------------------------------------- 1 | .. index:: show; width 2 | .. _show_width: 3 | 4 | Show Width 5 | ---------- 6 | 7 | **show width** 8 | 9 | Show the number of characters the debugger thinks are in a line. 10 | 11 | .. seealso:: 12 | 13 | :ref:`set width ` 14 | -------------------------------------------------------------------------------- /docs/commands/stack.rst: -------------------------------------------------------------------------------- 1 | Stack 2 | ===== 3 | 4 | Examining the call stack. 5 | 6 | The call stack is made up of stack frames. The debugger assigns 7 | numbers to stack frames counting from zero for the innermost 8 | (currently executing) frame. 9 | 10 | At any time the debugger identifies one frame as the "selected" frame. 11 | Variable lookups are done with respect to the selected frame. When 12 | the program being debugged stops, the debugger selects the innermost 13 | frame. The commands below can be used to select other frames by 14 | number or address. 15 | 16 | 17 | .. toctree:: 18 | :maxdepth: 1 19 | 20 | stack/backtrace 21 | stack/frame 22 | stack/up 23 | stack/down 24 | -------------------------------------------------------------------------------- /docs/commands/stack/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be handled by the 2 | # by the main (parent) Makefile. So reissue make from there. 3 | .PHONY: html 4 | 5 | html: 6 | $(MAKE) -C ../.. $@ 7 | 8 | %: html 9 | $(MAKE) -C ../.. $@ 10 | -------------------------------------------------------------------------------- /docs/commands/stack/backtrace.rst: -------------------------------------------------------------------------------- 1 | .. index:: backtrace 2 | .. _backtrace: 3 | 4 | Backtrace (show call-stack) 5 | --------------------------- 6 | 7 | **backtrace** [*options*] [*count*] 8 | 9 | Print backtrace of all stack frames, or innermost *count* frames. 10 | 11 | With a negative argument, print outermost -*count* frames. 12 | 13 | An arrow indicates the 'current frame'. The current frame determines 14 | the context used for many debugger commands such as expression 15 | evaluation or source-line listing. 16 | 17 | *opts* are: 18 | 19 | -d | --deparse - show deparsed call position 20 | -s | --source - show source code line 21 | -f | --full - locals of each frame 22 | -h | --help - give this help 23 | 24 | 25 | Examples: 26 | +++++++++ 27 | 28 | :: 29 | 30 | backtrace # Print a full stack trace 31 | backtrace 2 # Print only the top two entries 32 | backtrace -1 # Print a stack trace except the initial (least recent) call. 33 | backtrace -s # show source lines in listing 34 | backtrace -d # show deparsed source lines in listing 35 | backtrace -f # show with locals 36 | backtrace -df # show with deparsed calls and locals 37 | backtrace --deparse --full # same as above 38 | 39 | .. seealso:: 40 | 41 | :ref:`frame `, :ref:`info locals `, :ref:`deparse ` and :ref:`list `. 42 | -------------------------------------------------------------------------------- /docs/commands/stack/down.rst: -------------------------------------------------------------------------------- 1 | .. index:: down 2 | .. _down: 3 | 4 | Down (relative frame motion towards a more-recent frame) 5 | -------------------------------------------------------- 6 | 7 | **down** [*count*] 8 | 9 | Move the current frame down in the stack trace (to a newer frame). 0 10 | is the most recent frame. If no count is given, move down 1. 11 | 12 | .. seealso:: 13 | 14 | :ref:`up ` and :ref:`frame `. 15 | -------------------------------------------------------------------------------- /docs/commands/stack/up.rst: -------------------------------------------------------------------------------- 1 | .. index:: up 2 | .. _up: 3 | 4 | Up (relative frame motion towards a less-recent frame) 5 | ------------------------------------------------------ 6 | 7 | **up** [*count*] 8 | 9 | Move the current frame up in the stack trace (to an older frame). 0 is 10 | the most recent frame. If no count is given, move up 1. 11 | 12 | .. seealso:: 13 | 14 | :ref:`down ` and :ref:`frame `. 15 | -------------------------------------------------------------------------------- /docs/commands/support.rst: -------------------------------------------------------------------------------- 1 | Support 2 | ======= 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | 7 | support/alias 8 | support/bpython 9 | support/debug 10 | support/help 11 | support/ipython 12 | support/macro 13 | support/python 14 | support/source 15 | support/unalias 16 | -------------------------------------------------------------------------------- /docs/commands/support/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be handled by the 2 | # by the main (parent) Makefile. So reissue make from there. 3 | .PHONY: html 4 | 5 | html: 6 | $(MAKE) -C ../.. $@ 7 | 8 | %: html 9 | $(MAKE) -C ../.. $@ 10 | -------------------------------------------------------------------------------- /docs/commands/support/alias.rst: -------------------------------------------------------------------------------- 1 | .. index:: alias 2 | .. _alias: 3 | 4 | Alias (add debugger command alias) 5 | ---------------------------------- 6 | 7 | **alias** *alias-name* *debugger-command* 8 | 9 | Add alias *alias-name* for a debugger command *debugger-comand*. 10 | 11 | Add an alias when you want to use a command abbreviation for a command 12 | that would otherwise be ambiguous. For example, by default we make ``s`` 13 | be an alias of ``step`` to force it to be used. Without the alias, ``s`` 14 | might be ``step``, ``show``, or ``set`` among others 15 | 16 | Example: 17 | ++++++++ 18 | 19 | :: 20 | 21 | alias cat list # "cat myprog.py" is the same as "list myprog.py" 22 | alias s step # "s" is now an alias for "step". 23 | # The above example is done by default. 24 | 25 | .. seealso:: 26 | 27 | :ref:`unalias ` and :ref:`show alias `. 28 | -------------------------------------------------------------------------------- /docs/commands/support/bpython.rst: -------------------------------------------------------------------------------- 1 | .. index:: bpython 2 | .. _bpython: 3 | 4 | BPython (go into a bpython shell) 5 | --------------------------------- 6 | 7 | **bpython** [*-d* ] 8 | 9 | .. note:: 10 | 11 | this command is available only if bpython is installed 12 | 13 | Run Python as a command subshell. The *sys.ps1* prompt will be set to 14 | ``trepan2 >>>``. 15 | 16 | If *-d* is passed, you can access debugger state via local variable 17 | *debugger*. 18 | 19 | To issue a debugger command use function *dbgr()*. For example: 20 | 21 | :: 22 | 23 | dbgr('info program') 24 | 25 | .. seealso:: 26 | 27 | :ref:`python `, and :ref:`ipython `. 28 | -------------------------------------------------------------------------------- /docs/commands/support/debug.rst: -------------------------------------------------------------------------------- 1 | .. index:: debug 2 | .. _debug: 3 | 4 | Debug (recursively debug an expression) 5 | --------------------------------------- 6 | 7 | **debug** *python-expression* 8 | 9 | Enter a nested debugger that steps through the *python-expression* argument 10 | which is an arbitrary expression to be executed the current 11 | environment. 12 | -------------------------------------------------------------------------------- /docs/commands/support/help.rst: -------------------------------------------------------------------------------- 1 | .. index:: help 2 | .. _help: 3 | 4 | Help (Won't you please help me if you can) 5 | ------------------------------------------ 6 | 7 | **help** [*command* [*subcommand*]|*expression*] 8 | 9 | Without argument, print the list of available debugger commands. 10 | 11 | When an argument is given, it is first checked to see if it is command 12 | name. 13 | 14 | If the argument is an expression or object name, you get the same 15 | help that you would get inside a Python shell running the built-in 16 | *help()* command. 17 | 18 | If the environment variable *$PAGER* is defined, the file is 19 | piped through that command. You'll notice this only for long help 20 | output. 21 | 22 | Some commands like `info`, `set`, and `show` can accept an 23 | additional subcommand to give help just about that particular 24 | subcommand. For example `help info line` give help about the 25 | info line command. 26 | 27 | .. seealso:: 28 | 29 | :ref:`examine ` and :ref:`whatis `. 30 | -------------------------------------------------------------------------------- /docs/commands/support/ipython.rst: -------------------------------------------------------------------------------- 1 | .. index:: ipython 2 | .. _ipython: 3 | 4 | IPython (go into an IPython shell) 5 | ---------------------------------- 6 | 7 | **ipython** [*-d* ] 8 | 9 | .. note:: 10 | 11 | this command is available only if ipython is installed 12 | 13 | Run Python as a command subshell. The *sys.ps1* prompt will be set to 14 | ``trepan3k >>>``. 15 | 16 | If *-d* is passed, you can access debugger state via local variable 17 | *debugger*. 18 | 19 | To issue a debugger command use function *dbgr()*. For example: 20 | 21 | :: 22 | 23 | dbgr('info program') 24 | 25 | .. seealso:: 26 | 27 | :ref:`python `, and :ref:`bpython `. 28 | -------------------------------------------------------------------------------- /docs/commands/support/python.rst: -------------------------------------------------------------------------------- 1 | .. index:: python 2 | .. _python: 3 | 4 | Python (go into a Python shell) 5 | ------------------------------- 6 | 7 | **python** [*-d* ] 8 | 9 | Run Python as a command subshell. The *sys.ps1* prompt will be set to 10 | ``trepan3k >>>``. 11 | 12 | If *-d* is passed, you can access debugger state via local variable 13 | *debugger*. 14 | 15 | To issue a debugger command use function *dbgr()*. For example: 16 | 17 | :: 18 | 19 | dbgr('info program') 20 | 21 | .. seealso:: 22 | 23 | :ref:`eval `, 24 | :ref:`set autoeval `, 25 | :ref:`ipython `, and :ref:`bpython `. 26 | -------------------------------------------------------------------------------- /docs/commands/support/source.rst: -------------------------------------------------------------------------------- 1 | .. index:: source 2 | .. _source: 3 | 4 | Source (Read and run debugger commands from a file) 5 | --------------------------------------------------- 6 | 7 | **source** [**-v**][**-Y**|**-N**][**-c**] *file* 8 | 9 | Read debugger commands from a file named *file*. Optional *-v* switch 10 | (before the filename) causes each command in *file* to be echoed as it 11 | is executed. Option *-Y* sets the default value in any confirmation 12 | command to be "yes" and *-N* sets the default value to "no". 13 | 14 | Note that the command startup file `.trepanc` is read automatically 15 | via a *source* command the debugger is started. 16 | 17 | An error in any command terminates execution of the command file 18 | unless option `-c` is given. 19 | -------------------------------------------------------------------------------- /docs/commands/support/unalias.rst: -------------------------------------------------------------------------------- 1 | .. index:: unalias 2 | .. _unalias: 3 | 4 | Unalias (remove debugger command alias) 5 | --------------------------------------- 6 | 7 | **unalias** *alias-name* 8 | 9 | Remove alias *alias-name*. 10 | 11 | .. seealso:: 12 | 13 | :ref:`alias `. 14 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. trepan documentation master file, created by 2 | sphinx-quickstart on Mon Jun 1 21:23:13 2015. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | trepan3k - a gdb-like debugger for Python 3 7 | =========================================== 8 | 9 | trepan3k is a gdb-like debugger for Python. It is a rewrite of *pdb* 10 | from the ground up. It is aimed for people who care about high-quality 11 | debuggers 12 | 13 | A command-line interface (CLI) is provided as well as an remote access 14 | interface over TCP/IP. 15 | 16 | See the Tutorial_ for ways to enter the debugger. See ipython-trepan_ for using this 17 | in *ipython* or an *ipython notebook*. 18 | 19 | This package is for Python 3. See trepan2_ for the same 20 | code modified to work with Python 2. 21 | 22 | An Emacs interface is available via realgud_. 23 | 24 | .. toctree:: 25 | :maxdepth: 2 26 | 27 | features 28 | install 29 | options 30 | entry-exit 31 | syntax 32 | commands 33 | 34 | Indices and tables 35 | ================== 36 | 37 | * :ref:`genindex` 38 | * :ref:`search` 39 | 40 | .. _Tutorial: https://python3-trepan.readthedocs.io/en/latest/entry-exit.html 41 | .. _ipython-trepan: https://github.com/rocky/ipython-trepan 42 | .. _trepan2: https://pypi.python.org/pypi/trepan2 43 | .. _pydbgr: https://pypi.python.org/pypi/pydbgr 44 | .. _realgud: https://elpa.gnu.org/packages/realgud.html 45 | -------------------------------------------------------------------------------- /docs/manpages/trepan3kc.rst: -------------------------------------------------------------------------------- 1 | .. _trepan3kc: 2 | 3 | trepan3kc (Python3 client to connect to remote trepan session) 4 | ############################################################## 5 | 6 | Synopsis 7 | -------- 8 | 9 | **trepan3kc** [ *debugger-options* ] [ \-- ] [ *python-script* [ *script-options* ...]] 10 | 11 | 12 | Description 13 | ----------- 14 | 15 | Run the Python3 trepan debugger client to connect to an existing out-of-process Python *trepan* session 16 | 17 | 18 | Options 19 | ------- 20 | 21 | :-h, \--help: 22 | Show the help message and exit 23 | 24 | :-x, \--trace: 25 | Show lines before executing them. 26 | 27 | :-H *IP-OR-HOST*, \--host= *IP-OR-HOST*: 28 | connect to *IP* or *HOST* 29 | 30 | :-P *NUMBER, \--port= *NUMBER*: 31 | Use TCP port number NUMBER for out-of-process connections. 32 | 33 | :\--pid=*NUMBER*: 34 | Use PID to get FIFO names for out-of-process connections. 35 | 36 | See also 37 | -------- 38 | 39 | Full Documentation is available at http://python3-trepan.readthedocs.org 40 | -------------------------------------------------------------------------------- /docs/syntax.rst: -------------------------------------------------------------------------------- 1 | Command Syntax 2 | ************** 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | 7 | syntax/arange 8 | syntax/command 9 | syntax/examples 10 | syntax/filename 11 | syntax/location 12 | syntax/range 13 | syntax/suffixes 14 | -------------------------------------------------------------------------------- /docs/syntax/arange.rst: -------------------------------------------------------------------------------- 1 | .. index:: syntax; arange 2 | .. _syntax_arange: 3 | 4 | Syntax for Address Ranges 5 | ========================= 6 | 7 | Address ranges are used in the :ref:`disassemble ` command. It is like a 8 | range, but we allow addresses. 9 | 10 | An address range is in one of the following forms: 11 | 12 | :: 13 | 14 | location # starting line only 15 | first, last # starting and ending line 16 | , last # ending line only 17 | 18 | 19 | See :ref:` location ` for a full description of a location. 20 | 21 | *first* and *last* can also be line specifications (:ref:`linespec 22 | `), but they also may be a number or address 23 | (bytecode offset). And finally *last* can be an (line number) offset. 24 | 25 | A number is just a decimal number. An offset is a number prefaced with "+" and 26 | indicates the number to increment the line number found in *first*. 27 | 28 | Address-Range Examples 29 | ---------------------- 30 | 31 | :: 32 | 33 | *5 # start from bytecode offset 5 of current file 34 | *5 , # Same as above. 35 | foo.py:*5 # start from bytecode offset 5 of file foo.py 36 | 37 | 38 | .. seealso:: 39 | 40 | :ref:`location `, :ref:`linespec ` 41 | -------------------------------------------------------------------------------- /docs/syntax/examples.rst: -------------------------------------------------------------------------------- 1 | Command examples 2 | ================ 3 | 4 | :: 5 | 6 | # This line does nothing. It is a comment. Useful in debugger command files. 7 | # This line also does nothing. 8 | s # by default, this is an alias for the "step" command 9 | info program;;list # error no command 'program;;list' 10 | info program ;; list # Runs two commands "info program" and "list" 11 | 12 | .. seealso:: 13 | 14 | :ref:`macro `, :ref:`alias `, :ref:`python `, :ref:`set auto eval `, :ref:`info macro `, and the *show* variants of the above *set* commands. 15 | -------------------------------------------------------------------------------- /docs/syntax/filename.rst: -------------------------------------------------------------------------------- 1 | Syntax for Indicating a Filename 2 | ================================ 3 | 4 | Filename Examples: 5 | ------------------ 6 | 7 | :: 8 | 9 | file.py => file.py 10 | /tmp/file.py => /tmp/file.py 11 | "C:file.py" => C:file.py # For Microsoft OS's 12 | 'C:file.py' => same as above 13 | '''C:file.py''' => same as above 14 | 'C:\file.py' => C:\file.py # For Microsoft OS's 15 | '\new.py' => \new.py 16 | 'my file.py' => 'my file.py' 17 | -------------------------------------------------------------------------------- /docs/syntax/suffixes.rst: -------------------------------------------------------------------------------- 1 | .. _syntax_suffixes: 2 | 3 | Command suffixes which have special meaning 4 | =========================================== 5 | 6 | Some commands like `step`, or `list` do different things when an 7 | alias to the command ends in a particular suffix like `>`. 8 | 9 | Here are a list of commands and the special suffixes: 10 | 11 | ======= ====== 12 | command suffix 13 | ======= ====== 14 | list `>` 15 | step `+`, `-`, `<`, `>` 16 | next `+`, `-`, `<`, `>` 17 | quit `!` 18 | kill `!` 19 | eval `?` 20 | ======= ====== 21 | 22 | 23 | See the help on the specific commands listed above for the specific 24 | meaning of the suffix. 25 | -------------------------------------------------------------------------------- /make-check-filter.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Use this to cut out the crud from make check. 3 | # Use like this: 4 | # make check 2>&1 | python ../make-check-filter.py 5 | # See Makefile.am 6 | import re, sys 7 | pats = '|'.join( 8 | ["^(?:running", 9 | 'writing', 10 | "reading", 11 | ]) + ')' 12 | # puts pats 13 | skip_re = re.compile(pats) 14 | 15 | for line in sys.stdin: 16 | if not skip_re.match(line): 17 | print(line.rstrip('\n')) 18 | pass 19 | pass 20 | -------------------------------------------------------------------------------- /requirements-dev.txt: -------------------------------------------------------------------------------- 1 | flake8 2 | pytest 3 | # rst2html 4 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # This file is for CircleCI until I can figure 2 | # out how to get it to do "pip install -e" 3 | # The "pygments" version is not quite right 4 | # And the xdis version is missing 5 | columnize >= 0.3.10 6 | pyficache >= 2.3.0, 7 | pygments >= 2.2.0 8 | spark_parser 9 | tracer >= 0.3.2 10 | flake8 11 | uncompyle6 >= 3.9.2 12 | # Get these from github 13 | # pyficache >= 2.1.0, < 2.2.0 14 | # xdis >= 4.7.0 15 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import sys 3 | 4 | from setuptools import find_packages, setup 5 | 6 | SYS_VERSION = sys.version_info[0:2] 7 | if not ((3, 1) <= SYS_VERSION < (3, 14)): 8 | mess = "Python Versions 3.0 to 3.13 are supported only in this package." 9 | if (2, 4) <= SYS_VERSION <= (2, 7): 10 | mess += "\nFor your Python, version %s, See trepan2" % sys.version[0:3] 11 | elif SYS_VERSION < (2, 4): 12 | mess += "\nFor your Python, version %s, see pydb" % sys.version[0:3] 13 | print(mess) 14 | raise Exception(mess) 15 | 16 | __import__("pkg_resources") 17 | 18 | packages = find_packages() 19 | 20 | setup( 21 | data_files=[ 22 | ( 23 | "trepan/processor/command/help", 24 | [ 25 | "trepan/processor/command/help/arange.rst", 26 | "trepan/processor/command/help/command.rst", 27 | "trepan/processor/command/help/examples.rst", 28 | "trepan/processor/command/help/filename.rst", 29 | "trepan/processor/command/help/location.rst", 30 | "trepan/processor/command/help/range.rst", 31 | "trepan/processor/command/help/suffixes.rst", 32 | ], 33 | ) 34 | ], 35 | packages=packages, 36 | ) 37 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be forwarded to the 2 | # to top-level irectories 3 | PHONY=check all 4 | all: check 5 | 6 | %: 7 | $(MAKE) -C .. $@ 8 | -------------------------------------------------------------------------------- /test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/python3-trepan/df7fee9dcc64ae9f7293a88fe1cc1bf02677e265/test/__init__.py -------------------------------------------------------------------------------- /test/data/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be forwarded to the 2 | # to top-level irectories 3 | PHONY=check all 4 | all: check 5 | 6 | %: 7 | $(MAKE) -C ../.. $@ 8 | -------------------------------------------------------------------------------- /test/data/highlight-310.right: -------------------------------------------------------------------------------- 1 | (gcd.py:1): 2 | -> 1 #!/usr/bin/env python3 3 | Set basename is on. 4 | Set event is on. 5 | Set stopping is off. 6 | output set to not use terminal escape sequences 7 | output set to not use terminal escape sequences 8 | output set to not use terminal escape sequences 9 | output set to not use terminal escape sequences 10 | output set for terminal with escape sequences for a dark background 11 | output set for terminal with escape sequences for a light background 12 | trepan3k: That's all, folks... 13 | -------------------------------------------------------------------------------- /test/data/highlight-38.right: -------------------------------------------------------------------------------- 1 | (gcd.py:2): 2 | -> 2 """Greatest Common Divisor 3 | Set basename is on. 4 | Set event is on. 5 | Set stopping is off. 6 | output set to not use terminal escape sequences 7 | output set to not use terminal escape sequences 8 | output set to not use terminal escape sequences 9 | output set to not use terminal escape sequences 10 | output set for terminal with escape sequences for a dark background 11 | output set for terminal with escape sequences for a light background 12 | trepan3k: That's all, folks... 13 | -------------------------------------------------------------------------------- /test/data/highlight-pyp35.right: -------------------------------------------------------------------------------- 1 | (gcd.py:2): 2 | -> 2 """Greatest Common Divisor 3 | Set basename is on. 4 | Set event is on. 5 | Set stopping is off. 6 | output set to not use terminal escape sequences 7 | output set to not use terminal escape sequences 8 | output set to not use terminal escape sequences 9 | output set to not use terminal escape sequences 10 | output set for terminal with escape sequences for a dark background 11 | output set for terminal with escape sequences for a light background 12 | trepan3k: That's all, folks... 13 | -------------------------------------------------------------------------------- /test/data/highlight-pypy.right: -------------------------------------------------------------------------------- 1 | (gcd.py:2): 2 | -> 2 """Greatest Common Divisor 3 | Set basename is on. 4 | Set event is on. 5 | Set stopping is off. 6 | output set to not use terminal escape sequences 7 | output set to not use terminal escape sequences 8 | output set to not use terminal escape sequences 9 | output set to not use terminal escape sequences 10 | output set for terminal with escape sequences for a dark background 11 | output set for terminal with escape sequences for a light background 12 | trepan3k: That's all, folks... 13 | -------------------------------------------------------------------------------- /test/data/highlight.cmd: -------------------------------------------------------------------------------- 1 | # 2 | # Test of the debugger 'highlight' command 3 | # 4 | set basename on 5 | set trace on 6 | set skip off 7 | show highlight 8 | set highlight 9 | set highlight off 10 | set highlight plain 11 | set highlight dark 12 | set highlight light 13 | quit! 14 | quit! 15 | -------------------------------------------------------------------------------- /test/data/highlight.right: -------------------------------------------------------------------------------- 1 | (gcd.py:10): 2 | -> 10 """ 3 | Set basename is on. 4 | Set event is on. 5 | Set stopping is off. 6 | output set to not use terminal escape sequences 7 | output set to not use terminal escape sequences 8 | output set to not use terminal escape sequences 9 | output set to not use terminal escape sequences 10 | output set for terminal with escape sequences for a dark background 11 | output set for terminal with escape sequences for a light background 12 | trepan3k: That's all, folks... 13 | -------------------------------------------------------------------------------- /test/data/macro-pypy.right: -------------------------------------------------------------------------------- 1 | (gcd.py:2): 2 | -> 2 """Greatest Common Divisor 3 | Set basename is off. 4 | Set event is on. 5 | Set stopping is off. 6 | No macros defined. 7 | Macro "foo" defined. 8 | 1 #!/usr/bin/env python3 9 | 2 -> """Greatest Common Divisor 10 | 3 11 | 4 Some characterstics of this program used for testing check_args() does 12 | 5 not have a 'return' statement. 13 | 6 14 | 7 check_args() raises an uncaught exception when given the wrong number 15 | 8 of parameters. 16 | 9 17 | 10 """ 18 | foo 19 | 20 | Macro "bar" defined. 21 | 1 #!/usr/bin/env python3 22 | 2 -> """Greatest Common Divisor 23 | 3 24 | 4 Some characterstics of this program used for testing check_args() does 25 | 5 not have a 'return' statement. 26 | 6 27 | 7 check_args() raises an uncaught exception when given the wrong number 28 | 8 of parameters. 29 | 9 30 | 10 """ 31 | bar foo 32 | 33 | bar: 34 | ---- 35 | lambda count: 'list %s' % count 36 | foo: 37 | ---- 38 | lambda: 'list' 39 | trepan3k: That's all, folks... 40 | -------------------------------------------------------------------------------- /test/data/macro-pypy35.right: -------------------------------------------------------------------------------- 1 | # 2 | # Test of the debugger 'macro' command 3 | # 4 | set basename off 5 | set trace on 6 | set skip off 7 | info macro 8 | # macro foo 9 | macro foo lambda: 'list' 10 | foo 11 | info macro 12 | macro bar lambda count: 'list %s' % count 13 | bar 1 14 | # macro baz 'list 5' 15 | info macro 16 | info macro * 17 | quit! 18 | -------------------------------------------------------------------------------- /test/data/macro.cmd: -------------------------------------------------------------------------------- 1 | # 2 | # Test of the debugger 'macro' command 3 | # 4 | set basename off 5 | set trace on 6 | set skip off 7 | info macro 8 | # macro foo 9 | macro foo lambda: 'list' 10 | foo 11 | info macro 12 | macro bar lambda count: 'list %s' % count 13 | bar 1 14 | # macro baz 'list 5' 15 | info macro 16 | info macro * 17 | quit! 18 | -------------------------------------------------------------------------------- /test/data/macro.right: -------------------------------------------------------------------------------- 1 | (gcd.py:10): 2 | -> 10 """ 3 | Set basename is off. 4 | Set event is on. 5 | Set stopping is off. 6 | No macros defined. 7 | Macro "foo" defined. 8 | 5 not have a 'return' statement. 9 | 6 10 | 7 check_args() raises an uncaught exception when given the wrong number 11 | 8 of parameters. 12 | 9 13 | 10 -> """ 14 | 11 import sys 15 | 12 16 | 13 def check_args(): 17 | 14 if len(sys.argv) != 3: 18 | foo 19 | 20 | Macro "bar" defined. 21 | 1 #!/usr/bin/env python3 22 | 2 """Greatest Common Divisor 23 | 3 24 | 4 Some characterstics of this program used for testing check_args() does 25 | 5 not have a 'return' statement. 26 | 6 27 | 7 check_args() raises an uncaught exception when given the wrong number 28 | 8 of parameters. 29 | 9 30 | 10 -> """ 31 | 11 import sys 32 | bar foo 33 | 34 | bar: 35 | ---- 36 | lambda count: 'list %s' % count 37 | foo: 38 | ---- 39 | lambda: 'list' 40 | trepan3k: That's all, folks... 41 | -------------------------------------------------------------------------------- /test/data/noscript-pypy.right: -------------------------------------------------------------------------------- 1 | trepan3k: That's all, folks... 2 | -------------------------------------------------------------------------------- /test/data/noscript.cmd: -------------------------------------------------------------------------------- 1 | # Add more later... 2 | # list 3 | 4 | quit! 5 | -------------------------------------------------------------------------------- /test/data/noscript.right: -------------------------------------------------------------------------------- 1 | trepan3k: That's all, folks... 2 | -------------------------------------------------------------------------------- /test/data/step-310.right: -------------------------------------------------------------------------------- 1 | (gcd.py:1): 2 | -> 1 #!/usr/bin/env python3 3 | Set basename is on. 4 | Set event is on. 5 | Set stopping is off. 6 | Set confirmation is off. 7 | line - gcd.py:2 8 | (gcd.py:2): 9 | -- 2 """Greatest Common Divisor 10 | 2 -> """Greatest Common Divisor 11 | Set stopping is on. 12 | line - gcd.py:11 13 | (gcd.py:11): 14 | -- 11 import sys 15 | 11 -> import sys 16 | Set stopping is off. 17 | line - gcd.py:13 18 | line - gcd.py:26 19 | line - gcd.py:40 20 | (gcd.py:40): 21 | -- 40 if __name__=='__main__': 22 | 40 -> if __name__=='__main__': 23 | trepan3k: That's all, folks... 24 | -------------------------------------------------------------------------------- /test/data/step-311.right: -------------------------------------------------------------------------------- 1 | (gcd.py:1): 2 | -> 1 #!/usr/bin/env python3 3 | Set basename is on. 4 | Set event is on. 5 | Set stopping is off. 6 | Set confirmation is off. 7 | line - gcd.py:2 8 | (gcd.py:2): 9 | -- 2 """Greatest Common Divisor 10 | 2 -> """Greatest Common Divisor 11 | Set stopping is on. 12 | line - gcd.py:11 13 | (gcd.py:11): 14 | -- 11 import sys 15 | 11 -> import sys 16 | Set stopping is off. 17 | line - gcd.py:14 18 | line - gcd.py:27 19 | line - gcd.py:42 20 | (gcd.py:42): 21 | -- 42 if __name__ == "__main__": 22 | 42 -> if __name__ == "__main__": 23 | trepan3k: That's all, folks... 24 | -------------------------------------------------------------------------------- /test/data/step-38.right: -------------------------------------------------------------------------------- 1 | (gcd.py:2): 2 | -> 2 """Greatest Common Divisor 3 | Set basename is on. 4 | Set event is on. 5 | Set stopping is off. 6 | Set confirmation is off. 7 | line - gcd.py:2 8 | line - gcd.py:11 9 | (gcd.py:11): 10 | -- 11 import sys 11 | 11 -> import sys 12 | Set stopping is on. 13 | line - gcd.py:13 14 | line - gcd.py:26 15 | line - gcd.py:40 16 | (gcd.py:40): 17 | -- 40 if __name__=='__main__': 18 | 40 -> if __name__=='__main__': 19 | Set stopping is off. 20 | line - gcd.py:41 21 | (gcd.py:41): 22 | -- 41 check_args() 23 | 41 -> check_args() 24 | trepan3k: That's all, folks... 25 | -------------------------------------------------------------------------------- /test/data/step-pypy.right: -------------------------------------------------------------------------------- 1 | (gcd.py:2): 2 | -> 2 """Greatest Common Divisor 3 | Set basename is on. 4 | Set event is on. 5 | Set stopping is off. 6 | Set confirmation is off. 7 | line - gcd.py:2 8 | line - gcd.py:11 9 | (gcd.py:11): 10 | -- 11 import sys 11 | 11 -> import sys 12 | Set stopping is on. 13 | call - :1044 14 | (/home/rocky/.pyenv/versions/pypy3.5-5.8.0/lib-python/3/importlib/_bootstrap.py:1044 remapped ): __import__ 15 | -> 1044 def __import__(name, globals=None, locals=None, fromlist=(), level=0): 16 | 17 | ** /src/external-vcs/github/rocky/python3-trepan/test/integration/../data/step.cmd:13: Error in source command file: 18 | ** No file importlib._bootstrap found; using "deparse" command instead to show source 19 | *instruction:* 1055 0 LOAD_FAST 'level' 20 | if level == 0: 21 | ----- 22 | Set stopping is off. 23 | line - :1055 24 | (/home/rocky/.pyenv/versions/pypy3.5-5.8.0/lib-python/3/importlib/_bootstrap.py:1055 remapped ): __import__ 25 | -- 1055 if level == 0: 26 | 27 | ** /src/external-vcs/github/rocky/python3-trepan/test/integration/../data/step.cmd:16: Error in source command file: 28 | ** No file importlib._bootstrap found; using "deparse" command instead to show source 29 | *instruction:* 1055 0 LOAD_FAST 'level' 30 | if level == 0: 31 | ----- 32 | trepan3k: That's all, folks... 33 | -------------------------------------------------------------------------------- /test/data/step.cmd: -------------------------------------------------------------------------------- 1 | # 2 | # Test of the 'step' and skip 3 | # 4 | set basename on 5 | set trace on 6 | set skip off 7 | set confirm off 8 | set listsize 1 9 | step 10 | list 11 | set skip on 12 | step 13 | list 14 | set skip off 15 | step 16 | list 17 | quit! 18 | -------------------------------------------------------------------------------- /test/data/step.right: -------------------------------------------------------------------------------- 1 | (gcd.py:10): 2 | -> 10 """ 3 | Set basename is on. 4 | Set event is on. 5 | Set stopping is off. 6 | Set confirmation is off. 7 | line - gcd.py:10 8 | line - gcd.py:11 9 | (gcd.py:11): 10 | -- 11 import sys 11 | 11 -> import sys 12 | Set stopping is on. 13 | line - gcd.py:13 14 | line - gcd.py:26 15 | line - gcd.py:40 16 | (gcd.py:40): 17 | -- 40 if __name__=='__main__': 18 | 40 -> if __name__=='__main__': 19 | Set stopping is off. 20 | line - gcd.py:41 21 | (gcd.py:41): 22 | -- 41 check_args() 23 | 41 -> check_args() 24 | trepan3k: That's all, folks... 25 | -------------------------------------------------------------------------------- /test/example/eval.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tests to see how well we do with eval/exec 3 | """ 4 | 5 | # Deparsing will handle this 6 | eval_str = "1+2" 7 | x = eval(eval_str) 8 | print(x) 9 | 10 | # When deparsing does not work, looking at the string to the 11 | # eval call will work 12 | x = eval("3+4") 13 | 14 | exec("""y = 5; 15 | x += y 16 | """) 17 | print(x) 18 | 19 | # TODO: add an AST example. 20 | -------------------------------------------------------------------------------- /test/example/fib-exec.py: -------------------------------------------------------------------------------- 1 | def fib(x: int) -> int: 2 | if x <= 1: 3 | return 1 4 | return fib(x-1) + fib(x-2) 5 | 6 | exec("print(fib(2))") 7 | print("fib(2)= %d, fib(3) = %d, fib(4) = %d\n" % (fib(2), fib(3), fib(4))) 8 | -------------------------------------------------------------------------------- /test/example/fib.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | def fib(x): 4 | if x <= 1: 5 | return 1 6 | return fib(x-1) + fib(x-2) 7 | 8 | 9 | print("fib(2)= %d, fib(3) = %d, fib(4) = %d\n" % (fib(2), fib(3), fib(4))) 10 | -------------------------------------------------------------------------------- /test/example/gcd-dbgcall-explicit-profile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """Greatest Common Divisor 3 | 4 | Some characterstics of this program used for testing check_args() does 5 | not have a 'return' statement. 6 | 7 | check_args() raises an uncaught exception when given the wrong number 8 | of parameters. 9 | 10 | """ 11 | import sys 12 | 13 | from trepan.api import debug 14 | 15 | 16 | def check_args(): 17 | if len(sys.argv) != 3: 18 | # Rather than use sys.exit let's just raise an error 19 | raise Exception("Need to give two numbers") 20 | for i in range(2): 21 | try: 22 | sys.argv[i + 1] = int(sys.argv[i + 1]) 23 | except ValueError: 24 | print("** Expecting an integer, got: %s" % repr(sys.argv[i])) 25 | sys.exit(2) 26 | 27 | 28 | def gcd(a, b): 29 | """GCD. We assume positive numbers""" 30 | 31 | # Make: a <= b 32 | if a > b: 33 | (a, b) = (b, a) 34 | 35 | if a <= 0: 36 | debug(step_ignore=0) 37 | return None 38 | if a == 1 or b - a == 0: 39 | debug(start_opts={"startup-profile": True}) 40 | return a 41 | return gcd(b - a, a) 42 | 43 | 44 | if __name__ == "__main__": 45 | check_args() 46 | 47 | (a, b) = sys.argv[1:3] 48 | print("The GCD of %d and %d is %d" % (a, b, gcd(a, b))) 49 | -------------------------------------------------------------------------------- /test/example/gcd-dbgcall-noprofile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """Greatest Common Divisor 3 | 4 | Some characterstics of this program used for testing check_args() does 5 | not have a 'return' statement. 6 | 7 | check_args() raises an uncaught exception when given the wrong number 8 | of parameters. 9 | 10 | """ 11 | import sys 12 | 13 | from trepan.api import debug 14 | 15 | 16 | def check_args(): 17 | if len(sys.argv) != 3: 18 | # Rather than use sys.exit let's just raise an error 19 | raise Exception("Need to give two numbers") 20 | for i in range(2): 21 | try: 22 | sys.argv[i + 1] = int(sys.argv[i + 1]) 23 | except ValueError: 24 | print("** Expecting an integer, got: %s" % repr(sys.argv[i])) 25 | sys.exit(2) 26 | 27 | 28 | def gcd(a, b): 29 | """GCD. We assume positive numbers""" 30 | 31 | # Make: a <= b 32 | if a > b: 33 | (a, b) = (b, a) 34 | 35 | if a <= 0: 36 | debug(step_ignore=0) 37 | return None 38 | if a == 1 or b - a == 0: 39 | debug(start_opts={"startup-profile": False}) 40 | return a 41 | return gcd(b - a, a) 42 | 43 | 44 | if __name__ == "__main__": 45 | check_args() 46 | 47 | (a, b) = sys.argv[1:3] 48 | print("The GCD of %d and %d is %d" % (a, b, gcd(a, b))) 49 | -------------------------------------------------------------------------------- /test/example/gcd-dbgcall.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """Greatest Common Divisor 3 | 4 | Some characterstics of this program used for testing check_args() does 5 | not have a 'return' statement. 6 | 7 | check_args() raises an uncaught exception when given the wrong number 8 | of parameters. 9 | 10 | """ 11 | import sys 12 | 13 | from trepan.api import debug 14 | 15 | 16 | def check_args(): 17 | if len(sys.argv) != 3: 18 | # Rather than use sys.exit let's just raise an error 19 | raise Exception("Need to give two numbers") 20 | for i in range(2): 21 | try: 22 | sys.argv[i + 1] = int(sys.argv[i + 1]) 23 | except ValueError: 24 | print("** Expecting an integer, got: %s" % repr(sys.argv[i])) 25 | sys.exit(2) 26 | 27 | 28 | def gcd(a, b): 29 | """GCD. We assume positive numbers""" 30 | 31 | # Make: a <= b 32 | if a > b: 33 | (a, b) = (b, a) 34 | 35 | if a <= 0: 36 | debug(step_ignore=0) 37 | return None 38 | if a == 1 or b - a == 0: 39 | debug() 40 | return a 41 | return gcd(b - a, a) 42 | 43 | 44 | if __name__ == "__main__": 45 | check_args() 46 | 47 | (a, b) = sys.argv[1:3] 48 | print("The GCD of %d and %d is %d" % (a, b, gcd(a, b))) 49 | -------------------------------------------------------------------------------- /test/example/gcd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """Greatest Common Divisor 3 | 4 | Some characterstics of this program used for testing check_args() does 5 | not have a 'return' statement. 6 | 7 | check_args() raises an uncaught exception when given the wrong number 8 | of parameters. 9 | 10 | """ 11 | import sys 12 | 13 | 14 | def check_args(): 15 | if len(sys.argv) != 3: 16 | # Rather than use sys.exit let's just raise an error 17 | raise Exception(f"Need to give two numbers; got: {sys.argv}") 18 | for i in range(2): 19 | try: 20 | sys.argv[i + 1] = int(sys.argv[i + 1]) 21 | except ValueError: 22 | print(f"** Expecting an integer, got: {repr(sys.argv[i])}") 23 | sys.exit(2) 24 | pass 25 | 26 | 27 | def gcd(a, b): 28 | """GCD. We assume positive numbers""" 29 | 30 | # Make: a <= b 31 | if a > b: 32 | (a, b) = (b, a) 33 | pass 34 | 35 | if a <= 0: 36 | return None 37 | if a == 1 or b - a == 0: 38 | return a 39 | return gcd(b - a, a) 40 | 41 | 42 | if __name__ == "__main__": 43 | check_args() 44 | 45 | (a, b) = sys.argv[1:3] 46 | print(f"The GCD of {a} and {b} is {gcd(a, b)}") 47 | pass 48 | -------------------------------------------------------------------------------- /test/example/hanoi.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """Towers of Hanoi""" 3 | import sys 4 | 5 | def hanoi(n,a,b,c): 6 | if n-1 > 0: 7 | hanoi(n-1, a, c, b) 8 | print("Move disk %s to %s" % (a, b)) 9 | if n-1 > 0: 10 | hanoi(n-1, c, b, a) 11 | 12 | if __name__=='__main__': 13 | i_args=len(sys.argv) 14 | if i_args != 1 and i_args != 2: 15 | print("*** Need number of disks or no parameter") 16 | sys.exit(1) 17 | 18 | n=3 19 | 20 | if i_args > 1: 21 | try: 22 | n = int(sys.argv[1]) 23 | except ValueError as msg: 24 | print("** Expecting an integer, got: %s" % repr(sys.argv[1])) 25 | sys.exit(2) 26 | 27 | if n < 1 or n > 100: 28 | print("*** number of disks should be between 1 and 100") 29 | sys.exit(2) 30 | 31 | hanoi(n, "a", "b", "c") 32 | -------------------------------------------------------------------------------- /test/example/multi-line.py: -------------------------------------------------------------------------------- 1 | # This file deliberately has several statements on a line, so 2 | # so please spare me the lecture on standard Python style. 3 | x = 1; y = 2 4 | z = lambda x, y: x + y 5 | a = z(x, y); b = 6 6 | print(a, b) 7 | -------------------------------------------------------------------------------- /test/functional/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Functional tests. In contrast to most unit tesets, 3 | these tests work with a Trepan debugger object and traces or debugs some code with it, testing some particular 4 | aspect of debugging, such as the ability to step, skip or jump to debugged lines, hit breakpoints, etc. 5 | """ 6 | -------------------------------------------------------------------------------- /test/functional/example/jump.py: -------------------------------------------------------------------------------- 1 | # This code fragment what is embedded inside ../test_jump.py 2 | # We have it here to make it easy to test things when things go wrong. 3 | 4 | 5 | # commands are: 6 | # step 7 | # jump 13 # 6 + 7 8 | # continue 9 | ############################## # 3... 10 | x = 4 11 | x = 5 12 | x = 6 13 | z = 7 # NOQA 14 | -------------------------------------------------------------------------------- /test/functional/example/skip.py: -------------------------------------------------------------------------------- 1 | # This code fragment what is embedded inside ../test_skippy 2 | # We have it here to make it easy to test things when things go wrong. 3 | 4 | 5 | # commands are: 6 | # step 7 | # skip 8 | # continue 9 | ############################## 10 | x = 3 11 | x = 4 12 | y = 5 13 | y = 7 # NOQA 14 | ############################## 15 | # commands are: 16 | # step 17 | # skip 2 18 | # continue 19 | x = 7 20 | x = 8 21 | x = 9 22 | y = 10 # NOQA 23 | ############################## 24 | -------------------------------------------------------------------------------- /test/functional/example/step/step_computed_value.py: -------------------------------------------------------------------------------- 1 | # See that we can step with a computed count value 2 | # cmds = ["step 5-3", "continue"] 3 | # 4 | ############################## 5 | x = 5 6 | y = 6 7 | z = 7 8 | -------------------------------------------------------------------------------- /test/functional/test_jump.py: -------------------------------------------------------------------------------- 1 | """ 2 | Functional test of debugger "jump" command. 3 | """ 4 | 5 | import inspect 6 | from os.path import basename 7 | from pathlib import Path 8 | from test.functional.fn_helper import compare_output, strarray_setup 9 | 10 | # FIXME: try this: 11 | import pyficache 12 | 13 | absolute_path = str(Path(__file__).absolute()) 14 | short_name = basename(__file__) 15 | pyficache.update_cache(short_name) 16 | pyficache.file2file_remap.update({short_name: absolute_path}) 17 | 18 | 19 | def test_jump(): 20 | # See that we can jump with line number 21 | curframe = inspect.currentframe() 22 | cmds = ["step", "jump %d" % (curframe.f_lineno + 7), "continue"] 23 | d = strarray_setup(cmds) # 1 24 | d.core.start() # 2 25 | ############################## # 3... 26 | x = 4 27 | x = 5 28 | x = 6 29 | z = 7 # NOQA 30 | ############################## 31 | d.core.stop(options={"remove": True}) 32 | out = [ 33 | "-- x = 4", # x = 4 is shown in prompt, but not run. 34 | "-- x = 5", 35 | "-- z = 7 # NOQA", 36 | ] 37 | compare_output(out, d) 38 | assert x == 4, " x = 5 and 6 should have been skipped" 39 | return 40 | -------------------------------------------------------------------------------- /test/integration/.gitignore: -------------------------------------------------------------------------------- 1 | /.eggs 2 | -------------------------------------------------------------------------------- /test/integration/Makefile: -------------------------------------------------------------------------------- 1 | PYTHON ?= python 2 | 3 | PHONY=all check check-short clean test-integration test-integration-short 4 | 5 | #: Same as test-integration 6 | all, check, test: 7 | $(MAKE) test-integration 8 | 9 | #: Run integration tests 10 | test-integration: 11 | $(PYTHON) ./setup.py nosetests 12 | 13 | #: Run integration tests reduced verbosity 14 | check-short, test-integration-short: 15 | $(PYTHON) ./setup.py nosetests | \ 16 | $(PYTHON) ../../make-check-filter.py 17 | 18 | #: Remove derived files 19 | clean: 20 | -rm -fr *.egg-info || true 21 | 22 | # Whatever else it is you want to do, it should be forwarded to the 23 | # to top-level directories 24 | %: 25 | $(MAKE) -C ../.. $@ 26 | -------------------------------------------------------------------------------- /test/integration/setup.cfg: -------------------------------------------------------------------------------- 1 | [nosetests] 2 | # Our tests are also executable since they are allowed to be run 3 | # individually. By default nose excludes these. 4 | exe=on 5 | 6 | # Show individual tests run 7 | verbosity = 2 8 | 9 | # debug=nose.loader 10 | # pdb=on 11 | detailed-errors = on 12 | -------------------------------------------------------------------------------- /test/integration/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | distutils setup (setup.py). 5 | 6 | This is just boilerplate code, since we do like to try to keep data separate 7 | from code as much as possible. The customizable information really comes 8 | from file __pkginfo__.py. 9 | """ 10 | 11 | from setuptools import setup 12 | 13 | setup( 14 | test_suite = 'nose.collector', 15 | setup_requires = ['nose>=1.0'], 16 | name = 'testing_test', 17 | ) 18 | -------------------------------------------------------------------------------- /test/integration/test-general.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | "General integration tests" 3 | import unittest 4 | 5 | import helper as Mhelper 6 | from xdis import PYTHON_VERSION_TRIPLE 7 | 8 | 9 | class GeneralTests(unittest.TestCase): 10 | def test_step(self): 11 | """Test stepping, set skip, set trace""" 12 | if PYTHON_VERSION_TRIPLE >= (3, 8): 13 | right_template = "%s-38.right" 14 | else: 15 | right_template = None 16 | result = Mhelper.run_debugger( 17 | testname="step", 18 | dbgr_opts="--basename --highlight=plain", 19 | python_file="gcd.py", 20 | right_template=right_template, 21 | ) 22 | self.assertEqual(True, result, "debugger 'step' command comparision") 23 | return 24 | 25 | pass 26 | 27 | 28 | if __name__ == "__main__": 29 | unittest.main() 30 | -------------------------------------------------------------------------------- /test/integration/test_highlight.py: -------------------------------------------------------------------------------- 1 | "General integration tests" 2 | 3 | import sys 4 | 5 | import pytest 6 | from helper import run_debugger 7 | from xdis import PYTHON_VERSION_TRIPLE 8 | 9 | 10 | @pytest.mark.skipif( 11 | sys.platform == "win32", reason="Need to adjust for filesystem on MS Windows" 12 | ) 13 | def test_highlight(): 14 | """Test set/show highlight""" 15 | if PYTHON_VERSION_TRIPLE >= (3, 10): 16 | right_template = "%s-310.right" 17 | elif PYTHON_VERSION_TRIPLE >= (3, 8): 18 | right_template = "%s-38.right" 19 | else: 20 | right_template = None 21 | result = run_debugger( 22 | testname="highlight", 23 | dbgr_opts="--basename " + "--highlight=plain --nx", 24 | python_file="gcd.py", 25 | right_template=right_template, 26 | ) 27 | assert result, "'highlight' command comparision" 28 | return 29 | 30 | 31 | pass 32 | -------------------------------------------------------------------------------- /test/integration/test_noscript.py: -------------------------------------------------------------------------------- 1 | "Integration test of invoking debugger without a file name" 2 | import sys 3 | 4 | import pytest 5 | from helper import run_debugger 6 | 7 | 8 | @pytest.mark.skipif( 9 | sys.platform == "win32", reason="Need to adjust for filesystem on MS Windows" 10 | ) 11 | def test_no_script(): 12 | """Test invoking debugger without a file name""" 13 | result = run_debugger(testname="noscript", dbgr_opts="--basename", python_file=None) 14 | assert result, "debugger 'step' command comparision" 15 | return 16 | -------------------------------------------------------------------------------- /test/integration/test_step.py: -------------------------------------------------------------------------------- 1 | "Step integration tests" 2 | 3 | import sys 4 | 5 | import pytest 6 | from helper import run_debugger 7 | from xdis import PYTHON_VERSION_TRIPLE 8 | 9 | 10 | @pytest.mark.skipif( 11 | sys.platform == "win32", reason="Need to adjust for filesystem on MS Windows" 12 | ) 13 | def test_step(): 14 | """Test stepping, set skip, set trace""" 15 | if PYTHON_VERSION_TRIPLE >= (3, 11): 16 | right_template = "%s-311.right" 17 | elif PYTHON_VERSION_TRIPLE >= (3, 10): 18 | right_template = "%s-310.right" 19 | elif PYTHON_VERSION_TRIPLE >= (3, 8): 20 | right_template = "%s-38.right" 21 | else: 22 | right_template = None 23 | result = run_debugger( 24 | testname="step", 25 | dbgr_opts="--basename --highlight=plain", 26 | python_file="gcd.py", 27 | right_template=right_template, 28 | ) 29 | assert result, "debugger 'step' command comparision" 30 | return 31 | -------------------------------------------------------------------------------- /test/unit/Makefile: -------------------------------------------------------------------------------- 1 | PYTHON ?= python3 2 | 3 | PHONY=all check check-short test-unit test-unit-short 4 | 5 | #: Run unit tests reduced verbosity 6 | test check: 7 | $(PYTHON) -m pytest lib processor test_*.py 8 | 9 | #: Remove derived files 10 | clean: 11 | -rm -fr *.egg-info || true 12 | 13 | # Whatever else it is you want to do, it should be forwarded to the 14 | # to top-level directories 15 | %: 16 | $(MAKE) -C ../.. $@ 17 | -------------------------------------------------------------------------------- /test/unit/inout/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/python3-trepan/df7fee9dcc64ae9f7293a88fe1cc1bf02677e265/test/unit/inout/__init__.py -------------------------------------------------------------------------------- /test/unit/inout/test_inout_input.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.inout.input""" 2 | import os.path as osp 3 | import pytest 4 | 5 | from trepan.inout.input import DebuggerUserInput 6 | 7 | srcdir = osp.abspath(osp.dirname(__file__)) 8 | 9 | @pytest.mark.skip(reason="input handling has changed with removing 'raw'") 10 | def test_DebuggerInput(): 11 | cmdhelper_file = osp.join(srcdir, "..", "cmdhelper.py") 12 | inp = DebuggerUserInput(cmdhelper_file) 13 | assert isinstance( 14 | inp, DebuggerUserInput 15 | ), "Should have gotten a DebuggerUserInput object back" 16 | line = inp.readline() 17 | assert "# -*- coding: utf-8 -*-" == line 18 | inp.close() 19 | # Should be okay 20 | inp.close() 21 | return 22 | -------------------------------------------------------------------------------- /test/unit/interfaces/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/python3-trepan/df7fee9dcc64ae9f7293a88fe1cc1bf02677e265/test/unit/interfaces/__init__.py -------------------------------------------------------------------------------- /test/unit/interfaces/test_intf_user.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.interfaces.user""" 2 | 3 | from io import StringIO 4 | 5 | from trepan.inout.input import DebuggerUserInput 6 | from trepan.interfaces.user import UserInterface 7 | 8 | 9 | def readline(answer): 10 | return answer 11 | 12 | 13 | def test_confirm(): 14 | """Test interface.user.UserInterface.confirm()""" 15 | 16 | inp = StringIO("") 17 | user_input = DebuggerUserInput(inp) 18 | 19 | def no_history(): 20 | return False 21 | 22 | user_input.use_history = no_history 23 | u = UserInterface(inp=user_input, opts={"debugger_name": "trepan-pytest"}) 24 | 25 | for s in ["y", "Y", "Yes", " YES "]: 26 | 27 | def readline_with_prompt(prompt=None, use_raw: bool=False): 28 | return readline(s) 29 | 30 | u.input.readline = readline_with_prompt 31 | 32 | assert u.confirm("Testing", True) 33 | pass 34 | for s in ["n", "N", "No", " NO "]: 35 | 36 | def readline_with_prompt(prompt=None, use_raw: bool=False): 37 | return readline(s) 38 | 39 | u.input.readline = readline_with_prompt 40 | assert not u.confirm("Testing", True) 41 | pass 42 | # FIXME: Add checking default values. Checking looping 43 | # values 44 | return 45 | 46 | 47 | # FIXME: more thorough testing of other routines in user. 48 | -------------------------------------------------------------------------------- /test/unit/lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/python3-trepan/df7fee9dcc64ae9f7293a88fe1cc1bf02677e265/test/unit/lib/__init__.py -------------------------------------------------------------------------------- /test/unit/lib/test_lib_bytecode.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """Unit test for trepan.lib.bytecode""" 3 | import inspect 4 | 5 | from trepan.lib.bytecode import is_def_stmt, op_at_frame, stmt_contains_opcode 6 | 7 | 8 | def test_contains_make_function(): 9 | frame = inspect.currentframe() 10 | co = frame.f_code 11 | lineno = frame.f_lineno 12 | assert not stmt_contains_opcode(co, lineno, "MAKE_FUNCTION") 13 | return 14 | 15 | 16 | def test_op_at_frame(): 17 | frame = inspect.currentframe() 18 | call_opcode = "CALL" 19 | 20 | assert call_opcode == op_at_frame(frame) 21 | return 22 | 23 | 24 | def test_is_def_frame(): 25 | # Not a "def" statement because frame is wrong spot 26 | frame = inspect.currentframe() 27 | assert not is_def_stmt("foo(): pass", frame) 28 | return 29 | -------------------------------------------------------------------------------- /test/unit/lib/test_lib_core.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.lib.core""" 2 | import os 3 | import sys 4 | 5 | from trepan.lib.core import TrepanCore 6 | 7 | 8 | class MockProcessor: 9 | pass 10 | 11 | 12 | def test_is_next_stop(): 13 | # We assume there's at least one command 14 | opts = {"processor": MockProcessor()} 15 | dc = TrepanCore(None, opts=opts) 16 | dc.step_ignore = 1 17 | assert not dc._is_step_next_stop("line") 18 | assert 0 == dc.step_ignore 19 | assert dc._is_step_next_stop("line") 20 | assert 0 == dc.step_ignore 21 | 22 | return 23 | 24 | 25 | def test_canonic(): 26 | opts = {"processor": MockProcessor()} 27 | dc = TrepanCore(None, opts=opts) 28 | s = "" 29 | assert s == dc.canonic(s), "canonic should not have changed string" 30 | if sys.platform != "win32": 31 | assert ( 32 | os.path.sep == dc.canonic(__file__)[0] 33 | ), "canonic should produce an absolute file" 34 | return 35 | -------------------------------------------------------------------------------- /test/unit/lib/test_lib_display.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.lib.display""" 2 | 3 | import inspect 4 | 5 | from trepan.lib.display import Display, DisplayMgr 6 | 7 | 8 | def test_display(): 9 | mgr = DisplayMgr() 10 | assert mgr.list == [], "Initial list empty" 11 | x = 1 # NOQA 12 | frame = inspect.currentframe() 13 | disp = mgr.add(frame, "x > 1") 14 | assert isinstance(disp, Display), "mgr.add should return display" 15 | assert len(mgr.list) == 1, "display list with one item" 16 | disp = mgr.add(frame, "x") 17 | assert isinstance(disp, Display), "mgr.add should return another display" 18 | assert len(mgr.list) == 2, "display list with two items" 19 | assert mgr.delete_index(1) is True, "return True on ok delete" 20 | assert mgr.delete_index(1) is False, "return False on no delete" 21 | assert len(mgr.list) == 1, "display list again with one item" 22 | return 23 | -------------------------------------------------------------------------------- /test/unit/lib/test_lib_eval.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.lib.eval""" 2 | 3 | from trepan.lib import eval as Meval 4 | 5 | 6 | def test_extract_expression(): 7 | for fragment, expect in ( 8 | ("if condition(x):", "condition(x)"), 9 | ("elif is_magic(name):", "is_magic(name)"), 10 | ("while expression:", "expression"), 11 | ("for i in range(3):", "range(3)"), 12 | ("and x > 3", "x > 3"), 13 | ("or y < 3", "y < 3"), 14 | ("abc = 123", "123"), 15 | ("assert True", "True"), 16 | ("return return_value", "return_value"), 17 | ("nothing_to_be.done", "nothing_to_be.done"), 18 | ): 19 | assert expect == Meval.extract_expression(fragment) 20 | pass 21 | return 22 | -------------------------------------------------------------------------------- /test/unit/lib/test_lib_format.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.lib.file""" 2 | import sys 3 | 4 | from pygments.lexers import RstLexer 5 | 6 | from trepan.lib.format import MonoRSTTerminalFormatter, RstFilter, highlight 7 | 8 | 9 | def test_mono(): 10 | rst_lex = RstLexer() 11 | rst_filt = RstFilter() 12 | rst_lex.add_filter(rst_filt) 13 | rst_tf = MonoRSTTerminalFormatter() 14 | text = "`A` very *emphasis* **strong** `code`" 15 | if sys.version_info[0:2] <= (3, 2): 16 | return 17 | got = highlight(text, rst_lex, rst_tf) 18 | assert '"A" very *emphasis* STRONG "code" ', got 19 | 20 | quit_text = "QUIT - gently terminate the debugged program. " 21 | rst_tf.reset(80) 22 | got = highlight(quit_text, rst_lex, rst_tf) 23 | assert got.startswith(quit_text) 24 | 25 | text = """ 26 | This is an example to show off *reformatting.* 27 | We have several lines 28 | here which should be reflowed. 29 | 30 | But paragraphs should be respected. 31 | 32 | And verbatim 33 | text should not be 34 | touched. 35 | 36 | End of test. 37 | """ 38 | rst_tf.reset(30) 39 | got = highlight(text, rst_lex, rst_tf) 40 | assert ( 41 | "This is an example to show \n" 42 | "off *reformatting.* We have \n" 43 | "several lines here which \n" 44 | "should be reflowed. \n\n" 45 | "But paragraphs should be \n" 46 | "respected. \n\n" 47 | " And verbatim\n" 48 | " text should not be\n" 49 | " touched.\n\n\n" 50 | "End of test. " == got 51 | ) 52 | return 53 | -------------------------------------------------------------------------------- /test/unit/lib/test_lib_kill.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.processor.command.kill""" 2 | 3 | import signal 4 | import sys 5 | from test.unit.cmdhelper import dbg_setup 6 | 7 | from trepan.processor.command import kill as Mkill 8 | 9 | 10 | def test_kill(): 11 | """Test processor.command.kill.KillCommand.run()""" 12 | 13 | signal_caught = False 14 | 15 | def handle(*args): 16 | signal_caught = True 17 | 18 | return 19 | 20 | signal.signal(28, handle) 21 | d, cp = dbg_setup() 22 | command = Mkill.KillCommand(cp) 23 | result = command.run(["kill", "wrong", "number", "of", "args"]) 24 | assert not result 25 | assert not signal_caught 26 | if sys.platform != "win32": 27 | result = command.run(["kill", "28"]) 28 | assert not result 29 | assert signal_caught 30 | return 31 | -------------------------------------------------------------------------------- /test/unit/lib/test_lib_printing.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.lib.printing""" 2 | 3 | import trepan.lib.printing as printing 4 | 5 | 6 | def test_lib_printf(): 7 | assert "0o37" == printing.printf(31, "/o") 8 | assert "00011111" == printing.printf(31, "/t") 9 | assert "!" == printing.printf(33, "/c") 10 | assert "0x21" == printing.printf(33, "/x") 11 | return 12 | 13 | 14 | def test_lib_argspec(): 15 | assert "test_lib_argspec()" == printing.print_argspec( 16 | test_lib_argspec, "test_lib_argspec" 17 | ) 18 | assert printing.print_argspec(None, "invalid_function") is None 19 | assert ( 20 | printing.print_argspec(printing.print_obj, "printing.print_obj") 21 | == "printing.print_obj(arg, frame, format=None, short=False) -> str" 22 | ) 23 | return 24 | -------------------------------------------------------------------------------- /test/unit/lib/test_lib_stack.py: -------------------------------------------------------------------------------- 1 | """Unit test for "trepan.frame" """ 2 | import inspect 3 | 4 | from trepan.lib.stack import count_frames, is_eval_or_exec_stmt 5 | 6 | 7 | def test_count_frames(): 8 | f = inspect.currentframe() 9 | frame_count = count_frames(f) 10 | assert count_frames(f) > 2 11 | assert frame_count - 1 == count_frames(f.f_back) 12 | assert frame_count - 1 == count_frames(f, 1) 13 | return 14 | 15 | 16 | def test_stack_misc(): 17 | f = inspect.currentframe() 18 | # assert "test_stack_misc" == get_call_function_name(f)) 19 | assert is_eval_or_exec_stmt(f) is None 20 | exec("result = is_eval_or_exec_stmt(inspect.currentframe())") 21 | assert "eval" == eval(" is_eval_or_exec_stmt(inspect.currentframe())") 22 | return 23 | -------------------------------------------------------------------------------- /test/unit/lib/test_lib_thread.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.lib.thread""" 2 | import _thread 3 | import sys 4 | import threading 5 | 6 | import pytest 7 | 8 | from trepan.lib.thred import ( 9 | current_thread_name, 10 | find_debugged_frame, 11 | id2thread_name, 12 | map_thread_names, 13 | ) 14 | 15 | 16 | class BgThread(threading.Thread): 17 | def __init__(self, name_checker): 18 | threading.Thread.__init__(self) 19 | self.id_name_checker = name_checker 20 | return 21 | 22 | def run(self): 23 | self.id_name_checker() 24 | return 25 | 26 | 27 | def id_name_checker(): 28 | """Helper for testing map_thread_names and id2thread""" 29 | name2id = map_thread_names() 30 | for thread_id, f in list(sys._current_frames().items()): 31 | assert thread_id == name2id[id2thread_name(thread_id)] 32 | # FIXME: use a better test 33 | assert f != find_debugged_frame(f) 34 | pass 35 | 36 | 37 | def test_current_thread_name(): 38 | """Test trepan.lib.thred.current_thread_name""" 39 | assert "MainThread" == current_thread_name() 40 | 41 | 42 | @pytest.mark.skip(reason="Fix have an intermittent failure") 43 | def test_id2thread_name(): 44 | """Test ``map_thread_names`` and ``id2thread``.""" 45 | thread_id = _thread.get_ident() 46 | assert "MainThread" == id2thread_name(thread_id) 47 | id_name_checker() 48 | 49 | background = BgThread(id_name_checker) 50 | background.start() 51 | background.join() # Wait for the background task to finish 52 | -------------------------------------------------------------------------------- /test/unit/processor/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/python3-trepan/df7fee9dcc64ae9f7293a88fe1cc1bf02677e265/test/unit/processor/__init__.py -------------------------------------------------------------------------------- /test/unit/processor/command/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/python3-trepan/df7fee9dcc64ae9f7293a88fe1cc1bf02677e265/test/unit/processor/command/__init__.py -------------------------------------------------------------------------------- /test/unit/processor/command/test_cmd_finish.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.processor.command.finish""" 2 | 3 | import inspect 4 | from test.unit.cmdhelper import setup_unit_test_debugger 5 | 6 | from trepan.processor.command.finish import FinishCommand 7 | 8 | 9 | def test_finish(): 10 | """Test processor.command.finish.FinishCommand.run()""" 11 | _, cp = setup_unit_test_debugger() 12 | 13 | command = FinishCommand(cp) 14 | for c in ((["finish", "5"], True), (["finish", "0*5+1"], True)): 15 | command.continue_running = False 16 | command.proc.stack = [(inspect.currentframe(), 14)] 17 | result = command.run(c[0]) 18 | assert c[1] == result 19 | pass 20 | return 21 | -------------------------------------------------------------------------------- /test/unit/processor/command/test_cmd_p.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Unit test for trepan.processor.command.p""" 3 | 4 | from test.unit.cmdhelper import setup_unit_test_debugger 5 | 6 | from trepan.processor.command.p import PCommand 7 | 8 | 9 | def test_p(): 10 | errors = [] 11 | msgs = [] 12 | 13 | def errmsg(msg_text: str): 14 | errors.append(msg_text) 15 | return 16 | 17 | def msg(msg_text: str): 18 | msgs.append(msg_text) 19 | return 20 | 21 | d, cp = setup_unit_test_debugger() 22 | cmd = PCommand(cp) 23 | cmd.msg = msg 24 | cmd.errmsg = errmsg 25 | 26 | me = 10 # NOQA 27 | cmd.run([cmd.name, "me"]) 28 | assert "10" == msgs[-1] 29 | cmd.run([cmd.name, "/x", "me"]) 30 | assert "'0xa'" == msgs[-1] 31 | cmd.run([cmd.name, "/o", "me"]) 32 | assert "'0o12'" == msgs[-1] 33 | return 34 | -------------------------------------------------------------------------------- /test/unit/processor/command/test_cmd_run.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.processor.command.run""" 2 | 3 | 4 | from test.unit.cmdhelper import readline_yes, setup_unit_test_debugger 5 | 6 | import pytest 7 | 8 | from trepan.exception import DebuggerRestart 9 | from trepan.processor.command.run import RunCommand 10 | 11 | 12 | def test_run(): 13 | """Test processor.command.run.RunCommand.run()""" 14 | _, cp = setup_unit_test_debugger() 15 | command = RunCommand(cp) 16 | 17 | # First try with "yes" prompt. 18 | cp.intf[-1].input.readline = readline_yes 19 | 20 | for cmd in ("run", "R"): 21 | with pytest.raises(DebuggerRestart): 22 | command.run([cmd]) 23 | 24 | # Now try with "no" prompt using run! 25 | def confirm_no(_, default) -> bool: 26 | return False 27 | 28 | command.confirm = confirm_no 29 | 30 | with pytest.raises(DebuggerRestart): 31 | command.run(["run!"]) 32 | 33 | # Test that unconfirmed quit does *not* raise a DebuggerQuit exception 34 | assert command.run(["run"]) is None 35 | 36 | return 37 | -------------------------------------------------------------------------------- /test/unit/processor/command/test_cmd_step.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.processor.command.step""" 2 | 3 | 4 | from test.unit.cmdhelper import setup_unit_test_debugger 5 | 6 | from trepan.processor.command.step import StepCommand 7 | 8 | """Tests StepCommand class""" 9 | 10 | 11 | def test_step(): 12 | """Test processor.command.step.StepCommand.run()""" 13 | _, cp = setup_unit_test_debugger() 14 | command = StepCommand(cp) 15 | result = command.run(["step", "wrong", "number", "of", "args"]) 16 | assert result is False 17 | 18 | result = command.run(["step", "5"]) 19 | assert result is True 20 | assert 4 == cp.debugger.core.step_ignore 21 | 22 | result = command.run(["step"]) 23 | assert result is True 24 | assert 0 == cp.debugger.core.step_ignore 25 | 26 | result = command.run(["step", "1+(2*3)"]) 27 | assert result is True 28 | assert 6 == cp.debugger.core.step_ignore 29 | return 30 | -------------------------------------------------------------------------------- /test/unit/test_clifns.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.clifns""" 2 | import inspect 3 | import os 4 | import sys 5 | 6 | import pytest 7 | 8 | from trepan.clifns import is_ok_line_for_breakpoint, path_expanduser_abs 9 | 10 | 11 | def test_clifns(): 12 | """Test trepan.clifns.expanduser_abs()""" 13 | file1 = os.path.join(os.path.curdir, "test_clifns") 14 | file1 = path_expanduser_abs(file1) 15 | file2 = path_expanduser_abs("test_clifns") 16 | assert file1 == file2, "path_expanduser_abs" 17 | assert path_expanduser_abs("~/foo") 18 | return 19 | 20 | 21 | def test_is_ok_line_for_breakpoint(): 22 | """Test trepan.clifns.is_ok_for_breakpoint()""" 23 | filename = __file__ 24 | if len(filename) > 4 and filename[-4:] == ".pyc": 25 | filename = filename[:-1] 26 | pass 27 | 28 | # Pick up a Python code line for testing. 29 | # Note that this comment line relative to the line 30 | # we pick up is also used. 31 | frame = inspect.currentframe() 32 | pytest.mark.skipif(frame is None, reason="Can't get runtime stack frame") 33 | assert frame is not None 34 | lineno = frame.f_lineno 35 | assert is_ok_line_for_breakpoint(filename, lineno, sys.stdout.write) 36 | assert not is_ok_line_for_breakpoint(filename, lineno - 5, sys.stdout.write) 37 | -------------------------------------------------------------------------------- /test/unit/test_exception.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """Unit test for trepan.exception""" 3 | 4 | from trepan.exception import DebuggerRestart 5 | 6 | 7 | def test_debugger_restart(): 8 | try: 9 | raise DebuggerRestart(["a", "b"]) 10 | except DebuggerRestart: 11 | import sys 12 | 13 | assert ["a", "b"] == sys.exc_info()[1].sys_argv 14 | else: 15 | assert False, "raise DebuggerRestart didn't raise" 16 | return 17 | -------------------------------------------------------------------------------- /test/unit/test_inout_tcp.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.inout.tcp*""" 2 | from trepan.inout.tcpclient import TCPClient 3 | from trepan.inout.tcpserver import TCPServer 4 | 5 | 6 | def test_client_server(): 7 | client = None 8 | server = None 9 | try: 10 | try: 11 | server = TCPServer(opts={"open": True}) 12 | except Exception: 13 | print("Skipping because of server open failure") 14 | return 15 | print("Server port is %s" % server.PORT) 16 | try: 17 | client = TCPClient(opts={"open": True, "PORT": server.PORT}) 18 | except IOError: 19 | print("Skipping because of client open failure") 20 | return 21 | for line in ["one", "two", "three"]: 22 | server.writeline(line) 23 | assert line == client.read_msg().rstrip("\n") 24 | pass 25 | 26 | for line in ["four", "five", "six"]: 27 | client.writeline(line) 28 | assert line == server.read_msg().rstrip("\n") 29 | pass 30 | 31 | finally: 32 | if client: 33 | client.close() 34 | if server: 35 | server.close() 36 | return 37 | -------------------------------------------------------------------------------- /test/unit/test_misc.py: -------------------------------------------------------------------------------- 1 | """Unit test for trepan.misc""" 2 | 3 | from trepan.misc import bool2YN, option_set, wrapped_lines 4 | 5 | 6 | def test_bool2YN(): 7 | for arg, expect in ((True, "Y"), (False, "N"), (None, "N")): 8 | assert bool2YN(arg) == expect 9 | 10 | 11 | def test_option_set(): 12 | """Test trepan.misc.option_set()""" 13 | TEST_OPTS = {"a": True, "b": 5, "c": None} 14 | 15 | def get_option(key): 16 | return option_set(opts, key, TEST_OPTS) 17 | 18 | opts = {"d": 6, "a": False} 19 | for opt, expect in [("a", False), ("b", 5), ("c", None), ("d", 6)]: 20 | assert expect == get_option(opt) 21 | opts = None 22 | for opt, expect in [("a", True), ("b", 5), ("c", None), ("d", None)]: 23 | assert expect == get_option(opt) 24 | pass 25 | 26 | 27 | def test_wrapped_msg(): 28 | """Test trepan.misc.wrapped_lines()""" 29 | assert "hi there" == wrapped_lines("hi", "there", 80) 30 | assert "hi\n\tthere" == wrapped_lines("hi", "there", 5) 31 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | ; Settings file for flake8: 2 | ; http://flake8.readthedocs.org/en/latest/config.html#settings 3 | [flake8] 4 | exclude = .tox,./build,./trepan/processor/command/tmp,./trepan/version.py 5 | filename = *.py 6 | ignore = E113,E121,E122,E123,E125,E126,E127,E128,E129,E201,E202,E203,E221,E222,E225,E226,E241,E251,E272,E302,E401,E402,E501,F401,E701,E702,E704,E731,C901,W503 7 | 8 | [tox] 9 | envlist = py33 py34 10 | 11 | [testenv] 12 | commands = python -W always setup.py nosetests {posargs} 13 | -------------------------------------------------------------------------------- /trepan/bwprocessor/__init__.py: -------------------------------------------------------------------------------- 1 | # This program is free software: you can redistribute it and/or modify 2 | # it under the terms of the GNU General Public License as published by 3 | # the Free Software Foundation, either version 3 of the License, or 4 | # (at your option) any later version. 5 | # 6 | # This program is distributed in the hope that it will be useful, 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | # GNU General Public License for more details. 10 | # 11 | # You should have received a copy of the GNU General Public License 12 | # along with this program. If not, see . 13 | """ Copyright (C) 2013, 2018 Rocky Bernstein """ 14 | -------------------------------------------------------------------------------- /trepan/bwprocessor/msg.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2015, 2023 Rocky Bernstein 3 | """ Common I/O routines""" 4 | 5 | 6 | # Note for errmsg, msg, and msg_nocr we don't want to simply make 7 | # an assignment of method names like self.msg = self.debugger.intf.msg, 8 | # because we want to allow the interface (intf) to change 9 | # dynamically. That is, the value of self.debugger may change 10 | # in the course of the program and if we made such an method assignment 11 | # we wouldn't pick up that change in our self.msg 12 | def errmsg(proc_obj, message, opts={}): 13 | response = proc_obj.response 14 | if "set_name" in opts: 15 | response["name"] = "error" 16 | return response["errs"].append(message) 17 | 18 | 19 | def msg(proc_obj, message, opts={}): 20 | response = proc_obj.response 21 | return response["msg"].append(message) 22 | 23 | 24 | # Demo it 25 | if __name__ == "__main__": 26 | 27 | class Demo: 28 | def __init__(self): 29 | self.response = {"errs": [], "msg": []} 30 | pass 31 | 32 | pass 33 | 34 | import pprint 35 | 36 | demo = Demo() 37 | msg(demo, "hi") 38 | pp = pprint.PrettyPrinter() 39 | pp.pprint(demo.response) 40 | -------------------------------------------------------------------------------- /trepan/exception.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2008-2009, 2013-2014, 2020 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | 18 | class DebuggerQuit(Exception): 19 | """An exception to signal a graceful termination of the program""" 20 | 21 | pass 22 | 23 | 24 | class DebuggerRestart(Exception): 25 | """An exception to signal a (soft) program restart. 26 | You can pass in an array containing the arguments to restart, should 27 | we have to issue an execv-style restart. 28 | """ 29 | 30 | def __init__(self, sys_argv=[]): 31 | self.sys_argv = sys_argv 32 | return 33 | 34 | pass 35 | 36 | 37 | if __name__ == "__main__": 38 | try: 39 | raise DebuggerRestart(["a", "b"]) 40 | except DebuggerRestart: 41 | import sys 42 | 43 | print(sys.exc_info()[1].sys_argv) 44 | pass 45 | pass 46 | -------------------------------------------------------------------------------- /trepan/inout/Makefile: -------------------------------------------------------------------------------- 1 | # Whatever it is you want to do, it should be forwarded to the 2 | # to top-level irectories 3 | PHONY=check all 4 | all: check 5 | 6 | %: 7 | $(MAKE) -C ../.. $@ 8 | -------------------------------------------------------------------------------- /trepan/inout/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | trepan.io 4 | ~~~~~~~~~ 5 | 6 | Trepan Input and Output routines 7 | 8 | :copyright: Copyright 2013, 2018 9 | :license: GPL3, see LICENSE for details. 10 | """ 11 | 12 | __docformat__ = "restructuredtext" 13 | 14 | from trepan.misc import pyfiles 15 | 16 | __all__ = pyfiles(__file__) 17 | -------------------------------------------------------------------------------- /trepan/interfaces/__init__.py: -------------------------------------------------------------------------------- 1 | # This program is free software: you can redistribute it and/or modify 2 | # it under the terms of the GNU General Public License as published by 3 | # the Free Software Foundation, either version 3 of the License, or 4 | # (at your option) any later version. 5 | # 6 | # This program is distributed in the hope that it will be useful, 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | # GNU General Public License for more details. 10 | # 11 | # You should have received a copy of the GNU General Public License 12 | # along with this program. If not, see . 13 | """ Copyright (C) 2008, 2013-2014, 2016 Rocky Bernstein """ 14 | __package__ = "trepan.interfaces" 15 | __docformat__ = "restructuredtext" 16 | -------------------------------------------------------------------------------- /trepan/interfaces/comcodes.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2008, 2009, 2013 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | """ Communication status codes""" 17 | PRINT = "." 18 | COMMAND = "C" # read a command 19 | CONFIRM_TRUE = "Y" 20 | CONFIRM_FALSE = "N" 21 | CONFIRM_REPLY = "?" 22 | QUIT = "q" 23 | PROMPT = "p" 24 | SYNC = "s" # Resynchronize communication 25 | RESTART = "r" 26 | -------------------------------------------------------------------------------- /trepan/lib/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008-2009, 2013, 2015, 2018 Rocky Bernstein 2 | # This program is free software: you can redistribute it and/or modify 3 | # it under the terms of the GNU General Public License as published by 4 | # the Free Software Foundation, either version 3 of the License, or 5 | # (at your option) any later version. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License 13 | # along with this program. If not, see . 14 | """ Copyright (C) 2008, 2009, 2013, 2015 Rocky Bernstein """ 15 | 16 | __docformat__ = "restructuredtext" 17 | 18 | from trepan.misc import pyfiles 19 | 20 | __all__ = pyfiles(__file__) 21 | __package__ = "trepan.lib" 22 | -------------------------------------------------------------------------------- /trepan/lib/chdir.py: -------------------------------------------------------------------------------- 1 | # Copied from 3.11 2 | """Utilities for with-statement contexts. See PEP 343.""" 3 | 4 | class ChDir(object): 5 | """ 6 | Step into a directory temporarily. 7 | """ 8 | def __init__(self, path): 9 | self.old_dir = os.getcwd() 10 | self.new_dir = path 11 | 12 | def __enter__(self): 13 | os.chdir(self.new_dir) 14 | 15 | def __exit__(self, *args): 16 | os.chdir(self.old_dir) 17 | -------------------------------------------------------------------------------- /trepan/processor/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/python3-trepan/df7fee9dcc64ae9f7293a88fe1cc1bf02677e265/trepan/processor/__init__.py -------------------------------------------------------------------------------- /trepan/processor/command/.gitignore: -------------------------------------------------------------------------------- 1 | /.coverage 2 | -------------------------------------------------------------------------------- /trepan/processor/command/help/.gitignore: -------------------------------------------------------------------------------- 1 | /*~ 2 | -------------------------------------------------------------------------------- /trepan/processor/command/help/README.md: -------------------------------------------------------------------------------- 1 | Files in this directory are help for `help syntax`. 2 | 3 | A list of sub-names is obtained by `Dir.glob('*.txt')` in this directory. 4 | 5 | Each file name without the trailing `.txt` is the name of the help subcategory under `help syntax`. 6 | 7 | The first line in the file is a summary shown in help summary. Lines 3 on are shown as help text. 8 | -------------------------------------------------------------------------------- /trepan/processor/command/help/arange.rst: -------------------------------------------------------------------------------- 1 | Syntax for Address Ranges 2 | ========================= 3 | 4 | Address ranges are used in the `disassemble` command. It is like a 5 | range, but we allow addresses. 6 | 7 | An address range is in one of the following forms: 8 | 9 | location # starting line only 10 | first, last # starting and ending line 11 | , last # ending line only 12 | 13 | 14 | A *location* is described elsewhere. *first* and *last* can also be 15 | linespecs but they also may be a number or address (bytecode 16 | offset). And finally *last* can be an (line number) offset. 17 | 18 | A number is just a decimal number. An offset is a number prefaced with "+" and 19 | indicates the number to increment the line number found in *first*. 20 | 21 | Examples 22 | -------- 23 | 24 | :: 25 | 26 | *5 # start from bytecode offset 5 of current file 27 | *5 , # Same as above. 28 | foo.py:*5 # start from bytecode offset 5 of file foo.py 29 | 30 | 31 | See also 32 | --------- 33 | `help syntax location` 34 | -------------------------------------------------------------------------------- /trepan/processor/command/help/examples.rst: -------------------------------------------------------------------------------- 1 | Command examples 2 | ================ 3 | 4 | :: 5 | 6 | # This line does nothing. It is a comment. Useful in debugger command files. 7 | # This line also does nothing. 8 | s # by default, this is an alias for the "step" command 9 | info program;;list # error no command 'program;;list' 10 | info program ;; list # Runs two commands "info program" and "list" 11 | -------------------------------------------------------------------------------- /trepan/processor/command/help/filename.rst: -------------------------------------------------------------------------------- 1 | Syntax for Indicating a Filename 2 | ================================ 3 | 4 | Filename Examples: 5 | ------------------ 6 | 7 | file.py => file.py 8 | /tmp/file.py => /tmp/file.py 9 | C\:file.py => C:file.py # For Microsoft OS's 10 | C\:\file.py => C:\file.py # For Microsoft OS's 11 | C\:\\file.py => C:\file.py # Note: double slash not needed 12 | \\new.py => \new.py # Note: double slash, or filename has newline 13 | my\ file.py => my file.py 14 | -------------------------------------------------------------------------------- /trepan/processor/command/help/range.rst: -------------------------------------------------------------------------------- 1 | Syntax for List Ranges 2 | ====================== 3 | 4 | List ranges are used in the `list` and `disassemble` commands. 5 | 6 | A list range is in one of the following forms: 7 | 8 | linespec # starting line only 9 | first, last # starting and ending line 10 | , last # ending line only 11 | 12 | 13 | A *linespec* is described elsewhere. *first* and *last* can also be 14 | linespecs but they also may be a number. And finally *last* can be an 15 | offset. 16 | 17 | A number is just a decimal number. An offset is a number prefaced with "+" and 18 | indicates the number to increment the line number found in *first*. 19 | 20 | Examples 21 | -------- 22 | 23 | 5 # start from line 5 of current file 24 | 5 , # Same as above. 25 | 5 # listsize lines before and up to 5 26 | foo.py:5 # start from line 5 of file foo.py 27 | foo() # start from function foo 28 | os.path:5 # start from line 5 of module os.path 29 | os.path:5 # Same as above. 30 | os.path:5, 6 # list lines 5 and 6 of os.path 31 | os.path:5, +1 # Same as above. +1 is an offset 32 | os.path:5, 1 # Same as above, since 1 < 5. 33 | os.path:5, +6 # lines 5-11 34 | os.path.join() # lines starting with the os.join.path function. 35 | "c:\foo.py":10, # listsize lines starting from line 10 of c:\foo.py 36 | , 'My Doc/foo.py':20 # listsize lines ending at line 20 of file: My Doc/foo.py 37 | -------------------------------------------------------------------------------- /trepan/processor/command/help/suffixes.rst: -------------------------------------------------------------------------------- 1 | Command suffixes which have special meaning 2 | =========================================== 3 | 4 | Some commands like `step`, or `list` do different things when an 5 | alias to the command ends in a particular suffix like `>`. 6 | 7 | Here are a list of commands and the special suffixes: 8 | 9 | command suffix 10 | ------- ------ 11 | list > 12 | step +,-,<,> 13 | next +,-,<,> 14 | quit ! 15 | kill ! 16 | eval ? 17 | 18 | See the help on the specific commands listed above for the specific 19 | meaning of the suffix. 20 | -------------------------------------------------------------------------------- /trepan/processor/command/info_subcmd/source.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2008-2009, 2013, 2015, 2024 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | # Our local modules 18 | from trepan.processor.command import base_subcmd as Mbase_subcmd 19 | 20 | 21 | class InfoSource(Mbase_subcmd.DebuggerSubcommand): 22 | """Information about the current Python file.""" 23 | 24 | min_abbrev = 1 25 | need_stack = True 26 | short_help = "Information about the current Python file" 27 | 28 | def run(self, args): 29 | if not self.proc.curframe: 30 | self.errmsg("No current source file.") 31 | return 32 | filename = self.core.canonic_filename(self.proc.curframe) 33 | self.msg(f"Current Python file is {self.core.filename(filename)}") 34 | return False 35 | 36 | pass 37 | -------------------------------------------------------------------------------- /trepan/processor/command/set.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2013, 2020 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | from trepan.processor.command.base_submgr import SubcommandMgr 18 | 19 | 20 | class SetCommand(SubcommandMgr): 21 | """**set** *set subcommand* 22 | 23 | Modifies parts of the debugger environment. 24 | 25 | You can give unique prefix of the name of a subcommand to get 26 | information about just that subcommand. 27 | 28 | Type `set` for a list of *set* subcommands and what they do. 29 | Type `help set *` for just the list of *set* subcommands.""" 30 | 31 | short_help = "Modify parts of the debugger environment" 32 | 33 | SubcommandMgr.setup(locals(), category="data") 34 | 35 | 36 | if __name__ == "__main__": 37 | from trepan.processor.command import mock 38 | 39 | d, cp = mock.dbg_setup() 40 | command = SetCommand(cp, "set") 41 | command.run(["set"]) 42 | pass 43 | -------------------------------------------------------------------------------- /trepan/processor/command/set_subcmd/__demo_helper__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | # FIXME: DRY with other demo_helper's 5 | 6 | 7 | def get_name(): 8 | """Get the name caller's caller. 9 | NB: f_code.co_filenames and thus this code kind of broken for 10 | zip'ed eggs circa Jan 2009 11 | """ 12 | caller = sys._getframe(2) 13 | filename = caller.f_code.co_filename 14 | filename = os.path.normcase(os.path.basename(filename)) 15 | return os.path.splitext(filename)[0] 16 | 17 | 18 | def demo_setup(): 19 | from trepan.processor.command import mock as Mmock, set as Mset 20 | 21 | d, cp = Mmock.dbg_setup() 22 | mgr = Mset.SetCommand(cp) 23 | return mgr 24 | 25 | 26 | def demo_run(subcmd, *args): 27 | mgr = demo_setup() 28 | sub = subcmd(mgr) 29 | sub.name = get_name() 30 | sub.run(*args) 31 | return sub 32 | -------------------------------------------------------------------------------- /trepan/processor/command/set_subcmd/basename.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2013, 2016 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | # Our local modules 18 | from trepan.processor.command import base_subcmd as Mbase_subcmd 19 | 20 | 21 | class SetBasename(Mbase_subcmd.DebuggerSetBoolSubcommand): 22 | """**set basename** [ **on** | **off** ] 23 | 24 | Set basename (short filenames) in debugger output. 25 | 26 | Setting this causes the debugger output to give just the basename for 27 | filenames. This is useful in debugger testing or possibly showing 28 | examples where you don't want to hide specific filesystem and 29 | installation information.""" 30 | 31 | in_list = True 32 | min_abbrev = len("ba") 33 | pass 34 | 35 | 36 | if __name__ == "__main__": 37 | from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper 38 | 39 | Mhelper.demo_run(SetBasename) 40 | pass 41 | -------------------------------------------------------------------------------- /trepan/processor/command/set_subcmd/cmdtrace.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2012-2013 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | # Our local modules 18 | from trepan.processor.command import base_subcmd as Mbase_subcmd 19 | from trepan.processor import cmdfns as Mcmdfns 20 | 21 | 22 | class SetCmdtrace(Mbase_subcmd.DebuggerSetBoolSubcommand): 23 | """Set echoing lines read from debugger command files""" 24 | 25 | in_list = True 26 | min_abbrev = len("cmdt") # Need at least "set cmdt" 27 | pass 28 | 29 | def run(self, args): 30 | Mcmdfns.run_set_bool(self, args) 31 | dbg = self.debugger 32 | if hasattr(dbg.intf[-1], "verbose"): 33 | dbg.intf[-1].verbose = dbg.settings[self.name] 34 | pass 35 | return 36 | 37 | pass 38 | -------------------------------------------------------------------------------- /trepan/processor/command/set_subcmd/tempdir.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2021, 2024 Rocky Bernstein 3 | # 4 | 5 | import os 6 | 7 | # Our local modules 8 | from trepan.processor.command.base_subcmd import DebuggerSubcommand 9 | 10 | 11 | class SetTempdir(DebuggerSubcommand): 12 | """**set tempdir** *directory* 13 | 14 | Set the temporary directory for temporary decompiled python files. 15 | 16 | This is sometimes useful remote debugging where you might set up a 17 | common shared location available between the debugged process and 18 | the front end client. 19 | 20 | Examples: 21 | --------- 22 | 23 | set tempdir /code/tmp # /code is a shared directory 24 | 25 | See also: 26 | -------- 27 | 28 | `show tempdir`""" 29 | 30 | in_list = True 31 | min_abbrev = len("temp") 32 | min_args = 1 33 | max_args = 1 34 | short_help = "Set a directory for storing decompiled Python" 35 | 36 | def run(self, args): 37 | dirpath = args[0] 38 | if os.path.isdir(dirpath): 39 | self.debugger.settings[self.name] = dirpath 40 | else: 41 | self.errmsg(f"set tempdir: directory {dirpath} not found; not changed.") 42 | return 43 | 44 | pass 45 | 46 | 47 | # if __name__ == '__main__': 48 | # from trepan.processor.command.set.tempdir import __demo_helper__ as Mhelper 49 | # sub = Mhelper.demo_run(SetTempdir) 50 | # d = sub.proc.debugger 51 | # sub.run(['tempdir']) 52 | # print(d.settings['tempdir']) 53 | # pass 54 | -------------------------------------------------------------------------------- /trepan/processor/command/set_subcmd/width.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2012-2013, 2015, 2020 Rocky Bernstein 3 | # 4 | # Our local modules 5 | from trepan.processor.command.base_subcmd import DebuggerSubcommand 6 | from trepan.processor.cmdfns import run_set_int 7 | 8 | 9 | class SetWidth(DebuggerSubcommand): 10 | """**set width** *number* 11 | 12 | Set the number of characters the debugger thinks are in a line. 13 | 14 | See also: 15 | -------- 16 | 17 | `show width`""" 18 | 19 | in_list = True 20 | min_abbrev = len("wid") 21 | short_help = "Set the width of the terminal" 22 | 23 | def run(self, args): 24 | run_set_int( 25 | self, " ".join(args), "The 'width' command requires a line width", 0, None 26 | ) 27 | return 28 | 29 | pass 30 | 31 | 32 | if __name__ == "__main__": 33 | from trepan.processor.command.set_subcmd.__demo_helper__ import demo_run 34 | 35 | sub = demo_run(SetWidth, ["10"]) 36 | d = sub.proc.debugger 37 | print(d.settings["width"]) 38 | sub.run(["100"]) 39 | print(d.settings["width"]) 40 | pass 41 | -------------------------------------------------------------------------------- /trepan/processor/command/show.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2013, 2020 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | from trepan.processor.command.base_submgr import SubcommandMgr 18 | 19 | 20 | class ShowCommand(SubcommandMgr): 21 | """**show** *subcommand* 22 | 23 | Generic command for showing things about the debugger. You can 24 | give unique prefix of the name of a subcommand to get information 25 | about just that subcommand. 26 | 27 | Type `show` for a list of *show* subcommands and what they do. 28 | Type `help show *` for just a list of *show* subcommands.""" 29 | 30 | short_help = "Show parts of the debugger environment" 31 | SubcommandMgr.setup(locals(), category="status") 32 | 33 | 34 | if __name__ == "__main__": 35 | from trepan.processor.command import mock 36 | 37 | d, cp = mock.dbg_setup() 38 | command = ShowCommand(cp, "show") 39 | command.run(["show"]) 40 | pass 41 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/__demo_helper__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | # FIXME: DRY with other demo_helper's 5 | 6 | 7 | def get_name(): 8 | """Get the name caller's caller. 9 | NB: f_code.co_filenames and thus this code kind of broken for 10 | zip'ed eggs circa Jan 2009 11 | """ 12 | caller = sys._getframe(2) 13 | filename = caller.f_code.co_filename 14 | filename = os.path.normcase(os.path.basename(filename)) 15 | return os.path.splitext(filename)[0] 16 | 17 | 18 | def demo_setup(): 19 | from trepan.processor.command import mock as Mmock, show as Mshow 20 | 21 | d, cp = Mmock.dbg_setup() 22 | mgr = Mshow.ShowCommand(cp) 23 | return mgr 24 | 25 | 26 | def demo_run(subcmd): 27 | mgr = demo_setup() 28 | sub = subcmd(mgr) 29 | sub.name = get_name() 30 | sub.run([]) 31 | return sub 32 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/__init__.py: -------------------------------------------------------------------------------- 1 | # This program is free software: you can redistribute it and/or modify 2 | # it under the terms of the GNU General Public License as published by 3 | # the Free Software Foundation, either version 3 of the License, or 4 | # (at your option) any later version. 5 | # 6 | # This program is distributed in the hope that it will be useful, 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | # GNU General Public License for more details. 10 | # 11 | # You should have received a copy of the GNU General Public License 12 | # along with this program. If not, see . 13 | # """ Copyright (C) 2008-2009, 2015, 2018 Rocky Bernstein """ 14 | 15 | import glob 16 | import os 17 | 18 | # FIXME: Is it really helpful to "privatize" variable names below? 19 | # The below names are not part of the standard pre-defined names like 20 | # __name__ or __file__ are. 21 | 22 | # Get the name of our directory. 23 | __command_dir__ = os.path.dirname(__file__) 24 | 25 | # A glob pattern that will get all *.py files but not __init__.py 26 | __py_files__ = glob.glob(os.path.join(__command_dir__, "[a-z]*.py")) 27 | 28 | # Take the basename of the filename and drop off '.py'. That minus the 29 | # file exclude_file the list of modules that show.py will use to import 30 | exclude_files = [] 31 | __modules__ = [ 32 | os.path.basename(filename[0:-3]) 33 | for filename in __py_files__ 34 | if os.path.basename(filename) not in exclude_files 35 | ] 36 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/args.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2013, 2015, 2024 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | # Our local modules 18 | from trepan.processor.command import base_subcmd as Mbase_subcmd 19 | 20 | 21 | class ShowArgs(Mbase_subcmd.DebuggerSubcommand): 22 | """Show argument list to give debugged program when it is started""" 23 | 24 | min_abbrev = len("arg") 25 | run_in_help = False 26 | short_help = "Show arguments when program is started" 27 | 28 | def run(self, args): 29 | self.msg( 30 | "Argument list to give program being debugged " + "when it is started is:" 31 | ) 32 | self.msg(f"\t{' '.join(self.debugger.program_sys_argv[1:])}.") 33 | return False 34 | 35 | pass 36 | 37 | 38 | if __name__ == "__main__": 39 | from trepan.processor.command.show_subcmd import __demo_helper__ as Mhelper 40 | 41 | Mhelper.demo_run(ShowArgs) 42 | pass 43 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/autoeval.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2013, 2015 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | # Our local modules 18 | from trepan.processor.command import base_subcmd as Mbase_subcmd 19 | 20 | 21 | class ShowAutoEval(Mbase_subcmd.DebuggerShowBoolSubcommand): 22 | """**show autoeval** 23 | 24 | Show Python evaluation of unrecognized debugger commands. 25 | 26 | See also: 27 | --------- 28 | 29 | `set autoeval`""" 30 | 31 | min_abbrev = len("autoe") 32 | pass 33 | 34 | 35 | if __name__ == "__main__": 36 | from trepan.processor.command.show_subcmd import __demo_helper__ as Mhelper 37 | 38 | Mhelper.demo_run(ShowAutoEval) 39 | pass 40 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/autolist.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2015, 2020 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | # Our local modules 18 | from trepan.processor.command.base_subcmd import DebuggerShowBoolSubcommand 19 | 20 | 21 | class ShowAutoList(DebuggerShowBoolSubcommand): 22 | """**show autolist** 23 | 24 | Show debugger `list` command automatically on entry. 25 | 26 | See also: 27 | --------- 28 | 29 | `set autolist`""" 30 | 31 | min_abbrev = len("autol") 32 | short_help = "Show `list` on debugger entry" 33 | pass 34 | 35 | 36 | if __name__ == "__main__": 37 | from trepan.processor.command.show_subcmd.__demo_helper__ import demo_run 38 | 39 | demo_run(ShowAutoList) 40 | pass 41 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/autopc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2015, 2020-2021 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | # Our local modules 18 | from trepan.processor.command.base_subcmd import DebuggerShowBoolSubcommand 19 | 20 | 21 | class ShowAutoPC(DebuggerShowBoolSubcommand): 22 | """**show autopc** 23 | 24 | Show debugger `info pc` command automatically on entry. 25 | 26 | See also: 27 | --------- 28 | 29 | `set autopc`""" 30 | 31 | min_abbrev = len("autos") 32 | short_help = "Show `info pc` on debugger entry" 33 | pass 34 | 35 | 36 | if __name__ == "__main__": 37 | from trepan.processor.command.show_subcmd.__demo_helper__ import demo_run 38 | 39 | demo_run(ShowAutoPC) 40 | pass 41 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/autopython.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2013, 2015 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | # Our local modules 18 | from trepan.processor.command import base_subcmd as Mbase_subcmd 19 | 20 | 21 | class ShowAutoPython(Mbase_subcmd.DebuggerShowBoolSubcommand): 22 | """**show autopython** 23 | 24 | Show whether we go into a python shell when automatically when the 25 | debugger is entered. 26 | 27 | Change with **set autopython**""" 28 | 29 | short_help = "Show automatic Python shell entry" 30 | min_abbrev = len("autopy") 31 | pass 32 | 33 | 34 | if __name__ == "__main__": 35 | from trepan.processor.command.show_subcmd import __demo_helper__ as Mhelper 36 | 37 | Mhelper.demo_run(ShowAutoPython) 38 | pass 39 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/basename.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2013 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | # Our local modules 18 | from trepan.processor.command import base_subcmd as Mbase_subcmd 19 | 20 | 21 | class ShowBasename(Mbase_subcmd.DebuggerShowBoolSubcommand): 22 | """**show basename** 23 | 24 | Show whether filenames are reported with just the basename or the 25 | fully qualified filename. 26 | 27 | Change with **set basename**""" 28 | 29 | short_help = "Show the basename portion only of filenames" 30 | min_abbrev = len("ba") 31 | pass 32 | 33 | 34 | if __name__ == "__main__": 35 | from trepan.processor.command.show_subcmd import __demo_helper__ as Mhelper 36 | 37 | Mhelper.demo_run(ShowBasename) 38 | pass 39 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/confirm.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2013, 2015 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | # Our local modules 18 | from trepan.processor.command import base_subcmd as Mbase_subcmd 19 | 20 | 21 | class ShowConfirm(Mbase_subcmd.DebuggerShowBoolSubcommand): 22 | """**show confirm** 23 | 24 | Show confirmation of potentially dangerous operations 25 | 26 | See also: 27 | --------- 28 | 29 | `set confirm`""" 30 | 31 | min_abbrev = 3 # Need at least "show con" 32 | pass 33 | 34 | 35 | if __name__ == "__main__": 36 | from trepan.processor.command.show_subcmd import __demo_helper__ as Mhelper 37 | 38 | Mhelper.demo_run(ShowConfirm) 39 | pass 40 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/dbg_trepan.py: -------------------------------------------------------------------------------- 1 | # Our local modules 2 | from trepan.processor.command import base_subcmd as Mbase_subcmd 3 | 4 | 5 | class ShowDbgTrepan(Mbase_subcmd.DebuggerShowBoolSubcommand): 6 | """**show dbg_trepan** 7 | 8 | Show debugging the debugger 9 | 10 | See also: 11 | --------- 12 | 13 | `set dbg_trepan`""" 14 | 15 | min_abbrev = 4 # Min 'show trep" 16 | short_help = "Show debugging the debugger" 17 | pass 18 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/listsize.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2009, 2015 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | 18 | # Our local modules 19 | from trepan.processor.command import base_subcmd as Mbase_subcmd 20 | 21 | 22 | class ShowListSize(Mbase_subcmd.DebuggerShowIntSubcommand): 23 | """**show maxstring*** 24 | 25 | Show the number lines printed in a 'list' command by default 26 | 27 | See also: 28 | -------- 29 | 30 | `set listsize`""" 31 | 32 | min_abbrev = len("lis") 33 | short_help = "Show number of lines in `list`" 34 | pass 35 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/style.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2015, 2018, 2020, 2024 Rocky Bernstein 3 | # 4 | 5 | from pygments.styles import STYLE_MAP 6 | 7 | # Our local modules 8 | from trepan.processor.command.base_subcmd import DebuggerSubcommand 9 | from trepan.lib.complete import complete_token 10 | 11 | 12 | style_names = sorted(list(STYLE_MAP.keys())) 13 | 14 | 15 | class ShowStyle(DebuggerSubcommand): 16 | """**show style* *pygments-style* 17 | 18 | Show the pygments style used in formatting 256-color terminal text. 19 | 20 | See also: 21 | --------- 22 | 23 | `set style`, `show styles`, `show highlight`""" 24 | 25 | in_list = True 26 | min_abbrev = len("sty") 27 | short_help = "Set the pygments style" 28 | 29 | def complete(self, prefix): 30 | return complete_token(style_names) 31 | 32 | 33 | def run(self, args): 34 | if len(args) != 0: 35 | self.errmsg("Expecting no args") 36 | return 37 | 38 | style = self.debugger.settings.get(self.name, None) 39 | if style: 40 | self.msg(f"Pygments style is {style}.") 41 | else: 42 | self.msg("Pygments style not set.") 43 | return 44 | 45 | pass 46 | 47 | 48 | if __name__ == "__main__": 49 | from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper 50 | 51 | sub = Mhelper.demo_run(ShowStyle, []) 52 | d = sub.proc.debugger 53 | sub.run(["show"]) 54 | pass 55 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/styles.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2024 Rocky Bernstein 3 | # 4 | 5 | from pygments.styles import STYLE_MAP 6 | 7 | # Our local modules 8 | from trepan.processor.command.base_subcmd import DebuggerSubcommand 9 | 10 | style_names = sorted(list(STYLE_MAP.keys())) 11 | 12 | 13 | class ShowStyles(DebuggerSubcommand): 14 | """**show styles** 15 | 16 | Give a list of all pygments style available in formatting 256-color terminal text. 17 | 18 | See also: 19 | --------- 20 | 21 | `show style`, `set style`, `show highlight`""" 22 | 23 | in_list = True 24 | short_help = "Show all pygments style available" 25 | min_abbrev = len("styles") 26 | 27 | def run(self, args): 28 | if len(args) != 0: 29 | self.errmsg("Expecting no args") 30 | return 31 | 32 | self.section("style names: ") 33 | self.msg(self.columnize_commands(style_names)) 34 | return 35 | 36 | pass 37 | 38 | 39 | if __name__ == "__main__": 40 | from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper 41 | 42 | sub = Mhelper.demo_run(ShowStyles, []) 43 | d = sub.proc.debugger 44 | sub.run(["show"]) 45 | pass 46 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/tempdir.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2021, 2024 Rocky Bernstein 3 | # 4 | 5 | # Our local modules 6 | from trepan.processor.command.base_subcmd import DebuggerSubcommand 7 | 8 | 9 | class ShowTempdir(DebuggerSubcommand): 10 | """**show tempdir** 11 | 12 | Show the temporary directory using in decompiled python files. 13 | 14 | See also: 15 | -------- 16 | 17 | `set tempdir`""" 18 | 19 | in_list = True 20 | min_abbrev = len("temp") 21 | min_args = 0 22 | max_args = 0 23 | short_help = "Set a directory for storing decompiled Python" 24 | 25 | def run(self, args): 26 | tempdir = self.debugger.settings.get(self.name, None) 27 | if tempdir: 28 | self.msg(f"tempdir is {tempdir}.") 29 | else: 30 | self.msg("tempdir not set; Python default is used.") 31 | return 32 | 33 | pass 34 | 35 | 36 | if __name__ == "__main__": 37 | from trepan.processor.command.set_subcmd import __demo_helper__ as Mhelper 38 | 39 | sub = Mhelper.demo_run(ShowTempdir) 40 | d = sub.proc.debugger 41 | sub.run(["show"]) 42 | pass 43 | -------------------------------------------------------------------------------- /trepan/processor/command/show_subcmd/width.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Copyright (C) 2024 Rocky Bernstein 3 | # 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see . 16 | 17 | 18 | # Our local modules 19 | from trepan.processor.command import base_subcmd as Mbase_subcmd 20 | 21 | 22 | class ShowWidth(Mbase_subcmd.DebuggerShowIntSubcommand): 23 | """**show width*** 24 | 25 | Show the maximum text lines width. 26 | 27 | See also: 28 | -------- 29 | 30 | `set width`""" 31 | 32 | min_abbrev = len("w") 33 | short_help = "Show line width" 34 | pass 35 | -------------------------------------------------------------------------------- /trepan/processor/parse/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/python3-trepan/df7fee9dcc64ae9f7293a88fe1cc1bf02677e265/trepan/processor/parse/__init__.py -------------------------------------------------------------------------------- /trepan/processor/parse/tok.py: -------------------------------------------------------------------------------- 1 | class Token: 2 | """ 3 | Class representing a token. 4 | kind: the kind of token, e.g. filename, number, other 5 | value: specific instance value, e.g. "/tmp/foo.c", or 5 6 | offset: byte offset from start of parse string 7 | """ 8 | 9 | def __init__(self, kind, value=None, offset=None): 10 | self.offset = offset 11 | self.kind = kind 12 | self.value = value 13 | 14 | def __eq__(self, o): 15 | """'==', but it's okay if offset is different""" 16 | if isinstance(o, Token): 17 | # Both are tokens: compare kind and value 18 | # It's okay if offsets are different 19 | return self.kind == o.kind 20 | else: 21 | return self.kind == o 22 | 23 | def __repr__(self): 24 | return str(self.kind) 25 | 26 | def __repr1__(self, indent, sib_num=""): 27 | return self.format(line_prefix=indent, sib_num=sib_num) 28 | 29 | def __str__(self): 30 | return self.format(line_prefix="") 31 | 32 | def format(self, line_prefix="", sib_num=None): 33 | if sib_num: 34 | sib_num = "%d." % sib_num 35 | else: 36 | sib_num = "" 37 | prefix = "%s%s" % (line_prefix, sib_num) 38 | offset_opname = "%5s %-10s" % (self.offset, self.kind) 39 | if not self.value: 40 | return "%s%s" % (prefix, offset_opname) 41 | return "%s%s %s" % (prefix, offset_opname, self.value) 42 | 43 | def __hash__(self): 44 | return hash(self.kind) 45 | 46 | def __getitem__(self, i): 47 | raise IndexError 48 | -------------------------------------------------------------------------------- /trepan/version.py: -------------------------------------------------------------------------------- 1 | # This file is needs to be multi-lingual in both Python and POSIX 2 | # shell which "exec()" or "source" it respectively. 3 | 4 | # This file should define a variable __version__ which we use as the 5 | # debugger version number. 6 | 7 | # fmt: off 8 | __version__="1.3.2.dev0" # noqa 9 | --------------------------------------------------------------------------------