Skip to content

Commit

Permalink
Experimental JavaScript tracing support
Browse files Browse the repository at this point in the history
https://bugs.chromium.org/p/v8/issues/detail?id=11043 tracks JavaScript
ETW instrumentation in Chromium. This attempts to add support for
recording that information.
  • Loading branch information
randomascii committed Mar 30, 2021
1 parent 1fd1327 commit 7e4bca1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions UIforETW/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
#define IDC_CHECK3 1035
#define IDC_CHECKFORNEWVERSIONS 1035
#define IDC_TRACESIZE 1036
#define IDC_CHECKFORNEWVERSIONS2 1036
#define IDC_TRACEJAVASCRIPT 1036
#define IDC_SELECT_PERF_COUNTERS 1037
#define IDC_CHECK4 1038
#define IDC_USE_OTHER_KERNEL_LOGGER 1038
Expand Down
10 changes: 10 additions & 0 deletions UIforETW/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void CSettings::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_HEAPSTACKS, btHeapStacks_);
DDX_Control(pDX, IDC_VIRTUALALLOCSTACKS, btVirtualAllocStacks_);
DDX_Control(pDX, IDC_CHECKFORNEWVERSIONS, btVersionChecks_);
DDX_Control(pDX, IDC_TRACEJAVASCRIPT, btTraceJavaScript_);
DDX_Control(pDX, IDC_CHROME_CATEGORIES, btChromeCategories_);
DDX_Control(pDX, IDC_IDENTIFY_CHROME_CPU, btIdentifyChromeProcessesCPU_);
DDX_Control(pDX, IDC_BACKGROUND_MONITORING, btBackgroundMonitoring_);
Expand All @@ -127,6 +128,7 @@ BEGIN_MESSAGE_MAP(CSettings, CDialog)
ON_BN_CLICKED(IDC_IDENTIFY_CHROME_CPU, &CSettings::OnBnClickedIdentifyChromeCpu)
ON_BN_CLICKED(IDC_BACKGROUND_MONITORING, &CSettings::OnBnClickedBackgroundMonitoring)
ON_BN_CLICKED(IDC_RECORD_TRACE_COMMAND, &CSettings::OnBnClickedRecordTraceCommand)
ON_BN_CLICKED(IDC_TRACEJAVASCRIPT, &CSettings::OnBnClickedTracejavascript)
END_MESSAGE_MAP()

BOOL CSettings::OnInitDialog()
Expand All @@ -144,6 +146,7 @@ BOOL CSettings::OnInitDialog()
CheckDlgButton(IDC_VIRTUALALLOCSTACKS, bVirtualAllocStacks_);
CheckDlgButton(IDC_CHECKFORNEWVERSIONS, bVersionChecks_);
CheckDlgButton(IDC_RECORD_TRACE_COMMAND, bRecordTraceCommand_);
CheckDlgButton(IDC_TRACEJAVASCRIPT, bTraceJavaScript_);

btIdentifyChromeProcessesCPU_.EnableWindow(bChromeDeveloper_);
if (IsWindows8Point1OrGreater())
Expand Down Expand Up @@ -220,6 +223,7 @@ BOOL CSettings::OnInitDialog()
toolTip_.AddTool(&btVirtualAllocStacks_, L"Check this to record call stacks on VirtualAlloc on all "
L"traces instead of just heap traces.");
toolTip_.AddTool(&btVersionChecks_, L"Check this to have UIforETW check for new versions at startup.");
toolTip_.AddTool(&btTraceJavaScript_, L"Check this to have UIforETW trace the IE/Chrome JavaScript provider.");
toolTip_.AddTool(&btChromeCategories_, L"Check the chrome tracing categories that you want Chrome "
L"to emit ETW events for. This requires running Chrome version 46 or later, and "
L"using chrome://flags/ to \"Enable exporting of tracing events to ETW\" - search for "
Expand Down Expand Up @@ -436,3 +440,9 @@ void CSettings::OnBnClickedRecordTraceCommand()
{
bRecordTraceCommand_ = !bRecordTraceCommand_;
}


void CSettings::OnBnClickedTracejavascript()
{
bTraceJavaScript_ = !bTraceJavaScript_;
}
3 changes: 3 additions & 0 deletions UIforETW/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class CSettings : public CDialog
bool bVirtualAllocStacks_ = false;
bool bVersionChecks_ = false;
bool bRecordTraceCommand_ = false;
bool bTraceJavaScript_ = false;
uint64_t chromeKeywords_ = 0;

protected:
Expand All @@ -73,6 +74,7 @@ class CSettings : public CDialog
CButton btHeapStacks_;
CButton btVirtualAllocStacks_;
CButton btVersionChecks_;
CButton btTraceJavaScript_;
CCheckListBox btChromeCategories_;

CToolTipCtrl toolTip_;
Expand Down Expand Up @@ -106,4 +108,5 @@ class CSettings : public CDialog
CSettings(const CSettings&) = delete;
CSettings(const CSettings&&) = delete;
afx_msg void OnBnClickedRecordTraceCommand();
afx_msg void OnBnClickedTracejavascript();
};
3 changes: 2 additions & 1 deletion UIforETW/Support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void CUIforETWDlg::TransferSettings(bool saving)
{ L"HeapStacks", &bHeapStacks_ },
{ L"VirtualAllocStacks", &bVirtualAllocStacks_ },
{ L"VersionChecks", &bVersionChecks_ },
{ L"RecordTraceCommand", &bRecordTraceCommand_},
{ L"RecordTraceCommand", &bRecordTraceCommand_ },
{ L"TraceJavaScript", &bTraceJavaScript_ },
};

