File: insn_check.py

package info (click to toggle)
capstone 5.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie, trixie-proposed-updates
  • size: 58,188 kB
  • sloc: ansic: 96,086; cpp: 67,489; cs: 29,510; python: 25,829; pascal: 24,412; java: 15,582; ml: 14,473; makefile: 1,275; sh: 479; ruby: 386
file content (25 lines) | stat: -rwxr-xr-x 720 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python
# check MappingInsn.inc to find potential incorrect mapping - for Capstone disassembler.
# by Nguyen Anh Quynh, 2019

import sys

if len(sys.argv) == 1:
    print("Syntax: %s <MappingInsn.inc>" %sys.argv[0])
    sys.exit(1)

#    ARM_CMPri, ARM_INS_CMN,
f = open(sys.argv[1])
lines = f.readlines()
f.close()

for line in lines:
    if '_INS_' in line:
        tmp = line.strip().split(',')
        if len(tmp) == 3 and tmp[2] == '':
            id_private = tmp[0].strip()
            id_public = tmp[1].strip()
            pos = id_public.find('_INS_')
            mnem = id_public[pos + len('_INS_'):]
            if not mnem in id_private:
                print("%s -> %s" %(id_private, id_public))