How to use print_entry method in Playwright Python

Best Python code snippet using playwright-python

mapping_insn_op-arch.py

Source:mapping_insn_op-arch.py Github

copy

Full Screen

...92#},93#{ /* ARM_ADCri, ARM_INS_ADC: adc${s}${p} $rd, $rn, $imm */94# { CS_AC_WRITE, CS_AC_READ, 0 }95#},96def print_entry(arch, insn_id, mnem, mapping, mnem_can_be_wrong):97 insn = "%s_%s" %(arch, insn_id)98 arch1 = arch99 if arch.upper() == 'AARCH64':100 arch1 = 'ARM64'101 # first, try to find this entry in old MappingInsn.inc file102 for i in range(len(mapping)):103 if mapping[i].startswith('{') and '/*' in mapping[i]:104 #print(mapping[i])105 tmp = mapping[i].split('/*')106 tmp = tmp[1].strip()107 tmp = tmp.split(',')108 #print("insn2 = |%s|" %tmp.strip())109 if tmp[0].strip() == insn:110 if not mnem_can_be_wrong:111 if arch.upper() == 'ARM':112 print('''113{\t/* %s, %s_INS_%s: %s */114\t%s115},'''% (insn, arch1, mnem, mnem.lower(), mapping[i + 1].strip()))116 else: # ARM64117 print('''118{\t/* %s, %s_INS_%s: %s */119\t%s120\t%s121},'''% (insn, arch, mnem, mnem.lower(), mapping[i + 1].strip(), mapping[i + 2].strip()))122 else:123 if arch.upper() == 'ARM':124 print('''125{\t/* %s, %s126\t%s127},'''% (insn, ''.join(tmp[1:]), mapping[i + 1].strip()))128 else: # ARM64129 print('''130{\t/* %s, %s131\t%s132\t%s133},'''% (insn, ''.join(tmp[1:]), mapping[i + 1].strip(), mapping[i + 2].strip()))134 return135 if mnem_can_be_wrong:136 #print("======== CANNOT FIND %s, mapping to %s" %(insn, mnem))137 return138 pass139 # this insn does not exist in mapping table140 if arch.upper() == 'ARM':141 print('''142{\t/* %s, %s_INS_%s: %s */143\t{ 0 }144},'''% (insn, arch1, mnem, mnem.lower()))145 else:146 print('''147{\t/* %s, %s_INS_%s: %s */148\t0,149\t{ 0 }150},'''% (insn, arch, mnem, mnem.lower()))151# extract from GenInstrInfo.inc, because the insn id is in order152enum_count = 0153meet_insn = False154f = open(sys.argv[2])155lines = f.readlines()156f.close()157count = 0158last_mnem = None159def is_pseudo_insn(insn, lines):160 return False161 for line in lines:162 tmp = '= %s' %insn163 if tmp in line and 'MCID::Pseudo' in line:164 return True165 return False166# 1st enum is register enum167for line in lines:168 line = line.rstrip()169 if len(line.strip()) == 0:170 continue171 if line.strip() == 'enum {':172 enum_count += 1173 #print(line.strip())174 continue175 line = line.strip()176 if enum_count == 1:177 # skip pseudo instructions178 if '__' in line or 'setjmp' in line or 'longjmp' in line or 'Pseudo' in line:179 continue180 elif 'INSTRUCTION_LIST_END' in line:181 break182 else:183 insn = line.split('=')[0].strip()184 # skip more pseudo instruction185 if is_pseudo_insn(insn, lines):186 continue187 '''188 insn = None189 if meet_insn:190 # enum items191 insn = line.split('=')[0].strip()192 if 'CALLSTACK' in insn or 'TAILJUMP' in insn:193 # pseudo instruction194 insn = None195 elif line.startswith(first_insn):196 insn = line.split('=')[0].strip()197 meet_insn = True198 if insn:199 count += 1200 if insn == 'BSWAP16r_BAD':201 last_mnem = 'BSWAP'202 print_entry(arch.upper(), insn, last_mnem, mapping, False)203 elif insn == 'CMOVNP_Fp32':204 last_mnem = 'FCMOVNP'205 print_entry(arch.upper(), insn, last_mnem, mapping, False)206 elif insn == 'CMOVP_Fp3':207 last_mnem = 'FCMOVP'208 print_entry(arch.upper(), insn, last_mnem, mapping, False)209 elif insn == 'CMPSDrm_Int':210 last_mnem = 'CMPSD'211 print_entry(arch.upper(), insn, last_mnem, mapping, False)212 elif insn == 'MOVSX16rm16':213 last_mnem = 'MOVSX'214 print_entry(arch.upper(), insn, last_mnem, mapping, False)215 elif insn == 'MOVZX16rm16':216 last_mnem = 'MOVZX'217 print_entry(arch.upper(), insn, last_mnem, mapping, False)218 elif insn == 'ST_Fp32m':219 last_mnem = 'FST'220 print_entry(arch.upper(), insn, last_mnem, mapping, False)221 elif insn == 'CMOVNP_Fp64':222 last_mnem = 'FCMOVNU'223 print_entry(arch.upper(), insn, last_mnem, mapping, False)224 elif insn == 'CMPSDrr_Int':225 last_mnem = 'CMPSD'226 print_entry(arch.upper(), insn, last_mnem, mapping, False)227 elif insn == 'CMPSSrm_Int':228 last_mnem = 'CMPSS'229 print_entry(arch.upper(), insn, last_mnem, mapping, False)230 elif insn == 'VCMPSDrm_Int':231 last_mnem = 'VCMPSD'232 print_entry(arch.upper(), insn, last_mnem, mapping, False)233 elif insn == 'VCMPSSrm_Int':234 last_mnem = 'VCMPSS'235 print_entry(arch.upper(), insn, last_mnem, mapping, False)236 elif insn == 'VPCMOVYrrr_REV':237 last_mnem = 'VPCMOV'238 print_entry(arch.upper(), insn, last_mnem, mapping, False)239 elif insn == 'VRNDSCALESDZm':240 last_mnem = 'VRNDSCALESD'241 print_entry(arch.upper(), insn, last_mnem, mapping, False)242 elif insn == 'VRNDSCALESSZm':243 last_mnem = 'VRNDSCALESS'244 print_entry(arch.upper(), insn, last_mnem, mapping, False)245 elif insn == 'VMAXCPDZ128rm':246 last_mnem = 'VMAXPD'247 print_entry(arch.upper(), insn, last_mnem, mapping, False)248 elif insn == 'VMAXCPSZ128rm':249 last_mnem = 'VMAXPS'250 print_entry(arch.upper(), insn, last_mnem, mapping, False)251 elif insn == 'VMAXCSDZrm':252 last_mnem = 'VMAXSD'253 print_entry(arch.upper(), insn, last_mnem, mapping, False)254 elif insn == 'VMAXCSSZrm':255 last_mnem = 'VMAXSS'256 print_entry(arch.upper(), insn, last_mnem, mapping, False)257 elif insn == 'VMINCPDZ128rm':258 last_mnem = 'VMINPD'259 print_entry(arch.upper(), insn, last_mnem, mapping, False)260 elif insn == 'VMINCPSZ128rm':261 last_mnem = 'VMINPS'262 print_entry(arch.upper(), insn, last_mnem, mapping, False)263 elif insn == 'VMINCSDZrm':264 last_mnem = 'VMINSD'265 print_entry(arch.upper(), insn, last_mnem, mapping, False)266 elif insn == 'VMINCSSZrm':267 last_mnem = 'VMINSS'268 print_entry(arch.upper(), insn, last_mnem, mapping, False)269 elif insn == 'VMOV64toPQIZrm':270 last_mnem = 'VMOVQ'271 print_entry(arch.upper(), insn, last_mnem, mapping, False)272 elif insn == 'VPERMIL2PDYrr_REV':273 last_mnem = 'VPERMILPD'274 print_entry(arch.upper(), insn, last_mnem, mapping, False)275 elif insn == 'VPERMIL2PSYrr_REV':276 last_mnem = 'VPERMILPS'277 print_entry(arch.upper(), insn, last_mnem, mapping, False)278 elif insn == 'VCVTSD2SI64Zrm_Int':279 last_mnem = 'VCVTSD2SI'280 print_entry(arch.upper(), insn, last_mnem, mapping, False)281 elif insn == 'VCVTSD2SSrm_Int':282 last_mnem = 'VCVTSD2SS'283 print_entry(arch.upper(), insn, last_mnem, mapping, False)284 elif insn == 'VCVTSS2SI64Zrm_Int':285 last_mnem = 'VCVTSS2SI'286 print_entry(arch.upper(), insn, last_mnem, mapping, False)287 elif insn == 'VCVTTSD2SI64Zrm_Int':288 last_mnem = 'VCVTTSD2SI'289 print_entry(arch.upper(), insn, last_mnem, mapping, False)290 elif insn == 'VCVTTSS2SI64Zrm_Int':291 last_mnem = 'VCVTTSS2SI'292 print_entry(arch.upper(), insn, last_mnem, mapping, False)293 elif insn.startswith('VFMSUBADD'):294 if insn[len('VFMSUBADD')].isdigit():295 last_mnem = insn[:len('VFMSUBADD123xy')]296 else:297 last_mnem = insn[:len('VFMSUBADDSS')]298 print_entry(arch.upper(), insn, last_mnem, mapping, False)299 elif insn.startswith('VFMADDSUB'):300 if insn[len('VFMADDSUB')].isdigit():301 last_mnem = insn[:len('VFMADDSUB123xy')]302 else:303 last_mnem = insn[:len('VFMADDSUBSS')]304 print_entry(arch.upper(), insn, last_mnem, mapping, False)305 elif insn.startswith('VFMADD'):306 if insn[len('VFMADD')].isdigit():307 last_mnem = insn[:len('VFMADD123PD')]308 else:309 last_mnem = insn[:len('VFMADDPD')]310 print_entry(arch.upper(), insn, last_mnem, mapping, False)311 elif insn.startswith('VFMSUB'):312 if insn[len('VFMSUB')].isdigit():313 last_mnem = insn[:len('VFMSUB123PD')]314 else:315 last_mnem = insn[:len('VFMSUBPD')]316 print_entry(arch.upper(), insn, last_mnem, mapping, False)317 elif insn.startswith('VFNMADD'):318 if insn[len('VFNMADD')].isdigit():319 last_mnem = insn[:len('VFNMADD123xy')]320 else:321 last_mnem = insn[:len('VFNMADDSS')]322 print_entry(arch.upper(), insn, last_mnem, mapping, False)323 elif insn.startswith('VFNMSUB'):324 if insn[len('VFNMSUB')].isdigit():325 last_mnem = insn[:len('VFNMSUB123xy')]326 else:327 last_mnem = insn[:len('VFNMSUBSS')]328 print_entry(arch.upper(), insn, last_mnem, mapping, False)329 '''330 if insn in insn_id_list:331 # trust old mapping table332 last_mnem = insn_id_list[insn].upper()333 print_entry(arch, insn, insn_id_list[insn].upper(), mapping, False)334 else:335 #pass336 # the last option when we cannot find mnem: use the last good mnem...

