diff --git a/Debug/Scripts/gdb_uefi.py b/Debug/Scripts/gdb_uefi.py index d49b822045a..32101b84c59 100644 --- a/Debug/Scripts/gdb_uefi.py +++ b/Debug/Scripts/gdb_uefi.py @@ -233,12 +233,13 @@ def pe_optional(self, pe): # Returns the symbol file name for a PE image. # - def pe_parse_debug(self, pe): + def pe_parse_debug(self, base): + pe = self.pe_headers(base) opt = self.pe_optional(pe) debug_dir_entry = opt['DataDirectory'][6] - dep = debug_dir_entry['VirtualAddress'] + opt['ImageBase'] + dep = debug_dir_entry['VirtualAddress'] + int(base) dep = dep.cast(self.ptype('EFI_IMAGE_DEBUG_DIRECTORY_ENTRY')) - cvp = dep.dereference()['RVA'] + opt['ImageBase'] + cvp = dep.dereference()['RVA'] + int(base) cvv = cvp.cast(self.ptype('UINT32')).dereference() if cvv == self.CV_NB10: return cvp + self.sizeof('EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY') @@ -328,7 +329,7 @@ def parse_image(self, image, syms): pe = self.pe_headers(base) opt = self.pe_optional(pe) file = self.pe_file(pe) - sym_name = self.pe_parse_debug(pe) + sym_name = self.pe_parse_debug(base) sections = self.pe_sections(opt, file, base) # For ELF and Mach-O-derived images... @@ -362,7 +363,7 @@ def parse_edii(self, edii, count): entry = entry['NormalImage'] self.parse_image(entry['LoadedImageProtocolInstance'], syms) else: - print(f"Skipping unknown EFI_DEBUG_IMAGE_INFO(Type 0x{entry['ImageInfoType'].dereference():x})") + print(f"Skipping unknown EFI_DEBUG_IMAGE_INFO(Type {str(entry['ImageInfoType'].dereference())})") index += 1 gdb.execute('symbol-file') print('Loading new symbols...') diff --git a/Debug/Scripts/lldb_uefi.py b/Debug/Scripts/lldb_uefi.py index 67010e4744f..b1b29149413 100644 --- a/Debug/Scripts/lldb_uefi.py +++ b/Debug/Scripts/lldb_uefi.py @@ -265,12 +265,13 @@ def pe_optional(self, pe): # Returns the symbol file name for a PE image. # - def pe_parse_debug(self, pe): + def pe_parse_debug(self, base): + pe = self.pe_headers(base) opt = self.pe_optional(pe) debug_dir_entry = opt.GetValueForExpressionPath('.DataDirectory[6]') - dep = self.get_field(debug_dir_entry, 'VirtualAddress') + self.get_field(opt, 'ImageBase') + dep = self.get_field(debug_dir_entry, 'VirtualAddress') + base dep = self.typed_ptr(self.ptype('EFI_IMAGE_DEBUG_DIRECTORY_ENTRY'), dep) - cvp = self.get_field(dep, 'RVA') + self.get_field(opt, 'ImageBase') + cvp = self.get_field(dep, 'RVA') + base # FIXME: UINT32 should be used here instead of unsigned, but LLDB+PDB type system is broken. cvv = self.typed_ptr(self.ptype('unsigned'), cvp).Dereference().GetValueAsUnsigned() if cvv == self.CV_NB10: @@ -310,7 +311,7 @@ def parse_image(self, image, syms): pe = self.pe_headers(base) opt = self.pe_optional(pe) file = self.pe_file(pe) - sym_address = self.pe_parse_debug(pe) + sym_address = self.pe_parse_debug(base) sections = self.pe_sections(opt, file, base) if sym_address == 0: @@ -373,7 +374,7 @@ def parse_edii(self, edii, count): entry = entry.GetChildMemberWithName('NormalImage') self.parse_image(entry.GetChildMemberWithName('LoadedImageProtocolInstance'), syms) else: - print(f'Skipping unknown EFI_DEBUG_IMAGE_INFO (Type 0x{image_type:x})') + print(f'Skipping unknown EFI_DEBUG_IMAGE_INFO (Type {str(image_type)})') index = index + 1 print('Loading new symbols...') for sym in syms: