Skip to content

Commit

Permalink
Add a check-box to control pre-trace recording
Browse files Browse the repository at this point in the history
Pre-traces are needed when tracing across a Chrome upgrade. So, I
initially enabled/disabled them based on the "Chrome developer" flag,
'cause that made for the simplest user experience. But, it turns out
that I hate the delay that they cause so I only want to enable them
when I know I need them. So now they have their own flag.
  • Loading branch information
randomascii committed Mar 28, 2017
1 parent b75199a commit cd47a9d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
2 changes: 2 additions & 0 deletions UIforETW/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
#define IDC_SELECT_PERF_COUNTERS 1037
#define IDC_CHECK4 1038
#define IDC_USE_OTHER_KERNEL_LOGGER 1038
#define IDC_USE_OTHER_KERNEL_LOGGER2 1039
#define IDC_RECORD_PRE_TRACE 1039
#define ID_TRACES_OPENTRACEINWPA 32771
#define ID_TRACES_DELETETRACE 32772
#define ID_TRACES_COMPRESSTRACE 32773
Expand Down
12 changes: 12 additions & 0 deletions UIforETW/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ void CSettings::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_USE_OTHER_KERNEL_LOGGER, btUseOtherKernelLogger_);
DDX_Control(pDX, IDC_CHROMEDEVELOPER, btChromeDeveloper_);
DDX_Control(pDX, IDC_AUTOVIEWTRACES, btAutoViewTraces_);
DDX_Control(pDX, IDC_RECORD_PRE_TRACE, btRecordPreTrace_);
DDX_Control(pDX, IDC_HEAPSTACKS, btHeapStacks_);
DDX_Control(pDX, IDC_VIRTUALALLOCSTACKS, btVirtualAllocStacks_);
DDX_Control(pDX, IDC_CHECKFORNEWVERSIONS, btVersionChecks_);
Expand All @@ -116,6 +117,7 @@ BEGIN_MESSAGE_MAP(CSettings, CDialog)
ON_BN_CLICKED(IDC_CHECKFORNEWVERSIONS, &CSettings::OnBnClickedCheckfornewversions)
ON_BN_CLICKED(IDC_SELECT_PERF_COUNTERS, &CSettings::OnBnClickedSelectPerfCounters)
ON_BN_CLICKED(IDC_USE_OTHER_KERNEL_LOGGER, &CSettings::OnBnClickedUseOtherKernelLogger)
ON_BN_CLICKED(IDC_RECORD_PRE_TRACE, &CSettings::OnBnClickedRecordPreTrace)
END_MESSAGE_MAP()

BOOL CSettings::OnInitDialog()
Expand All @@ -126,6 +128,7 @@ BOOL CSettings::OnInitDialog()
CheckDlgButton(IDC_USE_OTHER_KERNEL_LOGGER, bUseOtherKernelLogger_);
CheckDlgButton(IDC_CHROMEDEVELOPER, bChromeDeveloper_);
CheckDlgButton(IDC_AUTOVIEWTRACES, bAutoViewTraces_);
CheckDlgButton(IDC_RECORD_PRE_TRACE, bRecordPreTrace_);
CheckDlgButton(IDC_HEAPSTACKS, bHeapStacks_);
CheckDlgButton(IDC_VIRTUALALLOCSTACKS, bVirtualAllocStacks_);
CheckDlgButton(IDC_CHECKFORNEWVERSIONS, bVersionChecks_);
Expand Down Expand Up @@ -193,6 +196,9 @@ BOOL CSettings::OnInitDialog()
L"traces.");
toolTip_.AddTool(&btAutoViewTraces_, L"Check this to have UIforETW launch the trace viewer "
L"immediately after a trace is recorded.");
toolTip_.AddTool(&btRecordPreTrace_, L"Check this to enable recording of a startup trace "
L"to grab a snapshot of module version and symbol information. This allows analyzing "
L"traces across upgrades, such as chrome restart upgrades.");
toolTip_.AddTool(&btHeapStacks_, L"Check this to record call stacks on HeapAlloc, HeapRealloc, "
L"and similar calls, when doing heap traces.");
toolTip_.AddTool(&btVirtualAllocStacks_, L"Check this to record call stacks on VirtualAlloc on all "
Expand Down Expand Up @@ -379,3 +385,9 @@ void CSettings::OnBnClickedUseOtherKernelLogger()
{
bUseOtherKernelLogger_ = !bUseOtherKernelLogger_;
}


void CSettings::OnBnClickedRecordPreTrace()
{
bRecordPreTrace_ = !bRecordPreTrace_;
}
3 changes: 3 additions & 0 deletions UIforETW/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class CSettings : public CDialog
bool bUseOtherKernelLogger_ = false;
bool bChromeDeveloper_ = false;
bool bAutoViewTraces_ = false;
bool bRecordPreTrace_ = false;
bool bHeapStacks_ = false;
bool bVirtualAllocStacks_ = false;
bool bVersionChecks_ = false;
Expand All @@ -62,6 +63,7 @@ class CSettings : public CDialog
CButton btUseOtherKernelLogger_;
CButton btChromeDeveloper_;
CButton btAutoViewTraces_;
CButton btRecordPreTrace_;
CButton btHeapStacks_;
CButton btVirtualAllocStacks_;
CButton btVersionChecks_;
Expand Down Expand Up @@ -90,4 +92,5 @@ class CSettings : public CDialog
afx_msg void OnBnClickedCheckfornewversions();
afx_msg void OnBnClickedSelectPerfCounters();
afx_msg void OnBnClickedUseOtherKernelLogger();
afx_msg void OnBnClickedRecordPreTrace();
};
1 change: 1 addition & 0 deletions UIforETW/Support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void CUIforETWDlg::TransferSettings(bool saving)
{ L"UseOtherKernelLogger", &bUseOtherKernelLogger_ },
{ L"ChromeDeveloper", &bChromeDeveloper_ },
{ L"AutoViewTraces", &bAutoViewTraces_ },
{ L"RecordPreTrace", &bRecordPreTrace_ },
{ L"HeapStacks", &bHeapStacks_ },
{ L"VirtualAllocStacks", &bVirtualAllocStacks_ },
{ L"VersionChecks", &bVersionChecks_ },
Expand Down
5 changes: 3 additions & 2 deletions UIforETW/UIforETW.rc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ BEGIN
CONTROL "Extra &user mode providers:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,7,93,92,8
EDITTEXT IDC_EXTRAUSERMODEPROVIDERS,102,91,133,14,ES_AUTOHSCROLL
CONTROL "Perf counters:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,7,112,52,8
PUSHBUTTON "Se&lect...",IDC_SELECT_PERF_COUNTERS,61,109,38,14
EDITTEXT IDC_PERFORMANCECOUNTERS,102,109,133,14,ES_AUTOHSCROLL
PUSHBUTTON "&Copy startup profiles",IDC_COPYSTARTUPPROFILE,7,144,75,14
CONTROL "Record pre-trace",IDC_RECORD_PRE_TRACE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,167,71,10
CONTROL "Use other kernel logger",IDC_USE_OTHER_KERNEL_LOGGER,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,180,91,10
CONTROL "Ch&rome developer",IDC_CHROMEDEVELOPER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,103,128,75,10
Expand All @@ -160,8 +163,6 @@ BEGIN
LISTBOX IDC_CHROME_CATEGORIES,245,18,149,155,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,286,176,50,14
PUSHBUTTON "Cancel",IDCANCEL,344,176,50,14
PUSHBUTTON "Se&lect...",IDC_SELECT_PERF_COUNTERS,61,109,38,14
EDITTEXT IDC_PERFORMANCECOUNTERS,102,109,133,14,ES_AUTOHSCROLL
END


