Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: tools/binary_size/linker_map_parser.py

Issue 2775173005: FREEZE.unindexed (Closed)
Patch Set: ps2 Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/binary_size/integration_test.py ('k') | tools/binary_size/map2size.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 6
7 import models 7 import models
8 8
9 9
10 class MapFileParser(object): 10 class MapFileParser(object):
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 self._SkipToLineWithPrefix('Common symbol') 60 self._SkipToLineWithPrefix('Common symbol')
61 next(self._lines) # Skip past blank line 61 next(self._lines) # Skip past blank line
62 62
63 name, size_str, path = None, None, None 63 name, size_str, path = None, None, None
64 for l in self._lines: 64 for l in self._lines:
65 parts = self._ParsePossiblyWrappedParts(l, 3) 65 parts = self._ParsePossiblyWrappedParts(l, 3)
66 if not parts: 66 if not parts:
67 break 67 break
68 name, size_str, path = parts 68 name, size_str, path = parts
69 self._symbols.append( 69 self._symbols.append(
70 models.Symbol('.bss', int(size_str[2:], 16), name=name, path=path)) 70 models.Symbol('.bss', int(size_str[2:], 16), name=name,
71 object_path=path))
71 72
72 def _ParseSections(self): 73 def _ParseSections(self):
73 # .text 0x0028c600 0x22d3468 74 # .text 0x0028c600 0x22d3468
74 # .text.startup._GLOBAL__sub_I_bbr_sender.cc 75 # .text.startup._GLOBAL__sub_I_bbr_sender.cc
75 # 0x0028c600 0x38 obj/net/net/bbr_sender.o 76 # 0x0028c600 0x38 obj/net/net/bbr_sender.o
76 # .text._reset 0x00339d00 0xf0 obj/third_party/icu/icuuc/ucnv.o 77 # .text._reset 0x00339d00 0xf0 obj/third_party/icu/icuuc/ucnv.o
77 # ** fill 0x0255fb00 0x02 78 # ** fill 0x0255fb00 0x02
78 # .text._ZN4base8AutoLockD2Ev 79 # .text._ZN4base8AutoLockD2Ev
79 # 0x00290710 0xe obj/net/net/file_name.o 80 # 0x00290710 0xe obj/net/net/file_name.o
80 # 0x00290711 base::AutoLock::~AutoLock() 81 # 0x00290711 base::AutoLock::~AutoLock()
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 address_str, size_str = self._ParsePossiblyWrappedParts(line, 2) 135 address_str, size_str = self._ParsePossiblyWrappedParts(line, 2)
135 line = next(self._lines) 136 line = next(self._lines)
136 # These bytes are already accounted for. 137 # These bytes are already accounted for.
137 if name == '** common': 138 if name == '** common':
138 continue 139 continue
139 address = int(address_str[2:], 16) 140 address = int(address_str[2:], 16)
140 size = int(size_str[2:], 16) 141 size = int(size_str[2:], 16)
141 path = None 142 path = None
142 syms.append( 143 syms.append(
143 models.Symbol(section_name, size, address=address, name=name, 144 models.Symbol(section_name, size, address=address, name=name,
144 path=path)) 145 object_path=path))
145 else: 146 else:
146 # A normal symbol entry. 147 # A normal symbol entry.
147 subsection_name, address_str, size_str, path = ( 148 subsection_name, address_str, size_str, path = (
148 self._ParsePossiblyWrappedParts(line, 4)) 149 self._ParsePossiblyWrappedParts(line, 4))
149 size = int(size_str[2:], 16) 150 size = int(size_str[2:], 16)
150 assert subsection_name.startswith(section_name), ( 151 assert subsection_name.startswith(section_name), (
151 'subsection name was: ' + subsection_name) 152 'subsection name was: ' + subsection_name)
152 mangled_name = subsection_name[prefix_len:] 153 mangled_name = subsection_name[prefix_len:]
153 name = None 154 name = None
154 address_str2 = None 155 address_str2 = None
(...skipping 27 matching lines...) Expand all
182 else: 183 else:
183 address = int(address_str[2:], 16) 184 address = int(address_str[2:], 16)
184 # Finish off active address gap / merge section. 185 # Finish off active address gap / merge section.
185 if merge_symbol_start_address: 186 if merge_symbol_start_address:
186 merge_size = address - merge_symbol_start_address 187 merge_size = address - merge_symbol_start_address
187 logging.debug('Merge symbol of size %d found at:\n %r', 188 logging.debug('Merge symbol of size %d found at:\n %r',
188 merge_size, syms[-1]) 189 merge_size, syms[-1])
189 sym = models.Symbol( 190 sym = models.Symbol(
190 section_name, merge_size, 191 section_name, merge_size,
191 address=merge_symbol_start_address, 192 address=merge_symbol_start_address,
192 name='** symbol gap %d' % symbol_gap_count, path=path) 193 name='** symbol gap %d' % symbol_gap_count,
194 object_path=path)
193 symbol_gap_count += 1 195 symbol_gap_count += 1
194 syms.append(sym) 196 syms.append(sym)
195 merge_symbol_start_address = 0 197 merge_symbol_start_address = 0
196 198
197 if address == -1 and address_str2: 199 if address == -1 and address_str2:
198 address = int(address_str2[2:], 16) - 1 200 address = int(address_str2[2:], 16) - 1
199 # Merge sym with no second line showing real address. 201 # Merge sym with no second line showing real address.
200 if address == -1: 202 if address == -1:
201 address = syms[-1].end_address 203 address = syms[-1].end_address
202 syms.append(models.Symbol(section_name, size, address=address, 204 syms.append(models.Symbol(section_name, size, address=address,
203 name=name or mangled_name, path=path)) 205 name=name or mangled_name,
206 object_path=path))
204 logging.debug('Symbol count for %s: %d', section_name, 207 logging.debug('Symbol count for %s: %d', section_name,
205 len(syms) - sym_count_at_start) 208 len(syms) - sym_count_at_start)
206 except: 209 except:
207 logging.error('Problem line: %r', line) 210 logging.error('Problem line: %r', line)
208 logging.error('In section: %r', section_name) 211 logging.error('In section: %r', section_name)
209 raise 212 raise
OLDNEW
« no previous file with comments | « tools/binary_size/integration_test.py ('k') | tools/binary_size/map2size.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698