# # Copyright (c) 2011-2013, ARM Limited. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # import os import firmware_volume import build_report import system_table # Reload external classes reload(firmware_volume) reload(build_report) reload(system_table) def readMem32(executionContext, address): bytes = executionContext.getMemoryService().read(address, 4, 32) return struct.unpack('= debug_info[0]) and (pc < debug_info[0] + debug_info[1]): found = True if found == False: info = self.firmware_volumes[fv_base].load_symbols_at(pc) debug_infos.append(info) #self.firmware_volumes[fv_base].load_symbols_at(pc) elif self.in_sysmem(pc): debug_infos = [] if self.system_table is None: # Find the System Table self.system_table = system_table.SystemTable(self.ec, self.platform.sysmembase, self.platform.sysmemsize) # Find the Debug Info Table debug_info_table_base = self.system_table.get_configuration_table(system_table.DebugInfoTable.CONST_DEBUG_INFO_TABLE_GUID) self.debug_info_table = system_table.DebugInfoTable(self.ec, debug_info_table_base) stack_frame = self.ec.getTopLevelStackFrame() info = self.debug_info_table.load_symbols_at(int(stack_frame.getRegisterService().getValue('PC')) & 0xFFFFFFFF, self.verbose) debug_infos.append(info) while stack_frame.next() is not None: stack_frame = stack_frame.next() # Stack frame attached to 'PC' pc = int(stack_frame.getRegisterService().getValue('PC')) & 0xFFFFFFFF # Check if the symbols for this stack frame have already been loaded found = False for debug_info in debug_infos: if (pc >= debug_info[0]) and (pc < debug_info[0] + debug_info[1]): found = True if found == False: try: info = self.debug_info_table.load_symbols_at(pc) debug_infos.append(info) except: pass #self.debug_info_table.load_symbols_at(pc) else: raise Exception('ArmPlatformDebugger', "Not supported region") def load_all_symbols(self): # Load all the XIP symbols attached to the Firmware Volume for (fv_base, fv_size) in self.platform.fvs: if self.firmware_volumes.has_key(fv_base) == False: self.firmware_volumes[fv_base] = firmware_volume.FirmwareVolume(self.ec, fv_base, fv_size) self.firmware_volumes[fv_base].load_all_symbols(self.verbose) try: # Load all symbols of module loaded into System Memory if self.system_table is None: # Find the System Table self.system_table = system_table.SystemTable(self.ec, self.platform.sysmembase, self.platform.sysmemsize) # Find the Debug Info Table debug_info_table_base = self.system_table.get_configuration_table(system_table.DebugInfoTable.CONST_DEBUG_INFO_TABLE_GUID) self.debug_info_table = system_table.DebugInfoTable(self.ec, debug_info_table_base) self.debug_info_table.load_all_symbols(self.verbose) except: # Debugger exception could be excepted if DRAM has not been initialized or if we have not started to run from DRAM yet print "Note: no symbols have been found in System Memory (possible cause: the UEFI permanent memory has not been installed yet)"