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:
@ -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
|
# This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -21,16 +21,18 @@ import edk2_debugger
|
|||||||
reload(edk2_debugger)
|
reload(edk2_debugger)
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
|
print "-v,--verbose"
|
||||||
print "-a,--all: Load all symbols"
|
print "-a,--all: Load all symbols"
|
||||||
print "-l,--report=: Filename for the EDK2 report log"
|
print "-l,--report=: Filename for the EDK2 report log"
|
||||||
print "-m,--sysmem=(base,size): System Memory region"
|
print "-m,--sysmem=(base,size): System Memory region"
|
||||||
print "-f,--fv=(base,size): Firmware region"
|
print "-f,--fv=(base,size): Firmware region"
|
||||||
print "-r,--rom=(base,size): ROM region"
|
print "-r,--rom=(base,size): ROM region"
|
||||||
|
|
||||||
|
verbose = False
|
||||||
load_all = False
|
load_all = False
|
||||||
report_file = None
|
report_file = None
|
||||||
regions = []
|
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):
|
if (opts is None) or (not opts):
|
||||||
report_file = '../../../report.log'
|
report_file = '../../../report.log'
|
||||||
else:
|
else:
|
||||||
@ -44,6 +46,8 @@ else:
|
|||||||
if o in ("-h","--help"):
|
if o in ("-h","--help"):
|
||||||
usage()
|
usage()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
elif o in ("-v","--verbose"):
|
||||||
|
verbose = True
|
||||||
elif o in ("-a","--all"):
|
elif o in ("-a","--all"):
|
||||||
load_all = True
|
load_all = True
|
||||||
elif o in ("-l","--report"):
|
elif o in ("-l","--report"):
|
||||||
@ -58,7 +62,7 @@ else:
|
|||||||
region_type = edk2_debugger.ArmPlatformDebugger.REGION_TYPE_ROM
|
region_type = edk2_debugger.ArmPlatformDebugger.REGION_TYPE_ROM
|
||||||
regex = region_reg
|
regex = region_reg
|
||||||
else:
|
else:
|
||||||
assert False, "Unhandled option"
|
assert False, "Unhandled option (%s)" % o
|
||||||
|
|
||||||
if region_type:
|
if region_type:
|
||||||
m = regex.match(a)
|
m = regex.match(a)
|
||||||
@ -83,10 +87,8 @@ ec.getExecutionService().waitForStop()
|
|||||||
# in case the execution context reference is out of date
|
# in case the execution context reference is out of date
|
||||||
ec = debugger.getExecutionContext(0)
|
ec = debugger.getExecutionContext(0)
|
||||||
|
|
||||||
armplatform_debugger = edk2_debugger.ArmPlatformDebugger(ec, report_file, regions)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
armplatform_debugger = edk2_debugger.ArmPlatformDebugger(ec, report_file, regions)
|
armplatform_debugger = edk2_debugger.ArmPlatformDebugger(ec, report_file, regions, verbose)
|
||||||
|
|
||||||
if load_all:
|
if load_all:
|
||||||
armplatform_debugger.load_all_symbols()
|
armplatform_debugger.load_all_symbols()
|
||||||
|
@ -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
|
# This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# 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 = system_table.DebugInfoTable(ec, debug_info_table_base)
|
||||||
debug_info_table.dump()
|
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:
|
try:
|
||||||
ec.getImageService().addSymbols(filename, address)
|
ec.getImageService().addSymbols(filename, address)
|
||||||
except:
|
except:
|
||||||
@ -62,7 +65,7 @@ def load_symbol_from_file(ec, filename, address):
|
|||||||
ec.getImageService().unloadSymbols(filename)
|
ec.getImageService().unloadSymbols(filename)
|
||||||
ec.getImageService().addSymbols(filename, address)
|
ec.getImageService().addSymbols(filename, address)
|
||||||
except:
|
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
|
pass
|
||||||
|
|
||||||
class ArmPlatform:
|
class ArmPlatform:
|
||||||
@ -79,8 +82,9 @@ class ArmPlatformDebugger:
|
|||||||
REGION_TYPE_ROM = 2
|
REGION_TYPE_ROM = 2
|
||||||
REGION_TYPE_FV = 3
|
REGION_TYPE_FV = 3
|
||||||
|
|
||||||
def __init__(self, ec, report_log, regions):
|
def __init__(self, ec, report_log, regions, verbose = False):
|
||||||
self.ec = ec
|
self.ec = ec
|
||||||
|
self.verbose = verbose
|
||||||
fvs = []
|
fvs = []
|
||||||
sysmem_base = None
|
sysmem_base = None
|
||||||
sysmem_size = None
|
sysmem_size = None
|
||||||
@ -141,7 +145,7 @@ class ArmPlatformDebugger:
|
|||||||
self.firmware_volumes[fv_base] = firmware_volume.FirmwareVolume(self.ec, fv_base, fv_size)
|
self.firmware_volumes[fv_base] = firmware_volume.FirmwareVolume(self.ec, fv_base, fv_size)
|
||||||
|
|
||||||
stack_frame = self.ec.getTopLevelStackFrame()
|
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)
|
debug_infos.append(info)
|
||||||
while stack_frame.next() is not None:
|
while stack_frame.next() is not None:
|
||||||
stack_frame = stack_frame.next()
|
stack_frame = stack_frame.next()
|
||||||
@ -171,7 +175,7 @@ class ArmPlatformDebugger:
|
|||||||
self.debug_info_table = system_table.DebugInfoTable(self.ec, debug_info_table_base)
|
self.debug_info_table = system_table.DebugInfoTable(self.ec, debug_info_table_base)
|
||||||
|
|
||||||
stack_frame = self.ec.getTopLevelStackFrame()
|
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)
|
debug_infos.append(info)
|
||||||
while stack_frame.next() is not None:
|
while stack_frame.next() is not None:
|
||||||
stack_frame = stack_frame.next()
|
stack_frame = stack_frame.next()
|
||||||
@ -197,7 +201,7 @@ class ArmPlatformDebugger:
|
|||||||
for (fv_base, fv_size) in self.platform.fvs:
|
for (fv_base, fv_size) in self.platform.fvs:
|
||||||
if self.firmware_volumes.has_key(fv_base) == False:
|
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] = 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:
|
try:
|
||||||
# Load all symbols of module loaded into System Memory
|
# 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)
|
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 = 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:
|
except:
|
||||||
# Debugger exception could be excepted if DRAM has not been initialized or if we have not started to run from DRAM yet
|
# 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)"
|
print "Note: no symbols have been found in System Memory (possible cause: the UEFI permanent memory has been installed yet)"
|
||||||
|
@ -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
|
# This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# 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)
|
section = ffs.get_next_section(section)
|
||||||
ffs = self.get_next_ffs(ffs)
|
ffs = self.get_next_ffs(ffs)
|
||||||
|
|
||||||
def load_symbols_at(self, addr):
|
def load_symbols_at(self, addr, verbose = False):
|
||||||
if self.DebugInfos == []:
|
if self.DebugInfos == []:
|
||||||
self.get_debug_info()
|
self.get_debug_info()
|
||||||
|
|
||||||
@ -282,11 +282,16 @@ class FirmwareVolume:
|
|||||||
else:
|
else:
|
||||||
raise Exception('FirmwareVolume','Section Type not supported')
|
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
|
return debug_info
|
||||||
|
|
||||||
def load_all_symbols(self):
|
def load_all_symbols(self, verbose = False):
|
||||||
if self.DebugInfos == []:
|
if self.DebugInfos == []:
|
||||||
self.get_debug_info()
|
self.get_debug_info()
|
||||||
|
|
||||||
@ -298,4 +303,10 @@ class FirmwareVolume:
|
|||||||
else:
|
else:
|
||||||
continue
|
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
|
||||||
|
|
||||||
|
@ -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
|
# This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# 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))
|
self.DebugInfos.append((image_base,image_size))
|
||||||
|
|
||||||
# Return (base, size)
|
# Return (base, size)
|
||||||
def load_symbols_at(self, addr):
|
def load_symbols_at(self, addr, verbose = False):
|
||||||
if self.DebugInfos == []:
|
if self.DebugInfos == []:
|
||||||
self.get_debug_info()
|
self.get_debug_info()
|
||||||
|
|
||||||
@ -57,7 +57,12 @@ class DebugInfoTable:
|
|||||||
if (addr >= debug_info[0]) and (addr < debug_info[0] + debug_info[1]):
|
if (addr >= debug_info[0]) and (addr < debug_info[0] + debug_info[1]):
|
||||||
section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0])
|
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
|
found = True
|
||||||
return debug_info
|
return debug_info
|
||||||
@ -65,14 +70,19 @@ class DebugInfoTable:
|
|||||||
if found == False:
|
if found == False:
|
||||||
raise Exception('DebugInfoTable','No symbol found at 0x%x' % addr)
|
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 == []:
|
if self.DebugInfos == []:
|
||||||
self.get_debug_info()
|
self.get_debug_info()
|
||||||
|
|
||||||
for debug_info in self.DebugInfos:
|
for debug_info in self.DebugInfos:
|
||||||
section = firmware_volume.EfiSectionPE32(self.ec, debug_info[0])
|
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):
|
def dump(self):
|
||||||
self.get_debug_info()
|
self.get_debug_info()
|
||||||
|
Reference in New Issue
Block a user