Skip to content

Commit 66251fb

Browse files
mmarchiniCommit Bot
authored andcommitted
[postmortem] generate more comprehensive metadata
Improve postmortem metadata generated by gen-postmortem-metadata by also including weak and synchronous accessors, as well as CHECKED and CHECKED2 variants of all accessors currently considered by gen-postmortem-metadata. Also improve type collection by parsing TORQUE_INSTANCE_CHECKERS_SINGLE_FULLY_DEFINED, as we were missing several types with the previous heuristic (like StackTraceFrame, PromiseReaction, and many others). This will include 96 new v8dbg constants which can be used by debuggers like llnode. [email protected], [email protected], [email protected] Change-Id: Ia9bea21eec38b92d255c3636c6a284eb27e9ed9b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2056126 Reviewed-by: Tobias Tebbi <[email protected]> Commit-Queue: Tobias Tebbi <[email protected]> Cr-Commit-Position: refs/heads/master@{#66551}
1 parent 069970e commit 66251fb

1 file changed

Lines changed: 43 additions & 16 deletions

File tree

tools/gen-postmortem-metadata.py

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,11 @@ def load_objects_from_file(objfilename, checktypes):
380380
objfile = io.open(objfilename, 'r', encoding='utf-8');
381381
in_insttype = False;
382382
in_torque_insttype = False
383+
in_torque_fulldef = False
383384

384385
typestr = '';
385386
torque_typestr = ''
387+
torque_fulldefstr = ''
386388
uncommented_file = ''
387389

388390
#
@@ -400,6 +402,10 @@ def load_objects_from_file(objfilename, checktypes):
400402
in_torque_insttype = True
401403
continue
402404

405+
if (line.startswith('#define TORQUE_INSTANCE_CHECKERS_SINGLE_FULLY_DEFINED')):
406+
in_torque_fulldef = True
407+
continue
408+
403409
if (in_insttype and line.startswith('};')):
404410
in_insttype = False;
405411
continue;
@@ -408,6 +414,10 @@ def load_objects_from_file(objfilename, checktypes):
408414
in_torque_insttype = False
409415
continue
410416

417+
if (in_torque_fulldef and (not line or line.isspace())):
418+
in_torque_fulldef = False
419+
continue
420+
411421
line = re.sub('//.*', '', line.strip());
412422

413423
if (in_insttype):
@@ -418,6 +428,10 @@ def load_objects_from_file(objfilename, checktypes):
418428
torque_typestr += line
419429
continue
420430

431+
if (in_torque_fulldef):
432+
torque_fulldefstr += line
433+
continue
434+
421435
uncommented_file += '\n' + line
422436

423437
for match in re.finditer(r'\nclass(?:\s+V8_EXPORT(?:_PRIVATE)?)?'
@@ -448,7 +462,18 @@ def load_objects_from_file(objfilename, checktypes):
448462
entries = torque_typestr.split('\\')
449463
for entry in entries:
450464
types[re.sub(r' *V\(|\) *', '', entry)] = True
451-
465+
entries = torque_fulldefstr.split('\\')
466+
for entry in entries:
467+
entry = entry.strip()
468+
if not entry:
469+
continue
470+
idx = entry.find('(');
471+
rest = entry[idx + 1: len(entry) - 1];
472+
args = re.split('\s*,\s*', rest);
473+
typename = args[0]
474+
typeconst = args[1]
475+
types[typeconst] = True
476+
typeclasses[typeconst] = typename
452477
#
453478
# Infer class names for each type based on a systematic transformation.
454479
# For example, "JS_FUNCTION_TYPE" becomes "JSFunction". We find the
@@ -551,25 +576,24 @@ def parse_field(call):
551576

552577
consts = [];
553578

554-
if (kind == 'ACCESSORS' or kind == 'ACCESSORS2' or
555-
kind == 'ACCESSORS_GCSAFE'):
556-
klass = args[0];
557-
field = args[1];
579+
klass = args[0];
580+
field = args[1];
581+
dtype = None
582+
offset = None
583+
if kind.startswith('WEAK_ACCESSORS'):
584+
dtype = 'weak'
585+
offset = args[2];
586+
elif not (kind.startswith('SMI_ACCESSORS') or kind.startswith('ACCESSORS_TO_SMI')):
558587
dtype = args[2].replace('<', '_').replace('>', '_')
559588
offset = args[3];
589+
else:
590+
offset = args[2];
591+
dtype = 'SMI'
560592

561-
return ({
562-
'name': 'class_%s__%s__%s' % (klass, field, dtype),
563-
'value': '%s::%s' % (klass, offset)
564-
});
565-
566-
assert(kind == 'SMI_ACCESSORS' or kind == 'ACCESSORS_TO_SMI');
567-
klass = args[0];
568-
field = args[1];
569-
offset = args[2];
570593

594+
assert(offset is not None and dtype is not None);
571595
return ({
572-
'name': 'class_%s__%s__%s' % (klass, field, 'SMI'),
596+
'name': 'class_%s__%s__%s' % (klass, field, dtype),
573597
'value': '%s::%s' % (klass, offset)
574598
});
575599

@@ -596,7 +620,10 @@ def load_fields_from_file(filename):
596620
# call parse_field() to pick apart the invocation.
597621
#
598622
prefixes = [ 'ACCESSORS', 'ACCESSORS2', 'ACCESSORS_GCSAFE',
599-
'SMI_ACCESSORS', 'ACCESSORS_TO_SMI' ];
623+
'SMI_ACCESSORS', 'ACCESSORS_TO_SMI',
624+
'SYNCHRONIZED_ACCESSORS', 'WEAK_ACCESSORS' ];
625+
prefixes += ([ prefix + "_CHECKED" for prefix in prefixes ] +
626+
[ prefix + "_CHECKED2" for prefix in prefixes ])
600627
current = '';
601628
opens = 0;
602629

0 commit comments

Comments
 (0)