Expand Down
9 changes: 4 additions & 5 deletions UIforETW/UIforETWDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,14 +1101,11 @@ void CUIforETWDlg::OnBnClickedStarttracing()

DWORD exitCode = 0;
bool started = true;
if (tracingMode_ == kTracingToFile && bChromeDeveloper_)
if (tracingMode_ == kTracingToFile && bRecordPreTrace_)
{
// Implement the fix to https://github.com/google/UIforETW/issues/97
// Grab an initial trace that will contain imageID, fileversion, etc., so that ETW
// traces that cover a Chrome upgrade will get before and after information. This
// *could* be applicable to non-Chrome developers, but it is unlikely, so rather than
// creating yet-another-obscure-setting I just piggyback off of the bChromeDeveloper_
// flag, in order to keep things simple.
// traces that cover a Chrome upgrade will get before and after information.
const std::wstring imageIDCommands[] = {
// Start tracing with minimal flags
L"xperf.exe -start " + GetKernelLogger() + L" -on PROC_THREAD+LOADER -f \"" + GetTempImageTraceFile() + L"\"",
Expand Down Expand Up @@ -1851,6 +1848,7 @@ void CUIforETWDlg::OnBnClickedSettings()
dlgSettings.bUseOtherKernelLogger_ = bUseOtherKernelLogger_;
dlgSettings.bChromeDeveloper_ = bChromeDeveloper_;
dlgSettings.bAutoViewTraces_ = bAutoViewTraces_;
dlgSettings.bRecordPreTrace_ = bRecordPreTrace_;
dlgSettings.bHeapStacks_ = bHeapStacks_;
dlgSettings.bVirtualAllocStacks_ = bVirtualAllocStacks_;
dlgSettings.bVersionChecks_ = bVersionChecks_;
Expand Down Expand Up @@ -1880,6 +1878,7 @@ void CUIforETWDlg::OnBnClickedSettings()

// Copy over the remaining settings.
bUseOtherKernelLogger_ = dlgSettings.bUseOtherKernelLogger_;
bRecordPreTrace_ = dlgSettings.bRecordPreTrace_;
WSMonitoredProcesses_ = dlgSettings.WSMonitoredProcesses_;
bExpensiveWSMonitoring_ = dlgSettings.bExpensiveWSMonitoring_;
extraKernelFlags_ = dlgSettings.extraKernelFlags_;
Expand Down
1 change: 1 addition & 0 deletions UIforETW/UIforETWDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ class CUIforETWDlg : public CDialog
// Editable only by the settings dialog.
bool bChromeDeveloper_ = false;
bool bAutoViewTraces_ = false;
bool bRecordPreTrace_ = false;
std::wstring extraKernelFlags_;
std::wstring extraKernelStacks_;
std::wstring extraUserProviders_;
Expand Down

0 comments on commit cd47a9d

Please sign in to comment.