|
15 | 15 |
|
16 | 16 | if len(sys.argv) != 3: |
17 | 17 | print("usage: objsym.py outfile libv8_base.a") |
18 | | - sys.exit(2); |
| 18 | + sys.exit(2) |
19 | 19 |
|
20 | | -outfile = file(sys.argv[1], 'w'); |
| 20 | +outfile = open(sys.argv[1], 'w') |
21 | 21 | try: |
22 | 22 | pipe = subprocess.Popen([ 'objdump', '-z', '-D', sys.argv[2] ], |
23 | | - bufsize=-1, stdout=subprocess.PIPE).stdout; |
24 | | -except OSError, e: |
| 23 | + bufsize=-1, stdout=subprocess.PIPE).stdout |
| 24 | +except OSError as e: |
25 | 25 | if e.errno == errno.ENOENT: |
26 | 26 | print(''' |
27 | 27 | Node.js compile error: could not find objdump |
|
33 | 33 |
|
34 | 34 | sys.exit() |
35 | 35 |
|
36 | | -pattern = re.compile('([0-9a-fA-F]{8}|[0-9a-fA-F]{16}) <(.*)>:'); |
| 36 | +pattern = re.compile('([0-9a-fA-F]{8}|[0-9a-fA-F]{16}) <(.*)>:') |
37 | 37 | v8dbg = re.compile('^v8dbg.*$') |
38 | | -numpattern = re.compile('^[0-9a-fA-F]{2} $'); |
| 38 | +numpattern = re.compile('^[0-9a-fA-F]{2} $') |
39 | 39 | octets = 4 |
40 | 40 |
|
41 | 41 | outfile.write(""" |
|
49 | 49 | #ifndef V8_CONSTANTS_H |
50 | 50 | #define V8_CONSTANTS_H |
51 | 51 |
|
52 | | -"""); |
| 52 | +""") |
53 | 53 |
|
54 | | -curr_sym = None; |
55 | | -curr_val = 0; |
56 | | -curr_octet = 0; |
| 54 | +curr_sym = None |
| 55 | +curr_val = 0 |
| 56 | +curr_octet = 0 |
57 | 57 |
|
58 | 58 | def out_reset(): |
59 | 59 | global curr_sym, curr_val, curr_octet |
60 | | - curr_sym = None; |
61 | | - curr_val = 0; |
62 | | - curr_octet = 0; |
| 60 | + curr_sym = None |
| 61 | + curr_val = 0 |
| 62 | + curr_octet = 0 |
63 | 63 |
|
64 | 64 | def out_define(): |
65 | 65 | global curr_sym, curr_val, curr_octet, outfile, octets |
66 | 66 | if curr_sym != None: |
67 | | - wrapped_val = curr_val & 0xffffffff; |
| 67 | + wrapped_val = curr_val & 0xffffffff |
68 | 68 | if curr_val & 0x80000000 != 0: |
69 | | - wrapped_val = 0x100000000 - wrapped_val; |
70 | | - outfile.write("#define %s -0x%x\n" % (curr_sym.upper(), wrapped_val)); |
| 69 | + wrapped_val = 0x100000000 - wrapped_val |
| 70 | + outfile.write("#define %s -0x%x\n" % (curr_sym.upper(), wrapped_val)) |
71 | 71 | else: |
72 | | - outfile.write("#define %s 0x%x\n" % (curr_sym.upper(), wrapped_val)); |
73 | | - out_reset(); |
| 72 | + outfile.write("#define %s 0x%x\n" % (curr_sym.upper(), wrapped_val)) |
| 73 | + out_reset() |
74 | 74 |
|
75 | 75 | for line in pipe: |
76 | 76 | if curr_sym != None: |
@@ -81,35 +81,35 @@ def out_define(): |
81 | 81 | # much like hex numbers (e.g., "adc"), and we don't want to risk picking |
82 | 82 | # those up by mistake, so we look at character-based columns instead. |
83 | 83 | # |
84 | | - for i in range (0, 3): |
| 84 | + for i in range(0, 3): |
85 | 85 | # 6-character margin, 2-characters + 1 space for each field |
86 | | - idx = 6 + i * 3; |
| 86 | + idx = 6 + i * 3 |
87 | 87 | octetstr = line[idx:idx+3] |
88 | 88 | if curr_octet > octets: |
89 | | - break; |
| 89 | + break |
90 | 90 |
|
91 | 91 | if not numpattern.match(octetstr): |
92 | | - break; |
| 92 | + break |
93 | 93 |
|
94 | | - curr_val += int('0x%s' % octetstr, 16) << (curr_octet * 8); |
95 | | - curr_octet += 1; |
| 94 | + curr_val += int('0x%s' % octetstr, 16) << (curr_octet * 8) |
| 95 | + curr_octet += 1 |
96 | 96 |
|
97 | 97 | match = pattern.match(line) |
98 | 98 | if match == None: |
99 | | - continue; |
| 99 | + continue |
100 | 100 |
|
101 | 101 | # Print previous symbol |
102 | | - out_define(); |
| 102 | + out_define() |
103 | 103 |
|
104 | | - v8match = v8dbg.match(match.group(2)); |
| 104 | + v8match = v8dbg.match(match.group(2)) |
105 | 105 | if v8match != None: |
106 | | - out_reset(); |
107 | | - curr_sym = match.group(2); |
| 106 | + out_reset() |
| 107 | + curr_sym = match.group(2) |
108 | 108 |
|
109 | 109 | # Print last symbol |
110 | | -out_define(); |
| 110 | +out_define() |
111 | 111 |
|
112 | 112 | outfile.write(""" |
113 | 113 |
|
114 | 114 | #endif /* V8_CONSTANTS_H */ |
115 | | -"""); |
| 115 | +""") |