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

Side by Side Diff: tracing/bin/symbolize_trace_macho_reader.py

Issue 2698543003: Use absolute pcs and load locations to symbolize on macOS. (Closed)
Patch Set: comments from dskiba. Created 3 years, 10 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 | « tracing/bin/symbolize_trace ('k') | tracing/bin/symbolize_trace_macho_reader_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import re
6 import subprocess
7
8
9 def ReadMachOTextLoadAddress(file_name):
10 """
11 This function returns the load address of the TEXT segment of a Mach-O file.
12 """
13 regex = re.compile(r".* vmaddr 0x([\dabcdef]*)")
14 cmd = ["otool", "-l", file_name]
15 output = subprocess.check_output(cmd).split('\n')
16 for i in range(len(output) - 3):
17 # It's possible to use a regex here instead, but these conditionals are much
18 # clearer.
19 if ("cmd LC_SEGMENT_64" in output[i] and
20 "cmdsize" in output[i + 1] and
21 "segname __TEXT" in output[i + 2] and
22 "vmaddr" in output[i + 3]):
23 result = regex.match(output[i + 3])
24 assert result
25 return int(result.group(1), 16)
26 return None
OLDNEW
« no previous file with comments | « tracing/bin/symbolize_trace ('k') | tracing/bin/symbolize_trace_macho_reader_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698