Full Screen

Full Screen

mapping_insn-arch.py

Source:mapping_insn-arch.py Github

copy

Full Screen

...95##ifndef CAPSTONE_DIET96# { 0 }, { 0 }, { X86_GRP_NOT64BITMODE, 0 }, 0, 097##endif98#},99def print_entry(arch, insn_id, mnem, mapping, mnem_can_be_wrong):100 #insn = "%s_%s" %(arch.upper(), insn_id)101 insn = "%s_%s" %(arch, insn_id)102 arch1 = arch103 if arch.upper() == 'AARCH64':104 arch1 = 'ARM64'105 #if '64' in insn_id:106 # is64bit = '1'107 #else:108 # is64bit = '0'109 # first, try to find this entry in old MappingInsn.inc file110 for i in range(len(mapping)):111 tmp = mapping[i].split(',')112 if tmp[0].strip() == insn:113 if not mnem_can_be_wrong:114 print('''115{116\t%s, %s_INS_%s,117#ifndef CAPSTONE_DIET118\t%s119#endif120},'''% (insn, arch1, mnem, mapping[i + 2].strip()))121 else: # ATTENTION: mnem can be wrong122 if not tmp[1].endswith(mnem):123 #print("======== cannot find %s, mapping to %s (instead of %s)" %(insn, tmp[1].strip(), mnem))124 pass125 print('''126{127\t%s, %s,128#ifndef CAPSTONE_DIET129\t%s130#endif131},'''% (insn, tmp[1].strip(), mapping[i + 2].strip()))132 return133 if mnem_can_be_wrong:134 #print("======== CANNOT FIND %s, mapping to %s" %(insn, mnem))135 return136 pass137 # this insn does not exist in mapping table138 print('''139{140\t%s, %s_INS_%s,141#ifndef CAPSTONE_DIET142\t{ 0 }, { 0 }, { 0 }, 0, 0143#endif144},'''% (insn, arch1, mnem))145# extract from GenInstrInfo.inc, because the insn id is in order146enum_count = 0147meet_insn = False148f = open(sys.argv[2])149lines = f.readlines()150f.close()151count = 0152last_mnem = None153# 1st enum is register enum154for line in lines:155 line = line.rstrip()156 if len(line.strip()) == 0:157 continue158 # skip pseudo instructions159 if len(line.strip()) == 0:160 continue161 if line.strip() == 'enum {':162 enum_count += 1163 #print(line.strip())164 continue165 line = line.strip()166 if enum_count == 1:167 # skip pseudo instructions168 if '__' in line or 'setjmp' in line or 'longjmp' in line or 'Pseudo' in line:169 continue170 elif 'INSTRUCTION_LIST_END' in line:171 break172 else:173 insn = line.split('=')[0].strip()174 '''175 insn = None176 if meet_insn:177 # enum items178 insn = line.split('=')[0].strip()179 if 'CALLSTACK' in insn or 'TAILJUMP' in insn:180 # pseudo instruction181 insn = None182 elif line.startswith(first_insn):183 insn = line.split('=')[0].strip()184 meet_insn = True185 if insn:186 count += 1187 if insn == 'BSWAP16r_BAD':188 last_mnem = 'BSWAP'189 print_entry(arch.upper(), insn, last_mnem, mapping, False)190 elif insn == 'CMOVNP_Fp32':191 last_mnem = 'FCMOVNP'192 print_entry(arch.upper(), insn, last_mnem, mapping, False)193 elif insn == 'CMOVP_Fp3':194 last_mnem = 'FCMOVP'195 print_entry(arch.upper(), insn, last_mnem, mapping, False)196 elif insn == 'CMPSDrm_Int':197 last_mnem = 'CMPSD'198 print_entry(arch.upper(), insn, last_mnem, mapping, False)199 elif insn == 'MOVSX16rm16':200 last_mnem = 'MOVSX'201 print_entry(arch.upper(), insn, last_mnem, mapping, False)202 elif insn == 'MOVZX16rm16':203 last_mnem = 'MOVZX'204 print_entry(arch.upper(), insn, last_mnem, mapping, False)205 elif insn == 'ST_Fp32m':206 last_mnem = 'FST'207 print_entry(arch.upper(), insn, last_mnem, mapping, False)208 elif insn == 'CMOVNP_Fp64':209 last_mnem = 'FCMOVNU'210 print_entry(arch.upper(), insn, last_mnem, mapping, False)211 elif insn == 'CMPSDrr_Int':212 last_mnem = 'CMPSD'213 print_entry(arch.upper(), insn, last_mnem, mapping, False)214 elif insn == 'CMPSSrm_Int':215 last_mnem = 'CMPSS'216 print_entry(arch.upper(), insn, last_mnem, mapping, False)217 elif insn == 'VCMPSDrm_Int':218 last_mnem = 'VCMPSD'219 print_entry(arch.upper(), insn, last_mnem, mapping, False)220 elif insn == 'VCMPSSrm_Int':221 last_mnem = 'VCMPSS'222 print_entry(arch.upper(), insn, last_mnem, mapping, False)223 elif insn == 'VPCMOVYrrr_REV':224 last_mnem = 'VPCMOV'225 print_entry(arch.upper(), insn, last_mnem, mapping, False)226 elif insn == 'VRNDSCALESDZm':227 last_mnem = 'VRNDSCALESD'228 print_entry(arch.upper(), insn, last_mnem, mapping, False)229 elif insn == 'VRNDSCALESSZm':230 last_mnem = 'VRNDSCALESS'231 print_entry(arch.upper(), insn, last_mnem, mapping, False)232 elif insn == 'VMAXCPDZ128rm':233 last_mnem = 'VMAXPD'234 print_entry(arch.upper(), insn, last_mnem, mapping, False)235 elif insn == 'VMAXCPSZ128rm':236 last_mnem = 'VMAXPS'237 print_entry(arch.upper(), insn, last_mnem, mapping, False)238 elif insn == 'VMAXCSDZrm':239 last_mnem = 'VMAXSD'240 print_entry(arch.upper(), insn, last_mnem, mapping, False)241 elif insn == 'VMAXCSSZrm':242 last_mnem = 'VMAXSS'243 print_entry(arch.upper(), insn, last_mnem, mapping, False)244 elif insn == 'VMINCPDZ128rm':245 last_mnem = 'VMINPD'246 print_entry(arch.upper(), insn, last_mnem, mapping, False)247 elif insn == 'VMINCPSZ128rm':248 last_mnem = 'VMINPS'249 print_entry(arch.upper(), insn, last_mnem, mapping, False)250 elif insn == 'VMINCSDZrm':251 last_mnem = 'VMINSD'252 print_entry(arch.upper(), insn, last_mnem, mapping, False)253 elif insn == 'VMINCSSZrm':254 last_mnem = 'VMINSS'255 print_entry(arch.upper(), insn, last_mnem, mapping, False)256 elif insn == 'VMOV64toPQIZrm':257 last_mnem = 'VMOVQ'258 print_entry(arch.upper(), insn, last_mnem, mapping, False)259 elif insn == 'VPERMIL2PDYrr_REV':260 last_mnem = 'VPERMILPD'261 print_entry(arch.upper(), insn, last_mnem, mapping, False)262 elif insn == 'VPERMIL2PSYrr_REV':263 last_mnem = 'VPERMILPS'264 print_entry(arch.upper(), insn, last_mnem, mapping, False)265 elif insn == 'VCVTSD2SI64Zrm_Int':266 last_mnem = 'VCVTSD2SI'267 print_entry(arch.upper(), insn, last_mnem, mapping, False)268 elif insn == 'VCVTSD2SSrm_Int':269 last_mnem = 'VCVTSD2SS'270 print_entry(arch.upper(), insn, last_mnem, mapping, False)271 elif insn == 'VCVTSS2SI64Zrm_Int':272 last_mnem = 'VCVTSS2SI'273 print_entry(arch.upper(), insn, last_mnem, mapping, False)274 elif insn == 'VCVTTSD2SI64Zrm_Int':275 last_mnem = 'VCVTTSD2SI'276 print_entry(arch.upper(), insn, last_mnem, mapping, False)277 elif insn == 'VCVTTSS2SI64Zrm_Int':278 last_mnem = 'VCVTTSS2SI'279 print_entry(arch.upper(), insn, last_mnem, mapping, False)280 elif insn.startswith('VFMSUBADD'):281 if insn[len('VFMSUBADD')].isdigit():282 last_mnem = insn[:len('VFMSUBADD123xy')]283 else:284 last_mnem = insn[:len('VFMSUBADDSS')]285 print_entry(arch.upper(), insn, last_mnem, mapping, False)286 elif insn.startswith('VFMADDSUB'):287 if insn[len('VFMADDSUB')].isdigit():288 last_mnem = insn[:len('VFMADDSUB123xy')]289 else:290 last_mnem = insn[:len('VFMADDSUBSS')]291 print_entry(arch.upper(), insn, last_mnem, mapping, False)292 elif insn.startswith('VFMADD'):293 if insn[len('VFMADD')].isdigit():294 last_mnem = insn[:len('VFMADD123PD')]295 else:296 last_mnem = insn[:len('VFMADDPD')]297 print_entry(arch.upper(), insn, last_mnem, mapping, False)298 elif insn.startswith('VFMSUB'):299 if insn[len('VFMSUB')].isdigit():300 last_mnem = insn[:len('VFMSUB123PD')]301 else:302 last_mnem = insn[:len('VFMSUBPD')]303 print_entry(arch.upper(), insn, last_mnem, mapping, False)304 elif insn.startswith('VFNMADD'):305 if insn[len('VFNMADD')].isdigit():306 last_mnem = insn[:len('VFNMADD123xy')]307 else:308 last_mnem = insn[:len('VFNMADDSS')]309 print_entry(arch.upper(), insn, last_mnem, mapping, False)310 elif insn.startswith('VFNMSUB'):311 if insn[len('VFNMSUB')].isdigit():312 last_mnem = insn[:len('VFNMSUB123xy')]313 else:314 last_mnem = insn[:len('VFNMSUBSS')]315 print_entry(arch.upper(), insn, last_mnem, mapping, False)316 '''317 if insn in insn_id_list:318 # trust old mapping table319 last_mnem = insn_id_list[insn].upper()320 print_entry(arch, insn, insn_id_list[insn].upper(), mapping, False)321 else:322 # the last option when we cannot find mnem: use the last good mnem...

