ArmPlatformPkg/Scripts: Added '--verbose' support to DS-5 scripts

Verbose mode can also be enabled by the shorter argument '-v'

Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14100 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2013-01-25 12:14:09 +00:00
parent 111339d2a2
commit 72efe0271f
4 changed files with 52 additions and 25 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
# Copyright (c) 2011-2013, 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
@ -21,16 +21,18 @@ import edk2_debugger
reload(edk2_debugger)
def usage():
print "-v,--verbose"
print "-a,--all: Load all symbols"
print "-l,--report=: Filename for the EDK2 report log"
print "-m,--sysmem=(base,size): System Memory region"
print "-f,--fv=(base,size): Firmware region"
print "-r,--rom=(base,size): ROM region"
verbose = False
load_all = False
report_file = None
regions = []
opts,args = getopt.getopt(sys.argv[1:], "har:vm:vr:vf:v", ["help","all","report=","sysmem=","rom=","fv="])
opts,args = getopt.getopt(sys.argv[1:], "hvar:vm:vr:vf:v", ["help","verbose","all","report=","sysmem=","rom=","fv="])
if (opts is None) or (not opts):
report_file = '../../../report.log'
else:
@ -44,6 +46,8 @@ else:
if o in ("-h","--help"):
usage()
sys.exit()
elif o in ("-v","--verbose"):
verbose = True
elif o in ("-a","--all"):
load_all = True
elif o in ("-l","--report"):
@ -58,7 +62,7 @@ else:
region_type = edk2_debugger.ArmPlatformDebugger.REGION_TYPE_ROM
regex = region_reg
else:
assert False, "Unhandled option"
assert False, "Unhandled option (%s)" % o
if region_type:
m = regex.match(a)
@ -83,10 +87,8 @@ ec.getExecutionService().waitForStop()
# in case the execution context reference is out of date
ec = debugger.getExecutionContext(0)
armplatform_debugger = edk2_debugger.ArmPlatformDebugger(ec, report_file, regions)
try:
armplatform_debugger = edk2_debugger.ArmPlatformDebugger(ec, report_file, regions)
armplatform_debugger = edk2_debugger.ArmPlatformDebugger(ec, report_file, regions, verbose)
if load_all:
armplatform_debugger.load_all_symbols()

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
# Copyright (c) 2011-2013, 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
@ -53,7 +53,10 @@ def dump_system_table(ec, mem_base, mem_size):
debug_info_table = system_table.DebugInfoTable(ec, debug_info_table_base)
debug_info_table.dump()
def load_symbol_from_file(ec, filename, address):
def load_symbol_from_file(ec, filename, address, verbose = False):
if verbose:
print "Add symbols of %s at 0x%x" % (filename, address)
try:
ec.getImageService().addSymbols(filename, address)
except:
@ -62,7 +65,7 @@ def load_symbol_from_file(ec, filename, address):
ec.getImageService().unloadSymbols(filename)
ec.getImageService().addSymbols(filename, address)
except:
print "Warning: not possible to load symbols from %s" % filename
print "Warning: not possible to load symbols from %s at 0x%x" % (filename, address)
pass
class ArmPlatform:
@ -79,8 +82,9 @@ class ArmPlatformDebugger:
REGION_TYPE_ROM = 2
REGION_TYPE_FV = 3
def __init__(self, ec, report_log, regions):
def __init__(self, ec, report_log, regions, verbose = False):
self.ec = ec
self.verbose = verbose
fvs = []
sysmem_base = None
sysmem_size = None
@ -89,7 +93,7 @@ class ArmPlatformDebugger:
try:
self.build = build_report.BuildReport(report_log)
except IOError:
raise IOError(2, 'Report \'%s\' isnot valid' % report_log)
raise IOError(2, 'Report \'%s\' is not valid' % report_log)
# Generate list of supported Firmware Volumes
if self.build.PCDs['gArmTokenSpaceGuid'].has_key('PcdFvSize') and int(self.build.PCDs['gArmTokenSpaceGuid']['PcdFvSize'][0],16) != 0:
@ -141,7 +145,7 @@ class ArmPlatformDebugger:
self.firmware_volumes[fv_base] = firmware_volume.FirmwareVolume(self.ec, fv_base, fv_size)
stack_frame = self.ec.getTopLevelStackFrame()
info = self.firmware_volumes[fv_base].load_symbols_at(int(stack_frame.getRegisterService().getValue('PC')) & 0xFFFFFFFF)
info = self.firmware_volumes[fv_base].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()
@ -171,7 +175,7 @@ class ArmPlatformDebugger:
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)
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()
@ -197,7 +201,7 @@ class ArmPlatformDebugger:
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.firmware_volumes[fv_base].load_all_symbols(self.verbose)
try:
# Load all symbols of module loaded into System Memory
@ -210,7 +214,7 @@ class ArmPlatformDebugger:
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.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 been installed yet)"

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
# Copyright (c) 2011-2013, 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
@ -269,7 +269,7 @@ class FirmwareVolume:
section = ffs.get_next_section(section)
ffs = self.get_next_ffs(ffs)
def load_symbols_at(self, addr):
def load_symbols_at(self, addr, verbose = False):
if self.DebugInfos == []:
self.get_debug_info()
@ -282,11 +282,16 @@ class FirmwareVolume:
else:
raise Exception('FirmwareVolume','Section Type not supported')
edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase())
try:
edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose)
except Exception, (ErrorClass, ErrorMessage):
if verbose:
print "Error while loading a symbol file (%s: %s)" % (ErrorClass, ErrorMessage)
pass
return debug_info
def load_all_symbols(self):
def load_all_symbols(self, verbose = False):
if self.DebugInfos == []:
self.get_debug_info()
@ -298,4 +303,10 @@ class FirmwareVolume:
else:
continue
edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase())
try:
edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose)
except Exception, (ErrorClass, ErrorMessage):
if verbose:
print "Error while loading a symbol file (%s: %s)" % (ErrorClass, ErrorMessage)
pass

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011-2012, ARM Limited. All rights reserved.
# Copyright (c) 2011-2013, 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
@ -48,7 +48,7 @@ class DebugInfoTable:
self.DebugInfos.append((image_base,image_size))
# Return (base, size)
def load_symbols_at(self, addr):
def load_symbols_at(self, addr, verbose = False):
if self.DebugInfos == []:
self.get_debug_info()
@ -57,7 +57,12 @@ class DebugInfoTable:
if (addr >= debug_info[0]) and (addr < debug_info[0] + debug_info[1]):
section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0])
edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase())
try:
edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose)
except Exception, (ErrorClass, ErrorMessage):
if verbose:
print "Error while loading a symbol file (%s: %s)" % (ErrorClass, ErrorMessage)
pass
found = True
return debug_info
@ -65,14 +70,19 @@ class DebugInfoTable:
if found == False:
raise Exception('DebugInfoTable','No symbol found at 0x%x' % addr)
def load_all_symbols(self):
def load_all_symbols(self, verbose = False):
if self.DebugInfos == []:
self.get_debug_info()
for debug_info in self.DebugInfos:
section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0])
edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase())
try:
edk2_debugger.load_symbol_from_file(self.ec, section.get_debug_filepath(), section.get_debug_elfbase(), verbose)
except Exception, (ErrorClass, ErrorMessage):
if verbose:
print "Error while loading a symbol file (%s: %s)" % (ErrorClass, ErrorMessage)
pass
def dump(self):
self.get_debug_info()