Skip to content

Commit b63810d

Browse files
committed
Misc cleanup
1 parent 15d4efe commit b63810d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

qiling/debugger/gdb/gdb.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
# gdbserver --remote-debug 0.0.0.0:9999 /path/to binary
77
# documentation: according to https://sourceware.org/gdb/current/onlinedocs/gdb/Remote-Protocol.html#Remote-Protocol
88

9-
from unicorn import *
10-
11-
import struct, os, re, socket
9+
import struct, os, socket
1210
from binascii import unhexlify
11+
from typing import Iterator, Literal
1312

14-
from .utils import QlGdbUtils
13+
from qiling import Qiling
1514
from qiling.const import *
1615
from qiling.utils import *
1716
from qiling.debugger import QlDebugger
@@ -25,6 +24,8 @@
2524
from qiling.arch.mips_const import reg_map as mips_reg_map
2625
from qiling.loader.elf import AUX
2726

27+
from .utils import QlGdbUtils
28+
2829
GDB_SIGNAL_INT = 2
2930
GDB_SIGNAL_SEGV = 11
3031
GDB_SIGNAL_GILL = 4
@@ -222,13 +223,13 @@ def handle_g(subcmd):
222223
s += tmp
223224

224225
elif self.ql.archtype == QL_ARCH.ARM:
225-
mode = self.ql.arch.check_thumb()
226+
226227

227228
# 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
228229
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+
232233
tmp = self.addr_to_str(r)
233234
s += tmp
234235

0 commit comments

Comments
 (0)