pwndbg/pwndbg

Implement common convenience variables

Open

#2,882 opened on Apr 16, 2025

View on GitHub
 (3 comments) (2 reactions) (0 assignees)Python (5,820 stars) (776 forks)batch import
featurehelp wanted

Description

Is your feature request related to a problem? Please describe. Essentially I don't want to type two extra characters.

We currently define some convenience functions, and adding more would be great, like mentioned in https://github.com/pwndbg/pwndbg/issues/2849 . It can probably be implemented such that p/x $heap(offset) returns a rebased value and p/x $heap() returns just the base of the heap. However, there should be no need to type ().

Describe the solution you'd like Gdb provides a facility called convinience variables: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Convenience-Vars.html For python api see https://sourceware.org/gdb/current/onlinedocs/gdb.html/Basic-Python.html and search gdb.convenience_variable and gdb.set_convenience_variable.

Additional context A user can define such a variable with set $awa = 0x1337 syntax, but even so I believe the variable names we define shouldn't have a preceding _, for example the variable for getting the base of the heap should be $heap and not $_heap because the risk of collision is really low in reality, and the _ is annoying to type.

Contributor guide