Skip to content

Commit fe462b8

Browse files
authored
Merge pull request #1600 from 0xMirasio/master
PPC debugger XML support
2 parents 83c6fb9 + 08650be commit fe462b8

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

qiling/debugger/gdb/gdb.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ def handle_qmark(subcmd: str) -> Reply:
183183
from unicorn.arm_const import UC_ARM_REG_R11
184184
from unicorn.arm64_const import UC_ARM64_REG_X29
185185
from unicorn.mips_const import UC_MIPS_REG_INVALID
186+
from unicorn.ppc_const import UC_PPC_REG_31
186187

187188
arch_uc_bp = {
188189
QL_ARCH.X86 : UC_X86_REG_EBP,
@@ -191,7 +192,8 @@ def handle_qmark(subcmd: str) -> Reply:
191192
QL_ARCH.ARM64 : UC_ARM64_REG_X29,
192193
QL_ARCH.MIPS : UC_MIPS_REG_INVALID, # skipped
193194
QL_ARCH.A8086 : UC_X86_REG_EBP,
194-
QL_ARCH.CORTEX_M : UC_ARM_REG_R11
195+
QL_ARCH.CORTEX_M : UC_ARM_REG_R11,
196+
QL_ARCH.PPC : UC_PPC_REG_31
195197
}[self.ql.arch.type]
196198

197199
def __get_reg_idx(ucreg: int) -> int:
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0"?>
2+
<!-- Copyright (C) 2007-2020 Free Software Foundation, Inc.
3+
4+
Copying and distribution of this file, with or without modification,
5+
are permitted in any medium without royalty provided the copyright
6+
notice and this notice are preserved. -->
7+
8+
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
9+
<feature name="org.gnu.gdb.power.core">
10+
<reg name="r0" bitsize="32" type="uint32"/>
11+
<reg name="r1" bitsize="32" type="uint32"/>
12+
<reg name="r2" bitsize="32" type="uint32"/>
13+
<reg name="r3" bitsize="32" type="uint32"/>
14+
<reg name="r4" bitsize="32" type="uint32"/>
15+
<reg name="r5" bitsize="32" type="uint32"/>
16+
<reg name="r6" bitsize="32" type="uint32"/>
17+
<reg name="r7" bitsize="32" type="uint32"/>
18+
<reg name="r8" bitsize="32" type="uint32"/>
19+
<reg name="r9" bitsize="32" type="uint32"/>
20+
<reg name="r10" bitsize="32" type="uint32"/>
21+
<reg name="r11" bitsize="32" type="uint32"/>
22+
<reg name="r12" bitsize="32" type="uint32"/>
23+
<reg name="r13" bitsize="32" type="uint32"/>
24+
<reg name="r14" bitsize="32" type="uint32"/>
25+
<reg name="r15" bitsize="32" type="uint32"/>
26+
<reg name="r16" bitsize="32" type="uint32"/>
27+
<reg name="r17" bitsize="32" type="uint32"/>
28+
<reg name="r18" bitsize="32" type="uint32"/>
29+
<reg name="r19" bitsize="32" type="uint32"/>
30+
<reg name="r20" bitsize="32" type="uint32"/>
31+
<reg name="r21" bitsize="32" type="uint32"/>
32+
<reg name="r22" bitsize="32" type="uint32"/>
33+
<reg name="r23" bitsize="32" type="uint32"/>
34+
<reg name="r24" bitsize="32" type="uint32"/>
35+
<reg name="r25" bitsize="32" type="uint32"/>
36+
<reg name="r26" bitsize="32" type="uint32"/>
37+
<reg name="r27" bitsize="32" type="uint32"/>
38+
<reg name="r28" bitsize="32" type="uint32"/>
39+
<reg name="r29" bitsize="32" type="uint32"/>
40+
<reg name="r30" bitsize="32" type="uint32"/>
41+
<reg name="r31" bitsize="32" type="uint32"/>
42+
43+
<reg name="cr" bitsize="32" type="uint32"/>
44+
<reg name="lr" bitsize="32" type="code_ptr"/>
45+
<reg name="pc" bitsize="32" type="code_ptr"/>
46+
<reg name="msr" bitsize="32" type="uint32"/>
47+
<reg name="ctr" bitsize="32" type="uint32"/>
48+
<reg name="xer" bitsize="32" type="uint32"/>
49+
50+
51+
</feature>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!-- Copyright (C) 2009-2016 Free Software Foundation, Inc.
3+
4+
*!Copying and distribution of this file, with or without modification,
5+
*!are permitted in any medium without royalty provided the copyright
6+
*!notice and this notice are preserved. -->
7+
8+
<!DOCTYPE target SYSTEM "gdb-target.dtd">
9+
<target xmlns:xi="http://www.w3.org/2001/XInclude">
10+
<architecture>powerpc:common</architecture>
11+
<xi:include href="ppc-core.xml"/>
12+
</target>

qiling/debugger/gdb/xmlregs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
reg_map_ymm as x86_regs_ymm
3939
)
4040

41+
from qiling.arch.ppc_const import (
42+
reg_map as ppc_regs
43+
)
44+
4145
from qiling.const import QL_ARCH, QL_OS
4246

4347
RegEntry = Tuple[Optional[int], int, int]
@@ -142,7 +146,8 @@ def __load_regsmap(archtype: QL_ARCH, xmltree: ElementTree.ElementTree) -> Seque
142146
QL_ARCH.ARM: dict(**arm_regs, **arm_regs_vfp, **arm_regs_q, **arm_regs_s),
143147
QL_ARCH.CORTEX_M: dict(**cortex_m_regs),
144148
QL_ARCH.ARM64: dict(**arm64_regs, **arm64_regs_v, **arm64_reg_map_fp),
145-
QL_ARCH.MIPS: dict(**mips_regs_gpr)
149+
QL_ARCH.MIPS: dict(**mips_regs_gpr),
150+
QL_ARCH.PPC: dict(**ppc_regs)
146151
}[archtype]
147152

148153
regsinfo = sorted(QlGdbFeatures.__walk_xml_regs(xmltree))

0 commit comments

Comments
 (0)