ds is broken on dev 6aeffbea246870fdc3af569b1bb16e51a3e2f667
Running the command results in Exception occured: ds: %x format: an integer is required, not gdb.Value (<class 'TypeError'>).
I looked at pwndbg/commands/windbg.py and managed to fix it by casting the address argument to int, but I'm not sure if this is the best solution.
@devneal Thanks for reporting the problem. The command seems to partially work - e.g. it can print strings from given addresses but if you provide no args or a missing symbol it shows lke something wrong has happened. What was the thing you have tried?
This is how it works on my side (latest dev):
pwndbg> set exception-verbose on
Set whether to print a full stacktracefor exceptions raised in Pwndbg commands to True
pwndbg> version
Gdb: GNU gdb (GDB) 8.0.1
Python: 3.6.3 (default, Oct 24 2017, 14:48:20) [GCC 7.2.0]
Pwndbg: 1.0.0 build: 3ac1047
pwndbg> ds
'ds': Dump a string at the specified address.
Traceback (most recent call last):
File "/home/dc/installed/pwndbg/pwndbg/commands/__init__.py", line 100, in __call__
return self.function(*args, **kwargs)
File "/home/dc/installed/pwndbg/pwndbg/commands/__init__.py", line 192, in _OnlyWhenRunning
return function(*a, **kw)
TypeError: ds() missing 1 required positional argument: 'address'
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)
PS: Pull requests are welcome
pwndbg> ds 1
1 None
pwndbg> ds $rax
1c None
pwndbg> ds ls
No symbol table is loaded. Use the "file" command.
'ds': Dump a string at the specified address.
Traceback (most recent call last):
File "/home/dc/installed/pwndbg/pwndbg/commands/__init__.py", line 100, in __call__
return self.function(*args, **kwargs)
File "/home/dc/installed/pwndbg/pwndbg/commands/__init__.py", line 192, in _OnlyWhenRunning
return function(*a, **kw)
TypeError: ds() missing 1 required positional argument: 'address'
pwndbg> ds 0x7fffffffda1d
7fffffffda1d '/usr/bin/ls'
Could you provide your exact case? Would you mind on trying to fix it, make it use ArgparsedCommand and make a pull request?
About ArgparsedCommand: we are moving all commands to use ArgparsedCommand decorator and argparse for argument parsing.
As for the argument type to be used within the parser for the address argument - the pwndbg.commands.sloppy_gdb_parse might be of good use here, however I am not 100% sure. See https://github.com/pwndbg/pwndbg/blob/dev/pwndbg/commands/vmmap.py#L41-L42 for an example.
Thanks for responding. I've included my output below. As I said before, the command works if I cast the address variable to int in pwndbg/commands/windbg.py. Do you know of some difference between gdb 7.11 and gdb 8 or python 3.5 and python 3.6 that could be causing this?
pwndbg> set exception-verbose on
Set whether to print a full stacktracefor exceptions raised in Pwndbg commands to True
pwndbg> version
Gdb: GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Python: 3.5.2 (default, Sep 14 2017, 22:51:06) [GCC 5.4.0 20160609]
Pwndbg: 1.0.0 build: 3ac1047
pwndbg> ds
'ds': Dump a string at the specified address.
Traceback (most recent call last):
File "/home/devneal/Public/pwndbg/pwndbg/commands/__init__.py", line 100, in __call__
return self.function(*args, **kwargs)
File "/home/devneal/Public/pwndbg/pwndbg/commands/__init__.py", line 192, in _OnlyWhenRunning
return function(*a, **kw)
TypeError: ds() missing 1 required positional argument: 'address'
pwndbg> ds 1
'ds': Dump a string at the specified address.
Traceback (most recent call last):
File "/home/devneal/Public/pwndbg/pwndbg/commands/__init__.py", line 100, in __call__
return self.function(*args, **kwargs)
File "/home/devneal/Public/pwndbg/pwndbg/commands/__init__.py", line 192, in _OnlyWhenRunning
return function(*a, **kw)
File "/home/devneal/Public/pwndbg/pwndbg/commands/windbg.py", line 233, in ds
print("%x" % address, repr(pwndbg.strings.get(address, max)))
TypeError: %x format: an integer is required, not gdb.Value
pwndbg> ds $rax
'ds': Dump a string at the specified address.
Traceback (most recent call last):
File "/home/devneal/Public/pwndbg/pwndbg/commands/__init__.py", line 100, in __call__
return self.function(*args, **kwargs)
File "/home/devneal/Public/pwndbg/pwndbg/commands/__init__.py", line 192, in _OnlyWhenRunning
return function(*a, **kw)
File "/home/devneal/Public/pwndbg/pwndbg/commands/windbg.py", line 233, in ds
print("%x" % address, repr(pwndbg.strings.get(address, max)))
TypeError: %x format: an integer is required, not gdb.Value
pwndbg> ds 0x4006d4
'ds': Dump a string at the specified address.
Traceback (most recent call last):
File "/home/devneal/Public/pwndbg/pwndbg/commands/__init__.py", line 100, in __call__
return self.function(*args, **kwargs)
File "/home/devneal/Public/pwndbg/pwndbg/commands/__init__.py", line 192, in _OnlyWhenRunning
return function(*a, **kw)
File "/home/devneal/Public/pwndbg/pwndbg/commands/windbg.py", line 233, in ds
print("%x" % address, repr(pwndbg.strings.get(address, max)))
TypeError: %x format: an integer is required, not gdb.Value
pwndbg>
I'd be happy to submit a pull request, but I'd like to be sure what the problem is before blindly casting to int, so I'll look into it more.
@devneal Thanks! That really looks like it might be related to Python/GDB version.
If you want to build particular gdb version, here is a little script I used few times to build 7.11 and 8.0:
wget https://ftp.gnu.org/gnu/gdb/gdb-7.12.tar.xz
tar -xvf gdb-7.12.tar.xz
cd gdb-7.12
mkdir build
cd build
../configure --prefix=/usr --disable-nls --disable-werror --with-system-readline --with-python=/usr/bin/python3.6 --with-system-gdbinit=/etc/gdb/gdbinit --enable-targets=all
make -j4
sudo make install
Note: this might require you to install some dependencies like readline dev library.
I've confirmed that the command works with gdb 8.0.1 + python 3.5.2 but fails with gdb 7.11.1 + python 3.5.2. The readme says pwndbg is best supported with ubuntu 16.04 (which has python 3.5.2 by default) + gdb 7.11, so this should be fixed. I'll look into ArgparsedCommand and submit a pr soon.
I've submitted a pull request at https://github.com/pwndbg/pwndbg/pull/364.
Closing as this has been fixed thx to PR https://github.com/pwndbg/pwndbg/pull/364.
Most helpful comment
I've confirmed that the command works with gdb 8.0.1 + python 3.5.2 but fails with gdb 7.11.1 + python 3.5.2. The readme says pwndbg is best supported with ubuntu 16.04 (which has python 3.5.2 by default) + gdb 7.11, so this should be fixed. I'll look into ArgparsedCommand and submit a pr soon.