Skip to content

Commit f72bfb8

Browse files
committed
Support arbitrary regs definition order
1 parent da82023 commit f72bfb8

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

qiling/debugger/gdb/xmlregs.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,16 @@ def load_regsmap(archtype: QL_ARCH) -> Sequence[RegEntry]:
8787
QL_ARCH.MIPS : dict(**mips_regs_gpr, **mips_regs_fpu)
8888
}[archtype]
8989

90-
regmap = []
91-
pos = 0
92-
9390
xmlpath = __get_xml_path(archtype)
91+
regsinfo = sorted(__walk_xml_regs(*xmlpath))
9492

95-
for regnum, name, bitsize in __walk_xml_regs(*xmlpath):
96-
# regs indices might not be consecutive.
97-
# extend regmap with null entries if needed
98-
if len(regmap) < regnum + 1:
99-
regmap.extend([(None, 0, 0)] * (regnum + 1 - len(regmap)))
93+
# pre-allocate regmap and occupy it with null entries
94+
last_regnum = regsinfo[-1][0]
95+
regmap: Sequence[RegEntry] = [(None, 0, 0)] * (last_regnum + 1)
96+
97+
pos = 0
10098

99+
for regnum, name, bitsize in sorted(regsinfo):
101100
# reg value size in nibbles
102101
nibbles = bitsize // 4
103102

0 commit comments

Comments
 (0)