From a8e812dea5567a9ec582e3c14cb90c0090d3f052 Mon Sep 17 00:00:00 2001 From: oliviermartin Date: Mon, 22 Oct 2012 14:01:38 +0000 Subject: ArmPlatformPkg/Scripts: Added ARM DS-5 scripts to debug UEFI These scripts allow to automatically load the symbols using either the report file created by the BaseTools or using the memory regions defined in the arguments. This is the scripts for DS-5 prior to DS5 v5.12. Signed-off-by: Olivier Martin git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13874 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py | 212 ++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py (limited to 'ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py') diff --git a/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py b/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py new file mode 100644 index 0000000000..f922a7283e --- /dev/null +++ b/ArmPlatformPkg/Scripts/Ds5/edk2_debugger.py @@ -0,0 +1,212 @@ +# +# Copyright (c) 2011-2012, ARM Limited. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# + +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) + 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: + info = self.debug_info_table.load_symbols_at(pc) + debug_infos.append(info) + + #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() + + 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() + 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 been installed yet)" + pass -- cgit v1.2.3