OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Copyright (c) 2008 The Chromium Authors. All rights reserved. | |
4 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 4 # found in the LICENSE file. |
6 | 5 |
7 """Usage: <win-path-to-pdb.pdb> | 6 """Usage: <win-path-to-pdb.pdb> |
8 This tool will take a PDB on the command line, extract the source files that | 7 This tool will take a PDB on the command line, extract the source files that |
9 were used in building the PDB, query SVN for which repository and revision | 8 were used in building the PDB, query SVN for which repository and revision |
10 these files are at, and then finally write this information back into the PDB | 9 these files are at, and then finally write this information back into the PDB |
11 in a format that the debugging tools understand. This allows for automatic | 10 in a format that the debugging tools understand. This allows for automatic |
12 source debugging, as all of the information is contained in the PDB, and the | 11 source debugging, as all of the information is contained in the PDB, and the |
13 debugger can go out and fetch the source files via SVN. | 12 debugger can go out and fetch the source files via SVN. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 # Hack up into a dictionary of the fields printed by svn info. | 110 # Hack up into a dictionary of the fields printed by svn info. |
112 vals = dict((y.split(': ', 2) for y in info.split('\r\n') if y)) | 111 vals = dict((y.split(': ', 2) for y in info.split('\r\n') if y)) |
113 | 112 |
114 root = vals['Repository Root'] | 113 root = vals['Repository Root'] |
115 if not vals['URL'].startswith(root): | 114 if not vals['URL'].startswith(root): |
116 raise "URL is not inside of the repository root?!?" | 115 raise "URL is not inside of the repository root?!?" |
117 path = vals['URL'][len(root):] | 116 path = vals['URL'][len(root):] |
118 rev = int(vals['Revision']) | 117 rev = int(vals['Revision']) |
119 | 118 |
120 return [root, path, rev] | 119 return [root, path, rev] |
121 | 120 |
Alexander Potapenko
2011/11/28 10:29:35
Blank lines
| |
122 def UpdatePDB(pdb_filename, verbose=False): | 121 def UpdatePDB(pdb_filename, verbose=False): |
123 """Update a pdb file with source information.""" | 122 """Update a pdb file with source information.""" |
124 dir_blacklist = { } | 123 dir_blacklist = { } |
125 # TODO(deanm) look into "compressing" our output, by making use of vars | 124 # TODO(deanm) look into "compressing" our output, by making use of vars |
126 # and other things, so we don't need to duplicate the repo path and revs. | 125 # and other things, so we don't need to duplicate the repo path and revs. |
127 lines = [ | 126 lines = [ |
128 'SRCSRV: ini ------------------------------------------------', | 127 'SRCSRV: ini ------------------------------------------------', |
129 'VERSION=1', | 128 'VERSION=1', |
130 'INDEXVERSION=2', | 129 'INDEXVERSION=2', |
131 'VERCTRL=Subversion', | 130 'VERCTRL=Subversion', |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 root = REPO_MAP[root] | 182 root = REPO_MAP[root] |
184 | 183 |
185 lines.append('%s*%s*%s*%s' % (filename, root, path, rev)) | 184 lines.append('%s*%s*%s*%s' % (filename, root, path, rev)) |
186 if verbose: | 185 if verbose: |
187 print " indexed file." | 186 print " indexed file." |
188 | 187 |
189 lines.append('SRCSRV: end ------------------------------------------------') | 188 lines.append('SRCSRV: end ------------------------------------------------') |
190 | 189 |
191 WriteSourceStream(pdb_filename, '\r\n'.join(lines)) | 190 WriteSourceStream(pdb_filename, '\r\n'.join(lines)) |
192 | 191 |
193 if __name__ == '__main__': | 192 |
193 def main(): | |
194 if len(sys.argv) < 2 or len(sys.argv) > 3: | 194 if len(sys.argv) < 2 or len(sys.argv) > 3: |
195 print "usage: file.pdb [-v]" | 195 print "usage: file.pdb [-v]" |
196 sys.exit(1) | 196 return 1 |
197 | 197 |
198 verbose = False | 198 verbose = False |
199 if len(sys.argv) == 3: | 199 if len(sys.argv) == 3: |
200 verbose = (sys.argv[2] == '-v') | 200 verbose = (sys.argv[2] == '-v') |
201 | 201 |
202 UpdatePDB(sys.argv[1], verbose=verbose) | 202 UpdatePDB(sys.argv[1], verbose=verbose) |
203 return 0 | |
204 | |
205 | |
206 if __name__ == '__main__': | |
207 sys.exit(main()) | |
OLD | NEW |