def get_debug_filepath()

in ArmPlatformPkg/Scripts/Ds5/firmware_volume.py [0:0]


    def get_debug_filepath(self):
        # Offset from dos hdr to PE file hdr (EFI_IMAGE_NT_HEADERS64)
        file_header_offset = self.ec.getMemoryService().readMemory32(self.base_pe64 + 0x3C)

        # Offset to debug dir in PE hdrs
        debug_dir_entry_rva = self.ec.getMemoryService().readMemory32(self.base_pe64 + file_header_offset + 0xB8)
        if debug_dir_entry_rva == 0:
            raise Exception("EfiFileSectionPE64","No Debug Directory")

        debug_type = self.ec.getMemoryService().readMemory32(self.base_pe64 + debug_dir_entry_rva + 0xC)
        if (debug_type != 0xdf) and (debug_type != EfiFileSection.EFI_IMAGE_DEBUG_TYPE_CODEVIEW):
            raise Exception("EfiFileSectionPE64","Debug type is not dwarf")


        debug_rva = self.ec.getMemoryService().readMemory32(self.base_pe64 + debug_dir_entry_rva + 0x14)

        dwarf_sig = struct.unpack("cccc", self.ec.getMemoryService().read(str(self.base_pe64 + debug_rva), 4, 32))
        if (dwarf_sig != 0x66727764) and (dwarf_sig != FirmwareFile.CONST_NB10_SIGNATURE):
            raise Exception("EfiFileSectionPE64","Dwarf debug signature not found")

        if dwarf_sig == 0x66727764:
            filename = self.base_pe64 + debug_rva + 0xc
        else:
            filename = self.base_pe64 + debug_rva + 0x10
        filename = struct.unpack("400s", self.ec.getMemoryService().read(str(filename), 400, 32))[0]
        return filename[0:string.find(filename,'\0')]