diff options
author | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-10-22 14:01:38 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-10-22 14:01:38 +0000 |
commit | a8e812dea5567a9ec582e3c14cb90c0090d3f052 (patch) | |
tree | e04b95fc99a11d1d428f5c6122cc5b06a004d90e /ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py | |
parent | 6f6c7857c27272da66205b0257f95689aabb6e88 (diff) | |
download | edk2-platforms-a8e812dea5567a9ec582e3c14cb90c0090d3f052.tar.xz |
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 <olivier.martin@arm.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13874 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py')
-rw-r--r-- | ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py b/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py new file mode 100644 index 0000000000..424eb63cbb --- /dev/null +++ b/ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py @@ -0,0 +1,100 @@ +#
+# 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.
+#
+
+from arm_ds.debugger_v1 import Debugger
+from arm_ds.debugger_v1 import DebugException
+
+import re, sys, getopt
+
+import edk2_debugger
+
+# Reload external classes
+reload(edk2_debugger)
+
+def usage():
+ 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"
+
+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="])
+if (opts is None) or (not opts):
+ report_file = '../../../report.log'
+else:
+ region_reg = re.compile("\((.*),(.*)\)")
+ base_reg = re.compile("(.*)")
+
+ for o,a in opts:
+ region_type = None
+ regex = None
+ m = None
+ if o in ("-h","--help"):
+ usage()
+ sys.exit()
+ elif o in ("-a","--all"):
+ load_all = True
+ elif o in ("-l","--report"):
+ report_file = a
+ elif o in ("-m","--sysmem"):
+ region_type = edk2_debugger.ArmPlatformDebugger.REGION_TYPE_SYSMEM
+ regex = region_reg
+ elif o in ("-f","--fv"):
+ region_type = edk2_debugger.ArmPlatformDebugger.REGION_TYPE_FV
+ regex = region_reg
+ elif o in ("-r","--rom"):
+ region_type = edk2_debugger.ArmPlatformDebugger.REGION_TYPE_ROM
+ regex = region_reg
+ else:
+ assert False, "Unhandled option"
+
+ if region_type:
+ m = regex.match(a)
+ if m:
+ if regex.groups == 1:
+ regions.append((region_type,int(m.group(1),0),0))
+ else:
+ regions.append((region_type,int(m.group(1),0),int(m.group(2),0)))
+ else:
+ if regex.groups == 1:
+ raise Exception('cmd_load_symbols', "Expect a base address")
+ else:
+ raise Exception('cmd_load_symbols', "Expect a region format as (base,size)")
+
+# Debugger object for accessing the debugger
+debugger = Debugger()
+
+# Initialisation commands
+ec = debugger.getExecutionContext(0)
+ec.getExecutionService().stop()
+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)
+
+ if load_all:
+ armplatform_debugger.load_all_symbols()
+ else:
+ armplatform_debugger.load_current_symbols()
+except IOError, (ErrorNumber, ErrorMessage):
+ print "Error: %s" % ErrorMessage
+except Exception, (ErrorClass, ErrorMessage):
+ print "Error(%s): %s" % (ErrorClass, ErrorMessage)
+except DebugException, de:
+ print "DebugError: %s" % (de.getMessage())
|