Skip to content

Commit ffaf535

Browse files
committed
Add script to generate symbols from pdbs on Windows.
1 parent edf7496 commit ffaf535

File tree

5 files changed

+149
-11
lines changed

5 files changed

+149
-11
lines changed

docs/development/build-instructions-windows.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ softwares:
1818
* [Windows 7 SDK](http://www.microsoft.com/en-us/download/details.aspx?id=8279)
1919
* `Windows Headers` and `Visual C++ Compilers` are required.
2020

21+
If you want to dump breakpad symbols you also need to do this (you are free to
22+
skip this step if you don't know what it is):
23+
24+
1. Get a copy of `msdia80.dll` and put it in
25+
`C:\Program Files\Common Files\Microsoft Shared\VC\`.
26+
2. As Administrator, run:
27+
`regsvr32 c:\Program Files\Common Files\Microsoft Shared\VC\msdia80.dll`.
28+
2129
The instructions bellow are executed under [cygwin](http://www.cygwin.com),
2230
but it's not a requirement, you can also build atom-shell under Windows's
2331
console or other terminals.

script/create-dist.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,22 @@ def download_libchromiumcontent_symbols(url):
152152
if sys.platform == 'darwin':
153153
symbols_name = 'libchromiumcontent.dylib.dSYM'
154154
else:
155-
symbols_name = 'libchromiumcontent.dll.pdb'
156-
symbols_path = os.path.join(OUT_DIR, symbols_name)
157-
if os.path.exists(symbols_path):
158-
return
155+
symbols_name = 'chromiumcontent.dll.pdb'
159156

160157
brightray_dir = os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor')
161158
target_dir = os.path.join(brightray_dir, 'download', 'libchromiumcontent')
159+
symbols_path = os.path.join(target_dir, 'Release', symbols_name)
160+
if os.path.exists(symbols_path):
161+
return
162+
162163
download = os.path.join(brightray_dir, 'libchromiumcontent', 'script',
163164
'download')
164165
subprocess.check_call([sys.executable, download, '-f', '-s', url, target_dir])
165166

166-
shutil.copytree(os.path.join(target_dir, 'Release', symbols_name),
167-
symbols_path,
168-
symlinks=True)
167+
if sys.platform == 'darwin':
168+
shutil.copytree(symbols_path,
169+
os.path.join(OUT_DIR, symbols_name),
170+
symlinks=True)
169171

170172

171173
def create_symbols():

tools/mac/generate_breakpad_symbols.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
2-
# Copyright 2013 The Chromium Authors. All rights reserved.
2+
# Copyright (c) 2013 GitHub, Inc. All rights reserved.
3+
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
34
# Use of this source code is governed by a BSD-style license that can be
45
# found in the LICENSE file.
56

@@ -171,8 +172,8 @@ def _Worker():
171172
binary = queue.get()
172173

173174
if options.verbose:
174-
with print_lock:
175-
print "Generating symbols for %s" % binary
175+
with print_lock:
176+
print "Generating symbols for %s" % binary
176177

177178
if sys.platform == 'darwin':
178179
binary = GetDSYMBundle(options.build_dir, binary)
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/usr/bin/env python
2+
# Copyright (c) 2013 GitHub, Inc. All rights reserved.
3+
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
"""Convert pdb to sym for given directories"""
8+
9+
import errno
10+
import glob
11+
import optparse
12+
import os
13+
import Queue
14+
import re
15+
import subprocess
16+
import sys
17+
import threading
18+
19+
20+
CONCURRENT_TASKS=4
21+
SOURCE_ROOT=os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
22+
DUMP_SYMS=os.path.join(SOURCE_ROOT, 'vendor', 'breakpad', 'dump_syms.exe')
23+
24+
25+
def GetCommandOutput(command):
26+
"""Runs the command list, returning its output.
27+
28+
Prints the given command (which should be a list of one or more strings),
29+
then runs it and returns its output (stdout) as a string.
30+
31+
From chromium_utils.
32+
"""
33+
devnull = open(os.devnull, 'w')
34+
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=devnull,
35+
bufsize=1)
36+
output = proc.communicate()[0]
37+
return output
38+
39+
40+
def mkdir_p(path):
41+
"""Simulates mkdir -p."""
42+
try:
43+
os.makedirs(path)
44+
except OSError as e:
45+
if e.errno == errno.EEXIST and os.path.isdir(path):
46+
pass
47+
else: raise
48+
49+
50+
def GenerateSymbols(options, binaries):
51+
"""Dumps the symbols of binary and places them in the given directory."""
52+
53+
queue = Queue.Queue()
54+
print_lock = threading.Lock()
55+
56+
def _Worker():
57+
while True:
58+
binary = queue.get()
59+
60+
if options.verbose:
61+
with print_lock:
62+
print "Generating symbols for %s" % binary
63+
64+
syms = GetCommandOutput([DUMP_SYMS, binary])
65+
module_line = re.match("MODULE [^ ]+ [^ ]+ ([0-9A-F]+) (.*)\r\n", syms)
66+
if module_line == None:
67+
with print_lock:
68+
print "Failed to get symbols for %s" % binary
69+
queue.task_done()
70+
continue
71+
72+
output_path = os.path.join(options.symbols_dir, module_line.group(2),
73+
module_line.group(1))
74+
mkdir_p(output_path)
75+
symbol_file = "%s.sym" % module_line.group(2)
76+
f = open(os.path.join(output_path, symbol_file), 'w')
77+
f.write(syms)
78+
f.close()
79+
80+
queue.task_done()
81+
82+
for binary in binaries:
83+
queue.put(binary)
84+
85+
for _ in range(options.jobs):
86+
t = threading.Thread(target=_Worker)
87+
t.daemon = True
88+
t.start()
89+
90+
queue.join()
91+
92+
93+
def main():
94+
parser = optparse.OptionParser()
95+
parser.add_option('', '--symbols-dir', default='',
96+
help='The directory where to write the symbols file.')
97+
parser.add_option('', '--clear', default=False, action='store_true',
98+
help='Clear the symbols directory before writing new '
99+
'symbols.')
100+
parser.add_option('-j', '--jobs', default=CONCURRENT_TASKS, action='store',
101+
type='int', help='Number of parallel tasks to run.')
102+
parser.add_option('-v', '--verbose', action='store_true',
103+
help='Print verbose status output.')
104+
105+
(options, directories) = parser.parse_args()
106+
107+
if not options.symbols_dir:
108+
print "Required option --symbols-dir missing."
109+
return 1
110+
111+
if options.clear:
112+
try:
113+
shutil.rmtree(options.symbols_dir)
114+
except:
115+
pass
116+
117+
pdbs = []
118+
for directory in directories:
119+
pdbs += glob.glob(os.path.join(directory, '*.pdb'))
120+
121+
GenerateSymbols(options, pdbs)
122+
123+
return 0
124+
125+
126+
if '__main__' == __name__:
127+
sys.exit(main())

vendor/breakpad

0 commit comments

Comments
 (0)