113 LPCGUID , ULONG is_enabled, UCHAR level,
114 ULONGLONG match_any_keyword, ULONGLONG match_all_keyword,
115 PEVENT_FILTER_DESCRIPTOR filter_data,
PVOID ) {
116 ETWTRACEDBG <<
"ETWEnableCallback called with is_enabled==" << is_enabled
119 bool is_etw_enabled_now =
131 if (!is_etw_enabled_now) {
139 DCHECK(is_etw_enabled_now);
143 if (!
v8_flags.enable_etw_stack_walking &&
144 (!filter_data || filter_data->Type != EVENT_FILTER_TYPE_SCHEMATIZED)) {
148 if (
v8_flags.enable_etw_stack_walking &&
149 (!filter_data || filter_data->Type != EVENT_FILTER_TYPE_SCHEMATIZED)) {
151 ETWTRACEDBG <<
"Enabling without filter" << std::endl;
158 if (!
v8_flags.enable_etw_by_custom_filter_only)
return;
163 if (filter_data->Size <=
sizeof(EVENT_FILTER_DESCRIPTOR)) {
167 EVENT_FILTER_HEADER* filter_event_header =
168 reinterpret_cast<EVENT_FILTER_HEADER*
>(filter_data->Ptr);
169 if (filter_event_header->Size <
sizeof(EVENT_FILTER_HEADER)) {
173 const uint8_t* payload_start =
174 reinterpret_cast<uint8_t*
>(filter_event_header) +
175 sizeof(EVENT_FILTER_HEADER);
176 const size_t payload_size =
177 filter_event_header->Size -
sizeof(EVENT_FILTER_HEADER);
178 etw_filter->assign(payload_start, payload_start + payload_size);
181 ETWTRACEDBG <<
"Enabling with filter data" << std::endl;
183 reinterpret_cast<const uint8_t*
>(etw_filter->data()), etw_filter->size(),
210 if (!isolate->IsETWTracingEnabled())
return;
221 uint32_t script_line = -1;
222 uint32_t script_column = -1;
225 if (!sfi.
is_null() && IsScript(sfi->script())) {
229 script_id = script->id();
231 std::wstring wstr_name(0,
L'\0');
233 if (IsString(script_name)) {
235 wstr_name.resize(v8str_name->length());
237 uint16_t* wstr_data =
const_cast<uint16_t*
>(
238 reinterpret_cast<const uint16_t*
>(wstr_name.data()));
242 if (isolate->ETWIsInRundown()) {
243 constexpr static auto source_dcstart_event_meta =
245 constexpr static auto source_dcstart_event_fields =
247 Field(
"ScriptContextID", TlgInPOINTER),
248 Field(
"SourceFlags", TlgInUINT32),
249 Field(
"Url", TlgInUNICODESTRING));
251 &source_dcstart_event_fields, (uint64_t)script_id,
256 constexpr static auto source_load_event_meta =
258 constexpr static auto source_load_event_fields =
260 Field(
"ScriptContextID", TlgInPOINTER),
261 Field(
"SourceFlags", TlgInUINT32),
262 Field(
"Url", TlgInUNICODESTRING));
264 &source_load_event_fields, (uint64_t)script_id,
272 script->GetPositionInfo(sfi->StartPosition(), &info);
273 script_line = info.line + 1;
274 script_column = info.column + 1;
280 if (code && code.value()->is_builtin()) {
281 bool skip_emitting_builtin =
true;
287 if (code.value()->has_instruction_stream()) {
288 skip_emitting_builtin =
false;
294 code.value()->is_builtin(),
295 code.value()->builtin_id() == Builtin::kInterpreterEntryTrampoline &&
296 isolate->interpreted_frames_native_stack());
298 DCHECK(code.value()->is_builtin());
304 CodeRange* code_range = isolate->isolate_group()->GetCodeRange();
306 skip_emitting_builtin =
false;
310 if (skip_emitting_builtin) {
315 if (isolate->ETWIsInRundown()) {
316 constexpr static auto method_dcstart_event_meta =
318 constexpr static auto method_dcstart_event_fields =
EventFields(
319 "MethodDCStart",
Field(
"ScriptContextID", TlgInPOINTER),
320 Field(
"MethodStartAddress", TlgInPOINTER),
321 Field(
"MethodSize", TlgInUINT64),
Field(
"MethodID", TlgInUINT32),
322 Field(
"MethodFlags", TlgInUINT16),
323 Field(
"MethodAddressRangeID", TlgInUINT16),
324 Field(
"SourceID", TlgInUINT64),
Field(
"Line", TlgInUINT32),
325 Field(
"Column", TlgInUINT32),
Field(
"MethodName", TlgInUNICODESTRING));
327 &method_dcstart_event_fields, script_context,
332 (uint64_t)script_id, script_line, script_column, method_name);
334 constexpr static auto method_load_event_meta =
336 constexpr static auto method_load_event_fields =
EventFields(
337 "MethodLoad",
Field(
"ScriptContextID", TlgInPOINTER),
338 Field(
"MethodStartAddress", TlgInPOINTER),
339 Field(
"MethodSize", TlgInUINT64),
Field(
"MethodID", TlgInUINT32),
340 Field(
"MethodFlags", TlgInUINT16),
341 Field(
"MethodAddressRangeID", TlgInUINT16),
342 Field(
"SourceID", TlgInUINT64),
Field(
"Line", TlgInUINT32),
343 Field(
"Column", TlgInUINT32),
Field(
"MethodName", TlgInUNICODESTRING));
345 &method_load_event_fields, script_context, event->
code_start,
350 (uint64_t)script_id, script_line, script_column, method_name);
void WINAPI V8_EXPORT_PRIVATE ETWEnableCallback(LPCGUID, ULONG is_enabled, UCHAR level, ULONGLONG match_any_keyword, ULONGLONG match_all_keyword, PEVENT_FILTER_DESCRIPTOR filter_data, PVOID)