Full Screen

Full Screen

insn.py

Source:insn.py Github

copy

Full Screen

...93##ifndef CAPSTONE_DIET94# { 0 }, { 0 }, { X86_GRP_NOT64BITMODE, 0 }, 0, 095##endif96#},97def print_entry(arch, insn_id, mnem, mapping, mnem_can_be_wrong):98 print(arch, insn_id, mnem, mnem_can_be_wrong)99 if not mnem_can_be_wrong:100 insn = "%s_INS_%s" %(arch.upper(), mnem.upper())101 if insn in insn_list:102 return103 print("%s," %insn)104 insn_list.append(insn)105 return106 insn = "%s_%s" %(arch.upper(), insn_id)107 # so mnem can be wrong, we need to verify with MappingInsn.inc108 # first, try to find this entry in old MappingInsn.inc file109 for i in range(len(mapping)):110 tmp = mapping[i].split(',')111 if tmp[0].strip() == insn:112 insn = tmp[1].strip()113 if insn in insn_list:114 return115 #print("==== get below from MappingInsn.inc file: %s" %insn)116 print("%s," %insn)117 insn_list.append(insn)118 return119# extract from GenInstrInfo.inc, because the insn id is in order120enum_count = 0121meet_insn = False122# GenInstrInfo.inc123f = open(sys.argv[2])124lines = f.readlines()125f.close()126count = 0127last_mnem = None128# 1st enum is register enum129for line in lines:130 line = line.rstrip()131 if len(line.strip()) == 0:132 continue133 if line.strip() == 'enum {':134 enum_count += 1135 #print(line.strip())136 continue137 line = line.strip()138 if enum_count == 1:139 if 'INSTRUCTION_LIST_END' in line:140 break141 else:142 insn = None143 if meet_insn:144 # enum items145 insn = line.split('=')[0].strip()146 if 'CALLSTACK' in insn or 'TAILJUMP' in insn:147 # pseudo instruction148 insn = None149 elif line.startswith(first_insn):150 insn = line.split('=')[0].strip()151 meet_insn = True152 if insn:153 count += 1154 if insn == 'BSWAP16r_BAD':155 last_mnem = 'BSWAP'156 print_entry(arch.upper(), insn, last_mnem, mapping, False)157 elif insn == 'CMOVNP_Fp32':158 last_mnem = 'FCMOVNP'159 print_entry(arch.upper(), insn, last_mnem, mapping, False)160 elif insn == 'CMOVP_Fp3':161 last_mnem = 'FCMOVP'162 print_entry(arch.upper(), insn, last_mnem, mapping, False)163 elif insn == 'CMPSDrm_Int':164 last_mnem = 'CMPSD'165 print_entry(arch.upper(), insn, last_mnem, mapping, False)166 elif insn == 'MOVSX16rm16':167 last_mnem = 'MOVSX'168 print_entry(arch.upper(), insn, last_mnem, mapping, False)169 elif insn == 'MOVZX16rm16':170 last_mnem = 'MOVZX'171 print_entry(arch.upper(), insn, last_mnem, mapping, False)172 elif insn == 'ST_Fp32m':173 last_mnem = 'FST'174 print_entry(arch.upper(), insn, last_mnem, mapping, False)175 elif insn == 'CMOVNP_Fp64':176 last_mnem = 'FCMOVNU'177 print_entry(arch.upper(), insn, last_mnem, mapping, False)178 elif insn == 'CMPSDrr_Int':179 last_mnem = 'CMPSD'180 print_entry(arch.upper(), insn, last_mnem, mapping, False)181 elif insn == 'CMPSSrm_Int':182 last_mnem = 'CMPSS'183 print_entry(arch.upper(), insn, last_mnem, mapping, False)184 elif insn == 'VCMPSDrm_Int':185 last_mnem = 'VCMPSD'186 print_entry(arch.upper(), insn, last_mnem, mapping, False)187 elif insn == 'VCMPSSrm_Int':188 last_mnem = 'VCMPSS'189 print_entry(arch.upper(), insn, last_mnem, mapping, False)190 elif insn == 'VPCMOVYrrr_REV':191 last_mnem = 'VPCMOV'192 print_entry(arch.upper(), insn, last_mnem, mapping, False)193 elif insn == 'VRNDSCALESDZm':194 last_mnem = 'VRNDSCALESD'195 print_entry(arch.upper(), insn, last_mnem, mapping, False)196 elif insn == 'VRNDSCALESSZm':197 last_mnem = 'VRNDSCALESS'198 print_entry(arch.upper(), insn, last_mnem, mapping, False)199 elif insn == 'VMAXCPDZ128rm':200 last_mnem = 'VMAXPD'201 print_entry(arch.upper(), insn, last_mnem, mapping, False)202 elif insn == 'VMAXCPSZ128rm':203 last_mnem = 'VMAXPS'204 print_entry(arch.upper(), insn, last_mnem, mapping, False)205 elif insn == 'VMAXCSDZrm':206 last_mnem = 'VMAXSD'207 print_entry(arch.upper(), insn, last_mnem, mapping, False)208 elif insn == 'VMAXCSSZrm':209 last_mnem = 'VMAXSS'210 print_entry(arch.upper(), insn, last_mnem, mapping, False)211 elif insn == 'VMINCPDZ128rm':212 last_mnem = 'VMINPD'213 print_entry(arch.upper(), insn, last_mnem, mapping, False)214 elif insn == 'VMINCPSZ128rm':215 last_mnem = 'VMINPS'216 print_entry(arch.upper(), insn, last_mnem, mapping, False)217 elif insn == 'VMINCSDZrm':218 last_mnem = 'VMINSD'219 print_entry(arch.upper(), insn, last_mnem, mapping, False)220 elif insn == 'VMINCSSZrm':221 last_mnem = 'VMINSS'222 print_entry(arch.upper(), insn, last_mnem, mapping, False)223 elif insn == 'VMOV64toPQIZrm':224 last_mnem = 'VMOVQ'225 print_entry(arch.upper(), insn, last_mnem, mapping, False)226 elif insn == 'VPERMIL2PDYrr_REV':227 last_mnem = 'VPERMILPD'228 print_entry(arch.upper(), insn, last_mnem, mapping, False)229 elif insn == 'VPERMIL2PSYrr_REV':230 last_mnem = 'VPERMILPS'231 print_entry(arch.upper(), insn, last_mnem, mapping, False)232 elif insn == 'VCVTSD2SI64Zrm_Int':233 last_mnem = 'VCVTSD2SI'234 print_entry(arch.upper(), insn, last_mnem, mapping, False)235 elif insn == 'VCVTSD2SSrm_Int':236 last_mnem = 'VCVTSD2SS'237 print_entry(arch.upper(), insn, last_mnem, mapping, False)238 elif insn == 'VCVTSS2SI64Zrm_Int':239 last_mnem = 'VCVTSS2SI'240 print_entry(arch.upper(), insn, last_mnem, mapping, False)241 elif insn == 'VCVTTSD2SI64Zrm_Int':242 last_mnem = 'VCVTTSD2SI'243 print_entry(arch.upper(), insn, last_mnem, mapping, False)244 elif insn == 'VCVTTSS2SI64Zrm_Int':245 last_mnem = 'VCVTTSS2SI'246 print_entry(arch.upper(), insn, last_mnem, mapping, False)247 elif insn.startswith('VFMSUBADD'):248 if insn[len('VFMSUBADD')].isdigit():249 last_mnem = insn[:len('VFMSUBADD123xy')]250 else:251 last_mnem = insn[:len('VFMSUBADDSS')]252 print_entry(arch.upper(), insn, last_mnem, mapping, False)253 elif insn.startswith('VFMADDSUB'):254 if insn[len('VFMADDSUB')].isdigit():255 last_mnem = insn[:len('VFMADDSUB123xy')]256 else:257 last_mnem = insn[:len('VFMADDSUBSS')]258 print_entry(arch.upper(), insn, last_mnem, mapping, False)259 elif insn.startswith('VFMADD'):260 if insn[len('VFMADD')].isdigit():261 last_mnem = insn[:len('VFMADD123PD')]262 else:263 last_mnem = insn[:len('VFMADDPD')]264 print_entry(arch.upper(), insn, last_mnem, mapping, False)265 elif insn.startswith('VFMSUB'):266 if insn[len('VFMSUB')].isdigit():267 last_mnem = insn[:len('VFMSUB123PD')]268 else:269 last_mnem = insn[:len('VFMSUBPD')]270 print_entry(arch.upper(), insn, last_mnem, mapping, False)271 elif insn.startswith('VFNMADD'):272 if insn[len('VFNMADD')].isdigit():273 last_mnem = insn[:len('VFNMADD123xy')]274 else:275 last_mnem = insn[:len('VFNMADDSS')]276 print_entry(arch.upper(), insn, last_mnem, mapping, False)277 elif insn.startswith('VFNMSUB'):278 if insn[len('VFNMSUB')].isdigit():279 last_mnem = insn[:len('VFNMSUB123xy')]280 else:281 last_mnem = insn[:len('VFNMSUBSS')]282 print_entry(arch.upper(), insn, last_mnem, mapping, False)283 elif insn in insn_id_list:284 # trust old mapping table285 last_mnem = insn_id_list[insn].upper()286 print_entry(arch.upper(), insn, last_mnem, mapping, False)287 else:288 # the last option when we cannot find mnem: use the last good mnem...