for (auto& m : bools)
Expand Down
1 change: 1 addition & 0 deletions UIforETW/UIforETW.rc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ BEGIN
CONTROL "&VirtualAlloc stacks always",IDC_VIRTUALALLOCSTACKS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,103,173,97,10
CONTROL "Check for new versions",IDC_CHECKFORNEWVERSIONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,103,186,105,10
CONTROL "Trace &JavaScript",IDC_TRACEJAVASCRIPT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,103,199,105,10
CONTROL "Chrome tracing cate&gories:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,245,7,131,8
LISTBOX IDC_CHROME_CATEGORIES,245,18,149,174,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,286,195,50,14
Expand Down
6 changes: 6 additions & 0 deletions UIforETW/UIforETWDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,10 @@ void CUIforETWDlg::OnBnClickedStarttracing()
if (IsWindowsVistaOrLesser())
userProviders = L"Microsoft-Windows-LUA"; // Because Microsoft-Windows-Win32k doesn't work on Vista.
userProviders += L"+Multi-MAIN+Multi-FrameRate+Multi-Input+Multi-Worker";
// Recommended IE/Chromium JavaScript tracing settings per https://bugs.chromium.org/p/v8/issues/detail?id=11043#c15
// Note that currently Chromium must be built with v8_enable_system_instrumentation = true.
if (bTraceJavaScript_)
userProviders += L"+Microsoft-JScript:0x3";
// Suggested in https://github.com/google/UIforETW/issues/80. The data shows up in WPA in
// Memory-> Virtual Memory Snapshots. On windows 8.1 and above this makes the working set
// scanning in UIforETW unnecessary.
Expand Down Expand Up @@ -1993,6 +1997,7 @@ void CUIforETWDlg::OnBnClickedSettings()
dlgSettings.bVirtualAllocStacks_ = bVirtualAllocStacks_;
dlgSettings.bVersionChecks_ = bVersionChecks_;
dlgSettings.bRecordTraceCommand_ = bRecordTraceCommand_;
dlgSettings.bTraceJavaScript_ = bTraceJavaScript_;
dlgSettings.chromeKeywords_ = chromeKeywords_;
if (dlgSettings.DoModal() == IDOK)
{
Expand Down Expand Up @@ -2035,6 +2040,7 @@ void CUIforETWDlg::OnBnClickedSettings()
bVirtualAllocStacks_ = dlgSettings.bVirtualAllocStacks_;
bVersionChecks_ = dlgSettings.bVersionChecks_;
bRecordTraceCommand_ = dlgSettings.bRecordTraceCommand_;
bTraceJavaScript_ = dlgSettings.bTraceJavaScript_;
chromeKeywords_ = dlgSettings.chromeKeywords_;
}
}
Expand Down
1 change: 1 addition & 0 deletions UIforETW/UIforETWDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ class CUIforETWDlg : public CDialog
bool bBackgroundMonitoring_ = true;
bool bChromeDeveloper_ = false;
bool bRecordTraceCommand_ = false; // Should the trace command be put in the .txt file?
bool bTraceJavaScript_ = false; // Should we trace IE/Chrome JavaScript?
bool bIdentifyChromeProcessesCPU_ = false;
bool bAutoViewTraces_ = false;
bool bRecordPreTrace_ = false;
Expand Down

0 comments on commit 7e4bca1

Please sign in to comment.