Beispiel #1
0
    def analyze_cu(self, cu: CompileUnit):
        # CompileUnit情報を取得
        self._cu_info = utilDwarf.cu_info()
        # CompileUnit=fileなので(?)、ファイル名、パスを取得
        top_die = cu.get_top_DIE()
        # コンパイル時ディレクトリ情報を取得
        if "DW_AT_comp_dir" in top_die.attributes.keys():
            self._cu_info.compile_dir = top_die.attributes[
                "DW_AT_comp_dir"].value.decode(self._encoding)
        else:
            self._cu_info.compile_dir = "."
        # ファイル名取得
        if "DW_AT_name" in top_die.attributes.keys():
            self._cu_info.filename = top_die.attributes[
                "DW_AT_name"].value.decode(self._encoding)
        else:
            self._cu_info.filename = ""
        # ファイル情報
        if self._debug_warning:
            print("CU file: " + self._cu_info.compile_dir + "\\" +
                  self._cu_info.filename)

        # CompileUnitヘッダ解析
        self._cu_info.address_size = cu.header['address_size']
        self._cu_info.debug_abbrev_offset = cu.header['debug_abbrev_offset']
        self._cu_info.unit_length = cu.header['unit_length']
        # debug comment
        #		print("    address_size       : " + str(self._curr_cu_info.address_size))
        #		print("    debug_abbrev_offset: " + str(self._curr_cu_info.debug_abbrev_offset))
        #		print("    unit_length        : " + str(self._curr_cu_info.unit_length))

        # file_entryは 0:存在しない になるので、Noneを入れておく
        self._cu_info.file_list.append(None)
        # include_directory は 0:カレントディレクトリ? になるので、
        # DW_AT_comp_dirを入れておく
        self._cu_info.include_dir_list.append(self._cu_info.compile_dir)
        # .debug_line解析
        line_program = self._dwarf_info.line_program_for_CU(cu)
        if line_program is not None:
            self._debug_line = line_program
            self.analyze_line(line_program)

        # DIE解析
        die: DIE
        for die in cu.iter_DIEs():
            self.analyze_die(die)
Beispiel #2
0
 def get_cu_base_address(self, cu: CompileUnit) -> Optional[int]:
   base = self._base_addresses.get(cu, None)
   if base == None:
     base = self._base_addresses.setdefault(cu, self.get_start_address(cu.get_top_DIE()))
   return base
Beispiel #3
0
 def unit_get_producer(self, handler: CompileUnit):
     result = self.get_attribute(handler.get_top_DIE(), 'DW_AT_producer')
     if result is None:
         result = super().unit_get_producer(handler)
     return result
Beispiel #4
0
 def unit_get_comp_dir(self, handler: CompileUnit):
     return self.get_attribute(handler.get_top_DIE(), 'DW_AT_comp_dir')
Beispiel #5
0
 def unit_get_functions(self, handler: CompileUnit):
     return self.filter_children(handler.get_top_DIE(), 'DW_TAG_subprogram')
Beispiel #6
0
 def unit_get_variables(self, handler: CompileUnit):
     return self.filter_children(handler.get_top_DIE(), 'DW_TAG_variable')
Beispiel #7
0
 def unit_get_language(self, handler: CompileUnit):
     return self.get_attribute(handler.get_top_DIE(), 'DW_AT_language')
Beispiel #8
0
 def unit_get_filename(self, handler: CompileUnit):
     return self.get_attribute(handler.get_top_DIE(), 'DW_AT_name')