diff --git a/osaca/marker_utils.py b/osaca/marker_utils.py index eba394b..e388d6e 100755 --- a/osaca/marker_utils.py +++ b/osaca/marker_utils.py @@ -24,9 +24,7 @@ def find_marked_kernel_AArch64(lines): def find_marked_kernel_x86(lines): nop_bytes = ['100', '103', '144'] - return find_marked_kernel( - lines, ParserX86ATT(), ['mov', 'movl'], 'ebx', [111, 222], nop_bytes - ) + return find_marked_kernel(lines, ParserX86ATT(), ['mov', 'movl'], 'ebx', [111, 222], nop_bytes) def find_marked_kernel(lines, parser, mov_instr, mov_reg, mov_vals, nop_bytes): @@ -34,15 +32,15 @@ def find_marked_kernel(lines, parser, mov_instr, mov_reg, mov_vals, nop_bytes): index_end = -1 for i, line in enumerate(lines): try: - if line['instruction'] in mov_instr and lines[i + 1]['directive'] is not None: - source = line['operands']['source'] - destination = line['operands']['destination'] + if line.instruction in mov_instr and lines[i + 1].directive is not None: + source = line.operands.source + destination = line.operands.destination # instruction pair matches, check for operands if ( 'immediate' in source[0] - and parser.normalize_imd(source[0]['immediate']) == mov_vals[0] + and parser.normalize_imd(source[0].immediate) == mov_vals[0] and 'register' in destination[0] - and parser.get_full_reg_name(destination[0]['register']) == mov_reg + and parser.get_full_reg_name(destination[0].register) == mov_reg ): # operands of first instruction match start, check for second one match, line_count = match_bytes(lines, i + 1, nop_bytes) @@ -51,9 +49,9 @@ def find_marked_kernel(lines, parser, mov_instr, mov_reg, mov_vals, nop_bytes): index_start = i + 1 + line_count elif ( 'immediate' in source[0] - and parser.normalize_imd(source[0]['immediate']) == mov_vals[1] + and parser.normalize_imd(source[0].immediate) == mov_vals[1] and 'register' in destination[0] - and parser.get_full_reg_name(destination[0]['register']) == mov_reg + and parser.get_full_reg_name(destination[0].register) == mov_reg ): # operand of first instruction match end, check for second one match, line_count = match_bytes(lines, i + 1, nop_bytes) @@ -73,11 +71,11 @@ def match_bytes(lines, index, byte_list): line_count = 0 while ( index < len(lines) - and lines[index]['directive'] is not None - and lines[index]['directive']['name'] == 'byte' + and lines[index].directive is not None + and lines[index].directive.name == 'byte' ): line_count += 1 - extracted_bytes += lines[index]['directive']['parameters'] + extracted_bytes += lines[index].directive.parameters index += 1 if extracted_bytes[0:len(byte_list)] == byte_list: return True, line_count diff --git a/osaca/parser/parser_AArch64v81.py b/osaca/parser/parser_AArch64v81.py index 09d3720..9917ae1 100755 --- a/osaca/parser/parser_AArch64v81.py +++ b/osaca/parser/parser_AArch64v81.py @@ -217,10 +217,10 @@ class ParserAArch64v81(BaseParser): self.directive.parseString(line, parseAll=True).asDict() ) result = AttrDict.convert_dict(result) - instruction_form[self.DIRECTIVE_ID] = { + instruction_form[self.DIRECTIVE_ID] = AttrDict({ 'name': result[self.DIRECTIVE_ID].name, 'parameters': result[self.DIRECTIVE_ID].parameters, - } + }) if self.COMMENT_ID in result[self.DIRECTIVE_ID]: instruction_form[self.COMMENT_ID] = ' '.join( result[self.DIRECTIVE_ID][self.COMMENT_ID] diff --git a/osaca/parser/parser_x86att.py b/osaca/parser/parser_x86att.py index 2b25e22..e9bcc7c 100755 --- a/osaca/parser/parser_x86att.py +++ b/osaca/parser/parser_x86att.py @@ -143,10 +143,10 @@ class ParserX86ATT(BaseParser): self.directive.parseString(line, parseAll=True).asDict() ) result = AttrDict.convert_dict(result) - instruction_form[self.DIRECTIVE_ID] = { + instruction_form[self.DIRECTIVE_ID] = AttrDict({ 'name': result[self.DIRECTIVE_ID]['name'], 'parameters': result[self.DIRECTIVE_ID]['parameters'], - } + }) if self.COMMENT_ID in result[self.DIRECTIVE_ID]: instruction_form[self.COMMENT_ID] = ' '.join( result[self.DIRECTIVE_ID][self.COMMENT_ID]