OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 bisect | 5 import bisect |
6 import os | |
7 import re | 6 import re |
8 import sys | |
9 | 7 |
10 | 8 |
11 _ARGUMENT_TYPE_PATTERN = re.compile('\([^()]*\)(\s*const)?') | 9 _ARGUMENT_TYPE_PATTERN = re.compile('\([^()]*\)(\s*const)?') |
12 _TEMPLATE_ARGUMENT_PATTERN = re.compile('<[^<>]*>') | 10 _TEMPLATE_ARGUMENT_PATTERN = re.compile('<[^<>]*>') |
13 _LEADING_TYPE_PATTERN = re.compile('^.*\s+(\w+::)') | 11 _LEADING_TYPE_PATTERN = re.compile('^.*\s+(\w+::)') |
14 _READELF_SECTION_HEADER_PATTER = re.compile( | 12 _READELF_SECTION_HEADER_PATTER = re.compile( |
15 '^\s*\[\s*(Nr|\d+)\]\s+(|\S+)\s+([A-Z_]+)\s+([0-9a-f]+)\s+' | 13 '^\s*\[\s*(Nr|\d+)\]\s+(|\S+)\s+([A-Z_]+)\s+([0-9a-f]+)\s+' |
16 '([0-9a-f]+)\s+([0-9a-f]+)\s+([0-9]+)\s+([WAXMSILGxOop]*)\s+' | 14 '([0-9a-f]+)\s+([0-9a-f]+)\s+([0-9]+)\s+([WAXMSILGxOop]*)\s+' |
17 '([0-9]+)\s+([0-9]+)\s+([0-9]+)') | 15 '([0-9]+)\s+([0-9]+)\s+([0-9]+)') |
18 | 16 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 matched.group(7), # es | 176 matched.group(7), # es |
179 matched.group(8), # flg | 177 matched.group(8), # flg |
180 matched.group(9), # lk | 178 matched.group(9), # lk |
181 matched.group(10), # inf | 179 matched.group(10), # inf |
182 matched.group(11) # al | 180 matched.group(11) # al |
183 )) | 181 )) |
184 else: | 182 else: |
185 if line in ('Key to Flags:', 'Program Headers:'): | 183 if line in ('Key to Flags:', 'Program Headers:'): |
186 break | 184 break |
187 | 185 |
188 def _parse_nm_bsd_line(self, line): | 186 @staticmethod |
| 187 def _parse_nm_bsd_line(line): |
189 if line[8] == ' ': | 188 if line[8] == ' ': |
190 return line[0:8], line[9], line[11:] | 189 return line[0:8], line[9], line[11:] |
191 elif line[16] == ' ': | 190 elif line[16] == ' ': |
192 return line[0:16], line[17], line[19:] | 191 return line[0:16], line[17], line[19:] |
193 raise ParsingException('Invalid nm output.') | 192 raise ParsingException('Invalid nm output.') |
194 | 193 |
195 def _get_short_function_name(self, function): | 194 @staticmethod |
| 195 def _get_short_function_name(function): |
196 while True: | 196 while True: |
197 function, number = _ARGUMENT_TYPE_PATTERN.subn('', function) | 197 function, number = _ARGUMENT_TYPE_PATTERN.subn('', function) |
198 if not number: | 198 if not number: |
199 break | 199 break |
200 while True: | 200 while True: |
201 function, number = _TEMPLATE_ARGUMENT_PATTERN.subn('', function) | 201 function, number = _TEMPLATE_ARGUMENT_PATTERN.subn('', function) |
202 if not number: | 202 if not number: |
203 break | 203 break |
204 return _LEADING_TYPE_PATTERN.sub('\g<1>', function) | 204 return _LEADING_TYPE_PATTERN.sub('\g<1>', function) |
205 | 205 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 self._append_procedure( | 254 self._append_procedure( |
255 last_start, Procedure(last_start, start_val, routine)) | 255 last_start, Procedure(last_start, start_val, routine)) |
256 | 256 |
257 last_start = start_val | 257 last_start = start_val |
258 routine = sym_name | 258 routine = sym_name |
259 | 259 |
260 if not mangled: | 260 if not mangled: |
261 routine = self._get_short_function_name(routine) | 261 routine = self._get_short_function_name(routine) |
262 self._append_procedure( | 262 self._append_procedure( |
263 last_start, Procedure(last_start, last_start, routine)) | 263 last_start, Procedure(last_start, last_start, routine)) |
OLD | NEW |