|
6 | 6 | # gdbserver --remote-debug 0.0.0.0:9999 /path/to binary |
7 | 7 | # documentation: according to https://sourceware.org/gdb/current/onlinedocs/gdb/Remote-Protocol.html#Remote-Protocol |
8 | 8 |
|
9 | | -from unicorn import * |
10 | | - |
11 | | -import struct, os, re, socket |
| 9 | +import struct, os, socket |
12 | 10 | from binascii import unhexlify |
| 11 | +from typing import Iterator, Literal |
13 | 12 |
|
14 | | -from .utils import QlGdbUtils |
| 13 | +from qiling import Qiling |
15 | 14 | from qiling.const import * |
16 | 15 | from qiling.utils import * |
17 | 16 | from qiling.debugger import QlDebugger |
|
25 | 24 | from qiling.arch.mips_const import reg_map as mips_reg_map |
26 | 25 | from qiling.loader.elf import AUX |
27 | 26 |
|
| 27 | +from .utils import QlGdbUtils |
| 28 | + |
28 | 29 | GDB_SIGNAL_INT = 2 |
29 | 30 | GDB_SIGNAL_SEGV = 11 |
30 | 31 | GDB_SIGNAL_GILL = 4 |
@@ -222,13 +223,13 @@ def handle_g(subcmd): |
222 | 223 | s += tmp |
223 | 224 |
|
224 | 225 | elif self.ql.archtype == QL_ARCH.ARM: |
225 | | - mode = self.ql.arch.check_thumb() |
| 226 | + |
226 | 227 |
|
227 | 228 | # r0-r12,sp,lr,pc,cpsr ,see https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/arch/arm.h;h=fa589fd0582c0add627a068e6f4947a909c45e86;hb=HEAD#l127 |
228 | 229 | for reg in self.tables[QL_ARCH.ARM][:16] + [self.tables[QL_ARCH.ARM][25]]: |
229 | | - r = self.ql.reg.read(reg) |
230 | | - if mode == UC_MODE_THUMB and reg == "pc": |
231 | | - r += 1 |
| 230 | + # if reg is pc, make sure to take thumb mode into account |
| 231 | + r = self.ql.arch.get_pc() if reg == "pc" else self.ql.reg.read(reg) |
| 232 | + |
232 | 233 | tmp = self.addr_to_str(r) |
233 | 234 | s += tmp |
234 | 235 |
|
|
0 commit comments