Debian Codegraph @

src/analyzer/generate_python.py

raw symbols SCIP
1 # pyOCD debugger
2 # Copyright (c) 2006-2015,2020 Arm Limited
3 # SPDX-License-Identifier: Apache-2.0
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 from __future__ import print_function
17 import sys
18 from struct import unpack
19
20 INPUT_FILENAME = sys.argv[1]
21 OUTPUT_FILENAME = sys.argv[2]
22
23 with open(INPUT_FILENAME, "rb") as f:
24 data = f.read()
25
26 words = len(data) // 4
27 if len(data) % 4 != 0:
28 print("Warning: input length not word aligned")
29 print("Data length %i" % len(data))
30 data = unpack("<%iL" % words, data)
31
32 str = "analyzer = (\n "
33 count = 0
34 for val in data:
35 if count % 8 == 7:
36 str += "0x{:08x},\n ".format(val)
37 else:
38 str += "0x{:08x}, ".format(val)
39 count += 1
40 str += "\n )"
41 data = str
42
43 with open(OUTPUT_FILENAME, "w") as f:
44 f.write(data)