]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/Scripts/Ds5/cmd_load_symbols.py
424eb63cbbe957a7c7ca09bfdee3a5b10f343c07
[mirror_edk2.git] / ArmPlatformPkg / Scripts / Ds5 / cmd_load_symbols.py
1 #
2 # Copyright (c) 2011-2012, ARM Limited. All rights reserved.
3 #
4 # This program and the accompanying materials
5 # are licensed and made available under the terms and conditions of the BSD License
6 # which accompanies this distribution. The full text of the license may be found at
7 # http://opensource.org/licenses/bsd-license.php
8 #
9 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 #
12
13 from arm_ds.debugger_v1 import Debugger
14 from arm_ds.debugger_v1 import DebugException
15
16 import re, sys, getopt
17
18 import edk2_debugger
19
20 # Reload external classes
21 reload(edk2_debugger)
22
23 def usage():
24 print "-a,--all: Load all symbols"
25 print "-l,--report=: Filename for the EDK2 report log"
26 print "-m,--sysmem=(base,size): System Memory region"
27 print "-f,--fv=(base,size): Firmware region"
28 print "-r,--rom=(base,size): ROM region"
29
30 load_all = False
31 report_file = None
32 regions = []
33 opts,args = getopt.getopt(sys.argv[1:], "har:vm:vr:vf:v", ["help","all","report=","sysmem=","rom=","fv="])
34 if (opts is None) or (not opts):
35 report_file = '../../../report.log'
36 else:
37 region_reg = re.compile("\((.*),(.*)\)")
38 base_reg = re.compile("(.*)")
39
40 for o,a in opts:
41 region_type = None
42 regex = None
43 m = None
44 if o in ("-h","--help"):
45 usage()
46 sys.exit()
47 elif o in ("-a","--all"):
48 load_all = True
49 elif o in ("-l","--report"):
50 report_file = a
51 elif o in ("-m","--sysmem"):
52 region_type = edk2_debugger.ArmPlatformDebugger.REGION_TYPE_SYSMEM
53 regex = region_reg
54 elif o in ("-f","--fv"):
55 region_type = edk2_debugger.ArmPlatformDebugger.REGION_TYPE_FV
56 regex = region_reg
57 elif o in ("-r","--rom"):
58 region_type = edk2_debugger.ArmPlatformDebugger.REGION_TYPE_ROM
59 regex = region_reg
60 else:
61 assert False, "Unhandled option"
62
63 if region_type:
64 m = regex.match(a)
65 if m:
66 if regex.groups == 1:
67 regions.append((region_type,int(m.group(1),0),0))
68 else:
69 regions.append((region_type,int(m.group(1),0),int(m.group(2),0)))
70 else:
71 if regex.groups == 1:
72 raise Exception('cmd_load_symbols', "Expect a base address")
73 else:
74 raise Exception('cmd_load_symbols', "Expect a region format as (base,size)")
75
76 # Debugger object for accessing the debugger
77 debugger = Debugger()
78
79 # Initialisation commands
80 ec = debugger.getExecutionContext(0)
81 ec.getExecutionService().stop()
82 ec.getExecutionService().waitForStop()
83 # in case the execution context reference is out of date
84 ec = debugger.getExecutionContext(0)
85
86 armplatform_debugger = edk2_debugger.ArmPlatformDebugger(ec, report_file, regions)
87
88 try:
89 armplatform_debugger = edk2_debugger.ArmPlatformDebugger(ec, report_file, regions)
90
91 if load_all:
92 armplatform_debugger.load_all_symbols()
93 else:
94 armplatform_debugger.load_current_symbols()
95 except IOError, (ErrorNumber, ErrorMessage):
96 print "Error: %s" % ErrorMessage
97 except Exception, (ErrorClass, ErrorMessage):
98 print "Error(%s): %s" % (ErrorClass, ErrorMessage)
99 except DebugException, de:
100 print "DebugError: %s" % (de.getMessage())