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

Side by Side Diff: tools/gen-postmortem-metadata.py

Issue 1435643002: Make gen-postmortem-metadata.py more reliable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 | « AUTHORS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # 3 #
4 # Copyright 2012 the V8 project authors. All rights reserved. 4 # Copyright 2012 the V8 project authors. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 220
221 #undef FRAME_CONST 221 #undef FRAME_CONST
222 222
223 ''' % sys.argv[0]; 223 ''' % sys.argv[0];
224 224
225 footer = ''' 225 footer = '''
226 } 226 }
227 ''' 227 '''
228 228
229 # 229 #
230 # Get the base class
231 #
232 def get_base_class(klass):
233 if (klass == 'Object'):
234 return klass;
235
236 if (not (klass in klasses)):
237 return None;
238
239 k = klasses[klass];
240
241 return get_base_class(k['parent']);
242
243 #
230 # Loads class hierarchy and type information from "objects.h". 244 # Loads class hierarchy and type information from "objects.h".
231 # 245 #
232 def load_objects(): 246 def load_objects():
233 objfilename = sys.argv[2]; 247 objfilename = sys.argv[2];
234 objfile = open(objfilename, 'r'); 248 objfile = open(objfilename, 'r');
235 in_insttype = False; 249 in_insttype = False;
236 250
237 typestr = ''; 251 typestr = '';
238 252
239 # 253 #
(...skipping 17 matching lines...) Expand all
257 if (in_insttype and line.startswith('};')): 271 if (in_insttype and line.startswith('};')):
258 in_insttype = False; 272 in_insttype = False;
259 continue; 273 continue;
260 274
261 line = re.sub('//.*', '', line.rstrip().lstrip()); 275 line = re.sub('//.*', '', line.rstrip().lstrip());
262 276
263 if (in_insttype): 277 if (in_insttype):
264 typestr += line; 278 typestr += line;
265 continue; 279 continue;
266 280
267 match = re.match('class (\w[^\s:]*)(: public (\w[^\s{]*))?\s*{', 281 match = re.match('class (\w[^:]*)(: public (\w[^{]*))?\s*{\s*',
268 line); 282 line);
269 283
270 if (match): 284 if (match):
271 klass = match.group(1); 285 klass = match.group(1).rstrip().lstrip();
272 pklass = match.group(3); 286 pklass = match.group(3);
287 if (pklass):
288 pklass = pklass.rstrip().lstrip();
273 klasses[klass] = { 'parent': pklass }; 289 klasses[klass] = { 'parent': pklass };
274 290
275 # 291 #
276 # Process the instance type declaration. 292 # Process the instance type declaration.
277 # 293 #
278 entries = typestr.split(','); 294 entries = typestr.split(',');
279 for entry in entries: 295 for entry in entries:
280 types[re.sub('\s*=.*', '', entry).lstrip()] = True; 296 types[re.sub('\s*=.*', '', entry).lstrip()] = True;
281 297
282 # 298 #
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 }); 529 });
514 530
515 emit_set(out, consts); 531 emit_set(out, consts);
516 532
517 out.write('/* class hierarchy information */\n'); 533 out.write('/* class hierarchy information */\n');
518 consts = []; 534 consts = [];
519 keys = klasses.keys(); 535 keys = klasses.keys();
520 keys.sort(); 536 keys.sort();
521 for klassname in keys: 537 for klassname in keys:
522 pklass = klasses[klassname]['parent']; 538 pklass = klasses[klassname]['parent'];
539 bklass = get_base_class(klassname);
540 if (bklass != 'Object'):
541 continue;
523 if (pklass == None): 542 if (pklass == None):
524 continue; 543 continue;
525 544
526 consts.append({ 545 consts.append({
527 'name': 'parent_%s__%s' % (klassname, pklass), 546 'name': 'parent_%s__%s' % (klassname, pklass),
528 'value': 0 547 'value': 0
529 }); 548 });
530 549
531 emit_set(out, consts); 550 emit_set(out, consts);
532 551
533 out.write('/* field information */\n'); 552 out.write('/* field information */\n');
534 emit_set(out, fields); 553 emit_set(out, fields);
535 554
536 out.write(footer); 555 out.write(footer);
537 556
538 if (len(sys.argv) < 4): 557 if (len(sys.argv) < 4):
539 print('usage: %s output.cc objects.h objects-inl.h' % sys.argv[0]); 558 print('usage: %s output.cc objects.h objects-inl.h' % sys.argv[0]);
540 sys.exit(2); 559 sys.exit(2);
541 560
542 load_objects(); 561 load_objects();
543 load_fields(); 562 load_fields();
544 emit_config(); 563 emit_config();
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698