mirror of https://github.com/pwndbg/pwndbg.git
Fix dt command when an address is passed (#2395)
* Fix dt command when an address is passed
`pwndbg.commands.fix()` expects a string, while an integer was passed.
```
pwndbg> dt "struct malloc_state" 0x7ffff7b99b78
Traceback (most recent call last):
File "/home/ubuntu/.local/share/pwndbg/pwndbg/commands/__init__.py", line 187, in __call__
return self.function(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/.local/share/pwndbg/pwndbg/commands/dt.py", line 34, in dt
address = pwndbg.commands.fix(address) # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/.local/share/pwndbg/pwndbg/commands/__init__.py", line 245, in fix
arg = arg.strip()
^^^^^^^^^
AttributeError: 'int' object has no attribute 'strip'
If that is an issue, you can report it on https://github.com/pwndbg/pwndbg/issues
(Please don't forget to search if it hasn't been reported before)
To generate the report and open a browser, you may run `bugreport --run-browser`
PS: Pull requests are welcome
pwndbg>
```
After this patch:
```
pwndbg> dt "struct malloc_state" 0x7ffff7b99b78
struct malloc_state @ 0x7ffff7b99b78
+0x0000 mutex : mutex_t
+0x0004 flags : int
+0x0008 fastbinsY : mfastbinptr [10]
+0x0058 top : mchunkptr
+0x0060 last_remainder : mchunkptr
+0x0068 bins : mchunkptr [254]
+0x0858 binmap : unsigned int [4]
+0x0868 next : struct malloc_state *
+0x0870 next_free : struct malloc_state *
+0x0878 attached_threads : size_t
+0x0880 system_mem : size_t
+0x0888 max_system_mem : size_t
```
* When using dt with an address show the address of each field
Note that the `bitpos` is not accunted for, but it's still showed in the relative offset
```
pwndbg> dt "struct malloc_state"
struct malloc_state
+0x0000 mutex : mutex_t
+0x0004 flags : int
+0x0008 fastbinsY : mfastbinptr [10]
+0x0058 top : mchunkptr
+0x0060 last_remainder : mchunkptr
+0x0068 bins : mchunkptr [254]
+0x0858 binmap : unsigned int [4]
+0x0868 next : struct malloc_state *
+0x0870 next_free : struct malloc_state *
+0x0878 attached_threads : size_t
+0x0880 system_mem : size_t
+0x0888 max_system_mem : size_t
pwndbg> dt "struct malloc_state" 0x7ffff7b99b78
struct malloc_state @ 0x7ffff7b99b78
0x00007ffff7b99b78 +0x0000 mutex : mutex_t
0x00007ffff7b99b7c +0x0004 flags : int
0x00007ffff7b99b80 +0x0008 fastbinsY : mfastbinptr [10]
0x00007ffff7b99bd0 +0x0058 top : mchunkptr
0x00007ffff7b99bd8 +0x0060 last_remainder : mchunkptr
0x00007ffff7b99be0 +0x0068 bins : mchunkptr [254]
0x00007ffff7b9a3d0 +0x0858 binmap : unsigned int [4]
0x00007ffff7b9a3e0 +0x0868 next : struct malloc_state *
0x00007ffff7b9a3e8 +0x0870 next_free : struct malloc_state *
0x00007ffff7b9a3f0 +0x0878 attached_threads : size_t
0x00007ffff7b9a3f8 +0x0880 system_mem : size_t
0x00007ffff7b9a400 +0x0888 max_system_mem : size_t
```
* Update pwndbg/gdblib/dt.py
---------
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
pull/2398/head
parent
27ccbbaceb
commit
3cf0985014
Loading…
Reference in new issue