gdb doesn't allow debugging itself:
```
attachp some-nonexistent-process-name
Attaching to 361478
Error: I refuse to debug myself!
```
This fixes the test_attachp_command_nonexistent_procname test for me.
* Fix terminal width to 80 columns in tests
Set a `PWNDBG_IN_TEST`environment variable when running gdb in tests. Use the dimensions in `LINES` and `COLUMNS` when looking up the window size when that envvar is set.
This makes context output always be 80 columns wide which allows to compare to hardcoded output.
* Use `width` and `height` parameters for cmd window size
They are updated to the correct values when switching between tui and cli mode. So it's unnecessary to parse `info win`.
* Remove workarounds for terminal size in DEVELOPING
* Don't bother updating the env of the debuggee
* Add history of context output
Every context section is cached individually to allow to display older output again. You can scroll through the old context output using `contextprev` and `contextnext`.
This allows to "scroll" in TUI mode.
* Add button TUI window to control context history
* Simplify history status output generation
termios.tcgetwinsize and termios.tcsetwinsize were added in Python 3.11, which caused undefined-attr typing errors when linting on python 3.10.
mypy doesn't support the Python version indirection of a global constant, so move the condition into the if statement.
The __doc__ is read in the gdb.Function constructor, so copy it from the function to the class in the decorator before calling the parent constructor.
`apropos` displays the first line of the docstring only, so move it up in the `bn_*` commands.
* Fix attachp tests when ptrace_scope is missing
Assume we can attach to any process when ptrace_scope is not available. This is the case in WSL2.
* Update tests/gdb-tests/tests/test_attachp.py
---------
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
* Remove SIGWINCH signal handler
gdb updates `height` and `width` automatically since 2015,
so this code seems to be obsolete.
Installing our own signal handler replaced gdb's one and prevented it from reacting to SIGWINCH signals.
* Add context sections TUI windows
This adds `pwndbg_[section]` tui windows to be used in a layout.
You can arrange `pwndbg_regs` or `pwndbg_disasm` as you wish.
The horizontal scrolling and truncation has to consider ANSI escape codes and makes sure to include all of them while scrolling through to properly keep the colors.
Since there is no event fired when TUI mode is enabled/disabled, we have to check `.is_valid()` whenever context data is available or the TUI is rendered to redirect context output appropriately again.
* Make last-signal context section selectable
There exists a context section to display the reason for the last stop, but it wasn't registered anywhere.
Add it to the list of available sections to choose from.
* Fix default context sections "heap-tracker"
The section name is derived from the function name.
The function is called `context_heap_tracker` so `heap-tracker` wouldn't work:
```
pwndbg> set context-sections heap-tracker
Invalid section: heap-tracker, valid values: args, regs, disasm, stack, backtrace, code, expressions, ghidra, heap_tracker, threads
```
The validator doesn't appear to run for the default value :D
* Update help text to include all available context sections
* gdblib & aglib proc now returns executed filename
+ executed filename received through "info proc exe"
+ previous the local filename was returned, which could be different from remote
+ this also fixes#2430
+ fixed softlock if `set integration-provider binja`
* Update pwndbg/aglib/proc.py
* Update pwndbg/gdblib/proc.py
* Update pwndbg/gdblib/proc.py
* fixed binja integration issues
+ ensure current process is alive, for needed events
+ handle ConnectionErrors correctly
* fixed binja integration issues
+ ensure current process is alive, for needed events
+ handle ConnectionErrors correctly
---------
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
* Replace bash with sleep in attachp commands to fix crash due to reading from terminal
* Update tests/gdb-tests/tests/test_attachp.py
* Update test_attachp.py
---------
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
* Fixed bug where plist()'s argument sentinel had incorrect type
* Fixed bug where if sentinel was different from zero, plist tried to dereference a null address
* Fixed bug where some error message in plist displayed 0x0x{address} due to incorrect formatting
* Added additional tests for plist's bugfixes
* Added types to hexdump()'s parameters
* hexdump(): upgraded format strings to f-strings, while fixing the offset when data is empty
* hexdump(): offset is now correctly computed and updated accross repeated calls to hexdump.
This fixes two bugs:
1. Offset was increased by the number of lines displayed by the hexdump() command,
which was incorrect, as some lines may be compressed;
2. When dumping a number of bytes that is not divisible by the number of bytes per line,
offset would be incorrectly updated.
* Linter
* hexdump: fixed type of retrieved config entry hexdump_group_use_big_endian
* Fixed test_hexdump_saved_address_and_offset test to account for random stack address
* Upgraded the linked-lists.c test program to 6 items in order to test the "deference-limit" setting
* Chain: changes to the deference-limit parameter were not reflected in the program due to an early cast to int()
* Linter
* Added support for `--offset` and `--count` for plist
* Added typing to commands.plist's prototype
* Updated documentation for plist tests
* Add informational message when plist --count is zero or under
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
* Handle case, in plist, where the default value for count is zero
---------
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
* Added types to hexdump()'s parameters
* hexdump(): upgraded format strings to f-strings, while fixing the offset when data is empty
* hexdump(): offset is now correctly computed and updated accross repeated calls to hexdump.
This fixes two bugs:
1. Offset was increased by the number of lines displayed by the hexdump() command,
which was incorrect, as some lines may be compressed;
2. When dumping a number of bytes that is not divisible by the number of bytes per line,
offset would be incorrectly updated.
* Linter
* hexdump: fixed type of retrieved config entry hexdump_group_use_big_endian
* Fixed test_hexdump_saved_address_and_offset test to account for random stack address
* Upgraded the linked-lists.c test program to 6 items in order to test the "deference-limit" setting
* Chain: changes to the deference-limit parameter were not reflected in the program due to an early cast to int()
* Linter
* Implement remaining functions in `aglib.memory` and tie some loose ends
* Update pwndbg/aglib/memory.py
---------
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
* Port Pwndbg to LLDB
* Fix splitting mistakes
* I love typos
* We already check for Python 3.11 manually
* Update pwndbg/dbg/lldb/__init__.py
Co-authored-by: patryk4815 <bux.patryk@gmail.com>
* Fix use of wrong variable name that was preventing the vmmap from being used in LLDB memory reads
* Use cached vmmap for `read_memory` in LLDB
* Fix Pwndbg CLI jank
* Try using SBAddress to resolve objfile names in LLDB vmmap
* Fix missing changes in `pwndbg.gdblib`
* Update pwndbg/aglib/arch.py
* Update pwndbg/aglib/arch.py
* Remove outdated comment about `pwndbg.aglib.arch`
* Update pwndbg/dbg/lldb/repl/io.py
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
* Fix lints
* Fix new test so that it points to `pwndbg.aglib.disasm`
* Fix lints
---------
Co-authored-by: patryk4815 <bux.patryk@gmail.com>
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
We don't have an ARM64 runner for creating release binaries since ~6 months.
Commenting this out until GitHub finally allows open source projects to use its own arm64 runners.
* Merge Arm tests
* Integrate MIPS, AArch64, RISC-V tests, and the rest of the ARM edges cases
* add fsbase/gsbase annotation test
* add function call / fin test
* lint
* Fix all bugs found - MIPS JAL, delay slots splits, arm/aarch unconditional jumps, and forcing targets when we know they go to the next instruction in memory, and add a bunch of comments. Arm now detects instructions that write to PC as branches too.
* Fix Arm exclusive stores
* comment update
* Fix arm/aarch64 post-indexed stores - add test
* AArch64 post-index stores
* Fix arm shifts
* comment typo