Full Screen

Full Screen

mapping_insn.py

Source:mapping_insn.py Github

copy

Full Screen

...81##ifndef CAPSTONE_DIET82# { 0 }, { 0 }, { X86_GRP_NOT64BITMODE, 0 }, 0, 083##endif84#},85def print_entry(arch, insn_id, mnem, mapping, mnem_can_be_wrong):86 insn = "%s_%s" %(arch.upper(), insn_id)87 if '64' in insn_id:88 is64bit = '1'89 else:90 is64bit = '0'91 # first, try to find this entry in old MappingInsn.inc file92 for i in range(len(mapping)):93 tmp = mapping[i].split(',')94 if tmp[0].strip() == insn:95 if not mnem_can_be_wrong:96 print('''97{98\t%s_%s, %s_INS_%s, %s,99#ifndef CAPSTONE_DIET100\t%s101#endif102},'''% (arch, insn_id, arch, mnem, is64bit, mapping[i + 2].strip()))103 else:104 if not tmp[1].endswith(mnem):105 #print("======== cannot find %s, mapping to %s (instead of %s)" %(insn, tmp[1].strip(), mnem))106 pass107 print('''108{109\t%s_%s, %s, %s,110#ifndef CAPSTONE_DIET111\t%s112#endif113},'''% (arch, insn_id, tmp[1].strip(), is64bit, mapping[i + 2].strip()))114 return115 if mnem_can_be_wrong:116 #print("======== CANNOT FIND %s, mapping to %s" %(insn, mnem))117 pass118 print('''119{120\t%s_%s, %s_INS_%s, %s,121#ifndef CAPSTONE_DIET122\t{ 0 }, { 0 }, { 0 }, 0, 0123#endif124},'''% (arch, insn_id, arch, mnem, is64bit))125# extract from GenInstrInfo.inc, because the insn id is in order126enum_count = 0127meet_insn = False128f = open(sys.argv[2])129lines = f.readlines()130f.close()131count = 0132last_mnem = None133# 1st enum is register enum134for line in lines:135 line = line.rstrip()136 if len(line.strip()) == 0:137 continue138 if line.strip() == 'enum {':139 enum_count += 1140 #print(line.strip())141 continue142 line = line.strip()143 if enum_count == 1:144 if 'INSTRUCTION_LIST_END' in line:145 break146 else:147 insn = None148 if meet_insn:149 # enum items150 insn = line.split('=')[0].strip()151 if 'CALLSTACK' in insn or 'TAILJUMP' in insn:152 # pseudo instruction153 insn = None154 elif line.startswith(first_insn):155 insn = line.split('=')[0].strip()156 meet_insn = True157 if insn:158 count += 1159 if insn == 'BSWAP16r_BAD':160 last_mnem = 'BSWAP'161 print_entry(arch.upper(), insn, last_mnem, mapping, False)162 elif insn == 'CMOVNP_Fp32':163 last_mnem = 'FCMOVNP'164 print_entry(arch.upper(), insn, last_mnem, mapping, False)165 elif insn == 'CMOVP_Fp3':166 last_mnem = 'FCMOVP'167 print_entry(arch.upper(), insn, last_mnem, mapping, False)168 elif insn == 'CMPSDrm_Int':169 last_mnem = 'CMPSD'170 print_entry(arch.upper(), insn, last_mnem, mapping, False)171 elif insn == 'MOVSX16rm16':172 last_mnem = 'MOVSX'173 print_entry(arch.upper(), insn, last_mnem, mapping, False)174 elif insn == 'MOVZX16rm16':175 last_mnem = 'MOVZX'176 print_entry(arch.upper(), insn, last_mnem, mapping, False)177 elif insn == 'ST_Fp32m':178 last_mnem = 'FST'179 print_entry(arch.upper(), insn, last_mnem, mapping, False)180 elif insn == 'CMOVNP_Fp64':181 last_mnem = 'FCMOVNU'182 print_entry(arch.upper(), insn, last_mnem, mapping, False)183 elif insn == 'CMPSDrr_Int':184 last_mnem = 'CMPSD'185 print_entry(arch.upper(), insn, last_mnem, mapping, False)186 elif insn == 'CMPSSrm_Int':187 last_mnem = 'CMPSS'188 print_entry(arch.upper(), insn, last_mnem, mapping, False)189 elif insn == 'VCMPSDrm_Int':190 last_mnem = 'VCMPSD'191 print_entry(arch.upper(), insn, last_mnem, mapping, False)192 elif insn == 'VCMPSSrm_Int':193 last_mnem = 'VCMPSS'194 print_entry(arch.upper(), insn, last_mnem, mapping, False)195 elif insn == 'VPCMOVYrrr_REV':196 last_mnem = 'VPCMOV'197 print_entry(arch.upper(), insn, last_mnem, mapping, False)198 elif insn == 'VRNDSCALESDZm':199 last_mnem = 'VRNDSCALESD'200 print_entry(arch.upper(), insn, last_mnem, mapping, False)201 elif insn == 'VRNDSCALESSZm':202 last_mnem = 'VRNDSCALESS'203 print_entry(arch.upper(), insn, last_mnem, mapping, False)204 elif insn == 'VMAXCPDZ128rm':205 last_mnem = 'VMAXPD'206 print_entry(arch.upper(), insn, last_mnem, mapping, False)207 elif insn == 'VMAXCPSZ128rm':208 last_mnem = 'VMAXPS'209 print_entry(arch.upper(), insn, last_mnem, mapping, False)210 elif insn == 'VMAXCSDZrm':211 last_mnem = 'VMAXSD'212 print_entry(arch.upper(), insn, last_mnem, mapping, False)213 elif insn == 'VMAXCSSZrm':214 last_mnem = 'VMAXSS'215 print_entry(arch.upper(), insn, last_mnem, mapping, False)216 elif insn == 'VMINCPDZ128rm':217 last_mnem = 'VMINPD'218 print_entry(arch.upper(), insn, last_mnem, mapping, False)219 elif insn == 'VMINCPSZ128rm':220 last_mnem = 'VMINPS'221 print_entry(arch.upper(), insn, last_mnem, mapping, False)222 elif insn == 'VMINCSDZrm':223 last_mnem = 'VMINSD'224 print_entry(arch.upper(), insn, last_mnem, mapping, False)225 elif insn == 'VMINCSSZrm':226 last_mnem = 'VMINSS'227 print_entry(arch.upper(), insn, last_mnem, mapping, False)228 elif insn == 'VMOV64toPQIZrm':229 last_mnem = 'VMOVQ'230 print_entry(arch.upper(), insn, last_mnem, mapping, False)231 elif insn == 'VPERMIL2PDYrr_REV':232 last_mnem = 'VPERMILPD'233 print_entry(arch.upper(), insn, last_mnem, mapping, False)234 elif insn == 'VPERMIL2PSYrr_REV':235 last_mnem = 'VPERMILPS'236 print_entry(arch.upper(), insn, last_mnem, mapping, False)237 elif insn == 'VCVTSD2SI64Zrm_Int':238 last_mnem = 'VCVTSD2SI'239 print_entry(arch.upper(), insn, last_mnem, mapping, False)240 elif insn == 'VCVTSD2SSrm_Int':241 last_mnem = 'VCVTSD2SS'242 print_entry(arch.upper(), insn, last_mnem, mapping, False)243 elif insn == 'VCVTSS2SI64Zrm_Int':244 last_mnem = 'VCVTSS2SI'245 print_entry(arch.upper(), insn, last_mnem, mapping, False)246 elif insn == 'VCVTTSD2SI64Zrm_Int':247 last_mnem = 'VCVTTSD2SI'248 print_entry(arch.upper(), insn, last_mnem, mapping, False)249 elif insn == 'VCVTTSS2SI64Zrm_Int':250 last_mnem = 'VCVTTSS2SI'251 print_entry(arch.upper(), insn, last_mnem, mapping, False)252 elif insn.startswith('VFMSUBADD'):253 if insn[len('VFMSUBADD')].isdigit():254 last_mnem = insn[:len('VFMSUBADD123xy')]255 else:256 last_mnem = insn[:len('VFMSUBADDSS')]257 print_entry(arch.upper(), insn, last_mnem, mapping, False)258 elif insn.startswith('VFMADDSUB'):259 if insn[len('VFMADDSUB')].isdigit():260 last_mnem = insn[:len('VFMADDSUB123xy')]261 else:262 last_mnem = insn[:len('VFMADDSUBSS')]263 print_entry(arch.upper(), insn, last_mnem, mapping, False)264 elif insn.startswith('VFMADD'):265 if insn[len('VFMADD')].isdigit():266 last_mnem = insn[:len('VFMADD123PD')]267 else:268 last_mnem = insn[:len('VFMADDPD')]269 print_entry(arch.upper(), insn, last_mnem, mapping, False)270 elif insn.startswith('VFMSUB'):271 if insn[len('VFMSUB')].isdigit():272 last_mnem = insn[:len('VFMSUB123PD')]273 else:274 last_mnem = insn[:len('VFMSUBPD')]275 print_entry(arch.upper(), insn, last_mnem, mapping, False)276 elif insn.startswith('VFNMADD'):277 if insn[len('VFNMADD')].isdigit():278 last_mnem = insn[:len('VFNMADD123xy')]279 else:280 last_mnem = insn[:len('VFNMADDSS')]281 print_entry(arch.upper(), insn, last_mnem, mapping, False)282 elif insn.startswith('VFNMSUB'):283 if insn[len('VFNMSUB')].isdigit():284 last_mnem = insn[:len('VFNMSUB123xy')]285 else:286 last_mnem = insn[:len('VFNMSUBSS')]287 print_entry(arch.upper(), insn, last_mnem, mapping, False)288 elif insn in insn_id_list:289 # trust old mapping table290 last_mnem = insn_id_list[insn].upper()291 print_entry(arch.upper(), insn, insn_id_list[insn].upper(), mapping, False)292 else:293 # the last option when we cannot find mnem: use the last good mnem...

Full Screen

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Python automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful