def __init__()

in preprocess/asm_obj.py [0:0]


  def __init__(self, asm_file, task):
    self.asm_file = asm_file 
    self.task = task

    self.regs = ['rax', 'rbx', 'rcx', 'rdx', 'rsp', 'rbp', 'rsi', 'rdi', 'r8', 'r9', 'r10', 'r11', 'r12', 'r13', 'r14', 'r15']
    self.broken_types = ['shlq']
    self.op_types = [['ja', 'jb', 'jbe', 'jl', 'jge', 'jmp', 'je', 'jne', 'jnp', 'jns', 'js', 'jg', 'jp', 'jle', 'jae', 'callq', 'call', 'pushq', 'popq', 'jmpq', 'repz', 'retq', 'leaveq', 'cltq', 'nop', 'hlt', 'push', 'pop', 'cltd', 'cqto', ' '],
                     ['inc', 'mul', 'incw', 'incl', 'incq', 'div', 'idiv', 'idivl', 'dec', 'decw', 'neg', 'not', 'nopl', 'nopw', 'sar', 'seta', 'setl', 'setle', 'sete', 'setp', 'setnp', 'setne', 'setge', 'shr', 'setg', 'setae'],
                     ['adc', 'movups', 'movw', 'movdqa', 'movsb', 'movsbl', 'cmovbe', 'cmovl', 'cmovs', 'cmovns', 'cmovg', 'cmovne', 'cmovle',\
                       'cmovge', 'cmove', 'movzwl', 'movsl', 'mov', 'movd', 'movabs', 'movb', 'movq', 'movss', 'movsd', 'movslq', 'movaps', \
                       'movswq', 'movswl', 'movapd', 'movzbl', 'cmpw', 'cmp', 'cmpb', 'cmpq', 'lea',  'add', 'addw', 'addl', 'addq', 'addss',\
                       'addsd', 'bt', 'sub', 'subl', 'subss', 'subsd', 'sbb', 'mulss', 'mulsd', 'divsd', 'divss', 'test', 'pxor', 'xor', 'xorpd',\
                       'xorps', 'orps', 'and', 'andps', 'andnps', 'or', 'sar', 'cmpl', 'movl', 'xorl', 'subq', 'shl', 'xchg', 'ucomiss',\
                       'ucomisd', 'cvtsd2ss', 'cvtss2sd', 'cvtsi2sd', 'cvttsd2si', 'cvttss2si', 'cvtsi2ss', 'cvtsi2ssl', 'cvtsi2sdl', 'cvtsi2sdq',\
                       'sqrtsd', 'stos', 'punpcklqdq', 'andpd', 'maxsd', 'rol', 'scas', "movsbq", "cmpnless"],
                     ['imul', 'pinsrd']]
    # combine subarrays of self.op_types into one and build id mapping
    self.op_set = [op for op_ls in self.op_types for op in op_ls]
    self.op2id = {}
    self.id2op = {}
    for op in self.op_set:
      self.op2id[op] = len(self.op2id)
      self.id2op[len(self.op2id)-1] = op

    # edge types we support
    # self.edge_types[0] are edges between type 1 nodes
    # self.edge_types[1] are edges between nodes of type 1 and 2
    # self.edge_types[2] are edges between nodes of type 2 and 3
    self.edge_types = [['next-ins'],
                       ['ins-src', 'ins-tgt'],
                       ['non-mem-reg', 'mem-base', 'mem-index-stride', 'mem-stride', 'mem-index', 'mem-offset', 'mem-start'],
                       ['last-read', 'last-write']]
    # combine subarrays of self.edge_types into one and build id mapping
    self.edge_type_set = [et for ets in self.edge_types for et in ets]
    self.edge_type_2_id = {}
    for edge_type in self.edge_type_set:
      self.edge_type_2_id[edge_type] = len(self.edge_type_2_id)

    # self.edges is a 1d array
    self.edges = []
    # self.nodes is supposed to be a 2d array of shape (num_ins, _). Each
    # subarray contains nodes of one pc
    self.nodes = []
    self.num_ins = 0
    self.num_nodes = 0
    # for building control flow edges through jump instructions
    self.pc2node = {}
    # for selecting subgraphs
    self.id2node = {}
    # for usage edges
    self.src_vnode = {}
    self.tgt_vnode = {}

    # start processing assembly to graph
    self.read_file()
    # create nodes of type 1
    self.__ins_node__()
    # create nodes of type 2 and 3
    for line in self.lines:
      self.get_opid(line)