Skip to content

Commit 305dd56

Browse files
cjihrigMylesBorins
authored andcommittedJan 9, 2018
test: add test for postmortem metadata validation
This commit adds a test to validate postmortem debugging metadata. When this test runs, it can check for the presence of metadata constants used by tools such as llnode and mdb and report if any have accidentally been removed. PR-URL: #17685 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent c5c4a53 commit 305dd56

File tree

2 files changed

+183
-0
lines changed

2 files changed

+183
-0
lines changed
 

‎test/parallel/parallel.status

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ prefix parallel
55
# sample-test : PASS,FLAKY
66

77
[true] # This section applies to all platforms
8+
# Postmortem debugging data is prone to accidental removal during V8 updates.
9+
test-postmortem-metadata: PASS,FLAKY
810

911
[$system==win32]
1012

+181
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
'use strict';
2+
3+
// This test verifies that expected postmortem debugging metadata is present
4+
// in the Node.js binary. These constants are used by tools such as llnode and
5+
// mdb_v8, so this test ensures that they don't vanish between V8 updates.
6+
7+
const common = require('../common');
8+
const assert = require('assert');
9+
const { spawnSync } = require('child_process');
10+
const args = [process.execPath];
11+
12+
if (common.isAIX)
13+
args.unshift('-Xany', '-B');
14+
15+
const nm = spawnSync('nm', args);
16+
17+
if (nm.error && nm.error.errno === 'ENOENT')
18+
common.skip('nm not found on system');
19+
20+
const symbolRe = /\s_?(v8dbg_.+)$/;
21+
const symbols = nm.stdout.toString().split('\n').reduce((filtered, line) => {
22+
const match = line.match(symbolRe);
23+
const symbol = match && match[1];
24+
25+
if (symbol)
26+
filtered.push(symbol);
27+
28+
return filtered;
29+
}, []);
30+
const missing = getExpectedSymbols().filter((symbol) => {
31+
return !symbols.includes(symbol);
32+
});
33+
34+
assert.strictEqual(missing.length, 0, `Missing constants: ${missing}`);
35+
36+
// This is only a function so that the long list of expected symbols can be
37+
// pushed to the bottom of the file for improved readability.
38+
function getExpectedSymbols() {
39+
return [
40+
'v8dbg_bit_field3_dictionary_map_shift',
41+
'v8dbg_bit_field3_number_of_own_descriptors_shift',
42+
'v8dbg_class_Code__instruction_size__int',
43+
'v8dbg_class_Code__instruction_start__uintptr_t',
44+
'v8dbg_class_ConsString__first__String',
45+
'v8dbg_class_ConsString__second__String',
46+
'v8dbg_class_FixedArray__data__uintptr_t',
47+
'v8dbg_class_FixedArrayBase__length__SMI',
48+
'v8dbg_class_FixedTypedArrayBase__base_pointer__Object',
49+
'v8dbg_class_FixedTypedArrayBase__external_pointer__Object',
50+
'v8dbg_class_HeapNumber__value__double',
51+
'v8dbg_class_HeapObject__map__Map',
52+
'v8dbg_class_JSArray__length__Object',
53+
'v8dbg_class_JSArrayBuffer__backing_store__Object',
54+
'v8dbg_class_JSArrayBuffer__byte_length__Object',
55+
'v8dbg_class_JSArrayBufferView__buffer__Object',
56+
'v8dbg_class_JSArrayBufferView__raw_byte_length__Object',
57+
'v8dbg_class_JSArrayBufferView__raw_byte_offset__Object',
58+
'v8dbg_class_JSDate__value__Object',
59+
'v8dbg_class_JSFunction__context__Context',
60+
'v8dbg_class_JSFunction__shared__SharedFunctionInfo',
61+
'v8dbg_class_JSObject__elements__Object',
62+
'v8dbg_class_JSObject__internal_fields__uintptr_t',
63+
'v8dbg_class_JSReceiver__raw_properties_or_hash__Object',
64+
'v8dbg_class_JSRegExp__source__Object',
65+
'v8dbg_class_Map__bit_field3__int',
66+
'v8dbg_class_Map__constructor_or_backpointer__Object',
67+
'v8dbg_class_Map__inobject_properties_or_constructor_function_index__int',
68+
'v8dbg_class_Map__instance_attributes__int',
69+
'v8dbg_class_Map__instance_descriptors__DescriptorArray',
70+
'v8dbg_class_Map__instance_size__int',
71+
'v8dbg_class_Oddball__kind_offset__int',
72+
'v8dbg_class_Script__line_ends__Object',
73+
'v8dbg_class_Script__line_offset__SMI',
74+
'v8dbg_class_Script__name__Object',
75+
'v8dbg_class_Script__source__Object',
76+
'v8dbg_class_SeqOneByteString__chars__char',
77+
'v8dbg_class_SeqTwoByteString__chars__char',
78+
'v8dbg_class_SharedFunctionInfo__code__Code',
79+
'v8dbg_class_SharedFunctionInfo__compiler_hints__int',
80+
'v8dbg_class_SharedFunctionInfo__end_position__int',
81+
'v8dbg_class_SharedFunctionInfo__function_identifier__Object',
82+
'v8dbg_class_SharedFunctionInfo__internal_formal_parameter_count__int',
83+
'v8dbg_class_SharedFunctionInfo__raw_name__Object',
84+
'v8dbg_class_SharedFunctionInfo__scope_info__ScopeInfo',
85+
'v8dbg_class_SharedFunctionInfo__script__Object',
86+
'v8dbg_class_SharedFunctionInfo__start_position_and_type__int',
87+
'v8dbg_class_SlicedString__offset__SMI',
88+
'v8dbg_class_SlicedString__parent__String',
89+
'v8dbg_class_String__length__SMI',
90+
'v8dbg_class_ThinString__actual__String',
91+
'v8dbg_context_idx_closure',
92+
'v8dbg_context_idx_prev',
93+
'v8dbg_context_min_slots',
94+
'v8dbg_frametype_ArgumentsAdaptorFrame',
95+
'v8dbg_frametype_ConstructEntryFrame',
96+
'v8dbg_frametype_ConstructFrame',
97+
'v8dbg_frametype_EntryFrame',
98+
'v8dbg_frametype_ExitFrame',
99+
'v8dbg_frametype_InternalFrame',
100+
'v8dbg_frametype_OptimizedFrame',
101+
'v8dbg_frametype_StubFrame',
102+
'v8dbg_jsarray_buffer_was_neutered_mask',
103+
'v8dbg_jsarray_buffer_was_neutered_shift',
104+
'v8dbg_namedictionary_prefix_start_index',
105+
'v8dbg_namedictionaryshape_entry_size',
106+
'v8dbg_namedictionaryshape_prefix_size',
107+
'v8dbg_off_fp_args',
108+
'v8dbg_off_fp_context',
109+
'v8dbg_off_fp_function',
110+
'v8dbg_prop_attributes_mask',
111+
'v8dbg_prop_attributes_shift',
112+
'v8dbg_prop_attributes_DONT_ENUM',
113+
'v8dbg_prop_attributes_DONT_ENUM',
114+
'v8dbg_prop_attributes_NONE',
115+
'v8dbg_prop_attributes_READ_ONLY',
116+
'v8dbg_prop_desc_details',
117+
'v8dbg_prop_desc_key',
118+
'v8dbg_prop_desc_size',
119+
'v8dbg_prop_desc_value',
120+
'v8dbg_prop_idx_first',
121+
'v8dbg_prop_index_mask',
122+
'v8dbg_prop_index_shift',
123+
'v8dbg_prop_kind_mask',
124+
'v8dbg_prop_kind_Accessor',
125+
'v8dbg_prop_kind_Data',
126+
'v8dbg_prop_location_mask',
127+
'v8dbg_prop_location_shift',
128+
'v8dbg_prop_location_Descriptor',
129+
'v8dbg_prop_location_Field',
130+
'v8dbg_prop_representation_double',
131+
'v8dbg_prop_representation_mask',
132+
'v8dbg_prop_representation_shift',
133+
'v8dbg_scopeinfo_idx_first_vars',
134+
'v8dbg_scopeinfo_idx_ncontextlocals',
135+
'v8dbg_scopeinfo_idx_nparams',
136+
'v8dbg_scopeinfo_idx_nstacklocals',
137+
'v8dbg_sharedfunctioninfo_start_position_mask',
138+
'v8dbg_sharedfunctioninfo_start_position_shift',
139+
'v8dbg_type_Code__CODE_TYPE',
140+
'v8dbg_type_FixedArray__FIXED_ARRAY_TYPE',
141+
'v8dbg_type_HeapNumber__HEAP_NUMBER_TYPE',
142+
'v8dbg_type_JSArray__JS_ARRAY_TYPE',
143+
'v8dbg_type_JSArrayBuffer__JS_ARRAY_BUFFER_TYPE',
144+
'v8dbg_type_JSDate__JS_DATE_TYPE',
145+
'v8dbg_type_JSFunction__JS_FUNCTION_TYPE',
146+
'v8dbg_type_JSGlobalObject__JS_GLOBAL_OBJECT_TYPE',
147+
'v8dbg_type_JSGlobalProxy__JS_GLOBAL_PROXY_TYPE',
148+
'v8dbg_type_JSObject__JS_OBJECT_TYPE',
149+
'v8dbg_type_JSRegExp__JS_REGEXP_TYPE',
150+
'v8dbg_type_JSTypedArray__JS_TYPED_ARRAY_TYPE',
151+
'v8dbg_type_Map__MAP_TYPE',
152+
'v8dbg_type_Oddball__ODDBALL_TYPE',
153+
'v8dbg_type_Script__SCRIPT_TYPE',
154+
'v8dbg_type_SharedFunctionInfo__SHARED_FUNCTION_INFO_TYPE',
155+
'v8dbg_APIObjectType',
156+
'v8dbg_ConsStringTag',
157+
'v8dbg_ExternalStringTag',
158+
'v8dbg_FirstNonstringType',
159+
'v8dbg_HeapObjectTag',
160+
'v8dbg_HeapObjectTagMask',
161+
'v8dbg_OddballException',
162+
'v8dbg_OddballFalse',
163+
'v8dbg_OddballNull',
164+
'v8dbg_OddballTheHole',
165+
'v8dbg_OddballTrue',
166+
'v8dbg_OddballUndefined',
167+
'v8dbg_OddballUninitialized',
168+
'v8dbg_OneByteStringTag',
169+
'v8dbg_PointerSizeLog2',
170+
'v8dbg_SeqStringTag',
171+
'v8dbg_SlicedStringTag',
172+
'v8dbg_SmiShiftSize',
173+
'v8dbg_SmiTag',
174+
'v8dbg_SmiTagMask',
175+
'v8dbg_SpecialAPIObjectType',
176+
'v8dbg_StringEncodingMask',
177+
'v8dbg_StringRepresentationMask',
178+
'v8dbg_ThinStringTag',
179+
'v8dbg_TwoByteStringTag',
180+
];
181+
}

0 commit comments

Comments
 (0)
Please sign in to comment.