forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-postmortem-metadata.js
204 lines (189 loc) · 7.62 KB
/
test-postmortem-metadata.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
'use strict';
// This test verifies that expected postmortem debugging metadata is present
// in the Node.js binary. These constants are used by tools such as llnode and
// mdb_v8, so this test ensures that they don't vanish between V8 updates.
const common = require('../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const { getSharedLibPath } = require('../common/shared-lib-util.js');
// For shared lib case, check shared lib instead
const args = [
process.config.variables.node_shared ?
getSharedLibPath() : process.execPath
];
if (common.isAIX)
args.unshift('-Xany', '-B');
if (common.isOpenBSD)
common.skip('no v8 debug symbols on OpenBSD');
const nm = spawnSync('nm', args, { maxBuffer: Infinity });
if (nm.error && nm.error.errno === 'ENOENT')
common.skip('nm not found on system');
const stderr = nm.stderr.toString();
if (stderr.length > 0) {
common.skip(`Failed to execute nm: ${stderr}`);
}
const symbolRe = /\s_?(v8dbg_.+)$/;
const symbols = nm.stdout.toString().split('\n').reduce((filtered, line) => {
const match = line.match(symbolRe);
const symbol = match && match[1];
if (symbol)
filtered.push(symbol);
return filtered;
}, []);
assert.notStrictEqual(symbols.length, 0, 'No postmortem metadata detected');
const missing = getExpectedSymbols().filter((symbol) => {
return !symbols.includes(symbol);
});
assert.strictEqual(missing.length, 0,
`Missing constants: \n${missing.join('\n')}`);
// This is only a function so that the long list of expected symbols can be
// pushed to the bottom of the file for improved readability.
function getExpectedSymbols() {
return [
// Disable the maximum line length for the remainder of the file since it
// should only consist of postmortem constants, and some of them can be
// relatively long.
/* eslint-disable max-len */
'v8dbg_class_DescriptorArray__header_size__uintptr_t',
'v8dbg_bit_field3_is_dictionary_map_shift',
'v8dbg_bit_field3_number_of_own_descriptors_shift',
'v8dbg_class_Code__instruction_size__int',
'v8dbg_class_Code__instruction_start__uintptr_t',
'v8dbg_class_ConsString__first_offset__int',
'v8dbg_class_ConsString__second_offset__int',
'v8dbg_class_FixedArray__data__uintptr_t',
'v8dbg_class_FixedArrayBase__length__SMI',
'v8dbg_class_JSTypedArray__base_pointer__Object',
'v8dbg_class_JSTypedArray__external_pointer__uintptr_t',
'v8dbg_class_HeapNumber__value__double',
'v8dbg_class_HeapObject__map__Map',
'v8dbg_class_JSArray__length__Object',
'v8dbg_class_JSArrayBuffer__backing_store__uintptr_t',
'v8dbg_class_JSArrayBuffer__byte_length__size_t',
'v8dbg_class_JSArrayBufferView__buffer__Object',
'v8dbg_class_JSArrayBufferView__byte_length__size_t',
'v8dbg_class_JSArrayBufferView__byte_offset__size_t',
'v8dbg_class_JSDate__value__Object',
'v8dbg_class_JSFunction__context__Context',
'v8dbg_class_JSFunction__shared__SharedFunctionInfo',
'v8dbg_class_JSObject__elements__Object',
'v8dbg_class_JSObject__internal_fields__uintptr_t',
'v8dbg_class_JSReceiver__raw_properties_or_hash__Object',
'v8dbg_class_JSRegExp__source__Object',
'v8dbg_class_Map__bit_field3__int',
'v8dbg_class_Map__constructor_or_backpointer__Object',
'v8dbg_class_Map__inobject_properties_start_or_constructor_function_index__char',
'v8dbg_class_Map__instance_type__uint16_t',
'v8dbg_class_Map__instance_descriptors_offset',
'v8dbg_class_Map__instance_size_in_words__char',
'v8dbg_class_Oddball__kind_offset__int',
'v8dbg_class_Script__line_ends__Object',
'v8dbg_class_Script__line_offset__SMI',
'v8dbg_class_Script__name__Object',
'v8dbg_class_Script__source__Object',
'v8dbg_class_SeqOneByteString__chars__char',
'v8dbg_class_SeqTwoByteString__chars__char',
'v8dbg_class_SharedFunctionInfo__function_data__Object',
'v8dbg_class_SharedFunctionInfo__flags__int',
'v8dbg_class_UncompiledData__end_position__int32_t',
'v8dbg_class_UncompiledData__inferred_name__String',
'v8dbg_class_SharedFunctionInfo__internal_formal_parameter_count__uint16_t',
'v8dbg_class_SharedFunctionInfo__name_or_scope_info__Object',
'v8dbg_class_SharedFunctionInfo__script_or_debug_info__HeapObject',
'v8dbg_class_UncompiledData__start_position__int32_t',
'v8dbg_class_SlicedString__offset_offset__int',
'v8dbg_class_SlicedString__parent__String',
'v8dbg_class_String__length__int32_t',
'v8dbg_class_ThinString__actual_offset__int',
'v8dbg_context_idx_scope_info',
'v8dbg_context_idx_prev',
'v8dbg_context_min_slots',
'v8dbg_frametype_ArgumentsAdaptorFrame',
'v8dbg_frametype_ConstructEntryFrame',
'v8dbg_frametype_ConstructFrame',
'v8dbg_frametype_EntryFrame',
'v8dbg_frametype_ExitFrame',
'v8dbg_frametype_InternalFrame',
'v8dbg_frametype_OptimizedFrame',
'v8dbg_frametype_StubFrame',
'v8dbg_jsarray_buffer_was_detached_mask',
'v8dbg_jsarray_buffer_was_detached_shift',
'v8dbg_namedictionary_prefix_start_index',
'v8dbg_namedictionaryshape_entry_size',
'v8dbg_namedictionaryshape_prefix_size',
'v8dbg_off_fp_args',
'v8dbg_off_fp_context',
'v8dbg_off_fp_function',
'v8dbg_prop_attributes_mask',
'v8dbg_prop_attributes_shift',
'v8dbg_prop_attributes_DONT_ENUM',
'v8dbg_prop_attributes_DONT_ENUM',
'v8dbg_prop_attributes_NONE',
'v8dbg_prop_attributes_READ_ONLY',
'v8dbg_prop_desc_details',
'v8dbg_prop_desc_key',
'v8dbg_prop_desc_size',
'v8dbg_prop_desc_value',
'v8dbg_prop_index_mask',
'v8dbg_prop_index_shift',
'v8dbg_prop_kind_mask',
'v8dbg_prop_kind_Accessor',
'v8dbg_prop_kind_Data',
'v8dbg_prop_location_mask',
'v8dbg_prop_location_shift',
'v8dbg_prop_location_Descriptor',
'v8dbg_prop_location_Field',
'v8dbg_prop_representation_double',
'v8dbg_prop_representation_mask',
'v8dbg_prop_representation_shift',
'v8dbg_scopeinfo_idx_first_vars',
'v8dbg_scopeinfo_idx_ncontextlocals',
'v8dbg_scopeinfo_idx_nparams',
'v8dbg_type_Code__CODE_TYPE',
'v8dbg_type_FixedArray__FIXED_ARRAY_TYPE',
'v8dbg_type_HeapNumber__HEAP_NUMBER_TYPE',
'v8dbg_type_JSArray__JS_ARRAY_TYPE',
'v8dbg_type_JSArrayBuffer__JS_ARRAY_BUFFER_TYPE',
'v8dbg_type_JSDate__JS_DATE_TYPE',
'v8dbg_type_JSFunction__JS_FUNCTION_TYPE',
'v8dbg_type_JSGlobalObject__JS_GLOBAL_OBJECT_TYPE',
'v8dbg_type_JSGlobalProxy__JS_GLOBAL_PROXY_TYPE',
'v8dbg_type_JSMessageObject__JS_MESSAGE_OBJECT_TYPE',
'v8dbg_type_JSObject__JS_OBJECT_TYPE',
'v8dbg_type_JSPromise__JS_PROMISE_TYPE',
'v8dbg_type_JSRegExp__JS_REG_EXP_TYPE',
'v8dbg_type_JSTypedArray__JS_TYPED_ARRAY_TYPE',
'v8dbg_type_Map__MAP_TYPE',
'v8dbg_type_Oddball__ODDBALL_TYPE',
'v8dbg_type_Script__SCRIPT_TYPE',
'v8dbg_type_SharedFunctionInfo__SHARED_FUNCTION_INFO_TYPE',
'v8dbg_APIObjectType',
'v8dbg_ConsStringTag',
'v8dbg_ExternalStringTag',
'v8dbg_FirstNonstringType',
'v8dbg_HeapObjectTag',
'v8dbg_HeapObjectTagMask',
'v8dbg_OddballException',
'v8dbg_OddballFalse',
'v8dbg_OddballNull',
'v8dbg_OddballTheHole',
'v8dbg_OddballTrue',
'v8dbg_OddballUndefined',
'v8dbg_OddballUninitialized',
'v8dbg_OneByteStringTag',
'v8dbg_SystemPointerSize',
'v8dbg_SystemPointerSizeLog2',
'v8dbg_TaggedSize',
'v8dbg_TaggedSizeLog2',
'v8dbg_SeqStringTag',
'v8dbg_SlicedStringTag',
'v8dbg_SmiShiftSize',
'v8dbg_SmiTag',
'v8dbg_SmiTagMask',
'v8dbg_SpecialAPIObjectType',
'v8dbg_StringEncodingMask',
'v8dbg_StringRepresentationMask',
'v8dbg_ThinStringTag',
'v8dbg_TwoByteStringTag',
];
}