Fix qemu.is_usermode and qemu.kernel

Tested with:
```
qemu-x86_64 -g 1234 `which ps`
gdb -nx `which ps` -ex 'target remote :1234'
```

Bug - we used `QOffsets` instead of `qOffsets`:
```
(gdb) maintenance packet QOffsets
sending: "QOffsets"
received: ""
(gdb) maintenance packet qOffsets
sending: "qOffsets"
received: "Text=0000004000000000;Data=0000004000000000;Bss=0000004000000000"
```

FWIW:
```
$ qemu-x86_64 --version
qemu-x86_64 version 5.2.0 (Debian 1:5.2+dfsg-9ubuntu3.1)
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers
$ uname -a
Linux dc 5.11.0-31-generic #33-Ubuntu SMP Wed Aug 11 13:19:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
```

Note:
```
(gdb) maintenance packet qAttached
sending: "qAttached"
received: "0"
```
pull/912/head
Disconnect3d 4 years ago
parent 2bef07faa0
commit 0068257ebe

@ -33,18 +33,15 @@ def is_usermode():
if not pwndbg.remote.is_remote(): if not pwndbg.remote.is_remote():
return False return False
# There is also 'qAttached' - maybe we can use it too?
# If we had QEMU 2.4 or better, we could use # for qemu user though it returned "0"?
# # Try with:
# maintenance packet QAttached: # qemu-x86_64 -g 1234 `which ps`
# # gdb -nx `which ps` -ex 'target remote :1234'
# However, Ubuntu 14 still has QEMU 2.2, so we have to use response = gdb.execute('maintenance packet qOffsets',
# a different command as a heuristic.
response = gdb.execute('maintenance packet QOffsets',
to_string=True, to_string=True,
from_tty=False) from_tty=False)
return 'Text=' in response return 'Text=' in response
@pwndbg.memoize.reset_on_stop @pwndbg.memoize.reset_on_stop

@ -11,6 +11,7 @@ import pwndbg.memoize
@pwndbg.memoize.reset_on_objfile @pwndbg.memoize.reset_on_objfile
@pwndbg.memoize.reset_on_start
def is_remote(): def is_remote():
# Example: # Example:
# pwndbg> maintenance print target-stack # pwndbg> maintenance print target-stack

Loading…
Cancel
Save