summaryrefslogtreecommitdiff
path: root/src/vm/eventpipeconfiguration.cpp
diff options
context:
space:
mode:
authorVictor "Nate" Graf <nategraf1@gmail.com>2017-12-20 18:07:52 -0800
committerGitHub <noreply@github.com>2017-12-20 18:07:52 -0800
commit7524d72d4f0f634fe5407280b83c25181dc8c556 (patch)
tree119c7edbbd7b3a0aec47d55334d52d1471e3a3da /src/vm/eventpipeconfiguration.cpp
parent9891c8ba8f84ff646455b4493447295c591665f4 (diff)
downloadcoreclr-7524d72d4f0f634fe5407280b83c25181dc8c556.tar.gz
coreclr-7524d72d4f0f634fe5407280b83c25181dc8c556.tar.bz2
coreclr-7524d72d4f0f634fe5407280b83c25181dc8c556.zip
Enable EventPipe across Unix and Windows (#14772)
* [squashed] most work complete to enable EventPipe on Windows * Eventpipe now builds on Windows * Ensure evevntpipe is intialized on Windows * Resolve the location of python from build.cmd * Ensure eventing files are generated when needed * moving linkage declaration to cmake * create new event from constructor * enable FEATURE_EVENT_TRACE and FEATURE_PERF_TRACE everywhere * [WIP] checkpoint in fixing contarct errors * add another possible python location * Fix double delete bug in EventPipeConfiguration destructor * Fix typo in function name * Revert changes to .gitgnore * bump to netstandard1.6 in preperation for new version of TraceEvent * Revert changes to groovy files * revert changes to perf-prep scripts * add common.h and use nothrow * Fix issue which was causing double delete of configprovider * Add new test utilizing TraceEvent * Remove accidentally added local directory reference * Add comment to explain the addition of misc/tracepointprovider.cpp * Add back sys.exit(0) and refactor * Change conditional to be more direct * Better handle NULL config * Initialize m_deleteDefered * Eliminate obsolete field * Fix spelling error * Fix nits * Make smaple progiler timing functions easier to read * Move projects back to netstandard1.4 * Incomplete improvements to EventPipeTrace test * Add event integrity checks to test * Clean up some left over code * Add EventSource based test * Remove unused PAL tests on Windows * Fix Linux build breaks * Minor changes to CMake files * Remove //HACK for hack that was previously removed * Fix formatting and negate a #ifdef * Add conditional to ensure PERFTRACING is not enabled without EVENT_TRACE * Take lock on EventPipeProvider and EventPipeConfiguration destruction * Load winmm.dll at runtime * Change function name and compile conditions * Move typedef into #ifndef * Use the correct config in setup * Change lifecycle managment of EventPipeConfiguration's configuration provider * Enable EventPipe tests pri0 and disable broken tests * Replace python3 only error with python2 compatable one * Make common.csproj build pri0 * Change TraceEvent version to 2.0.2 to match published verison * Address cross build failure * Remove use of undefined variable * Add crossgen fix to .cmd * Use more specific types to avoid marshalling errors * Use Assert-style statements and remove one check * Fix cross arch build * Fix flipped branch * Bring build.cmd changes to build.sh * Fix cmake writing * Revert "Bring build.cmd changes to build.sh" This reverts commit 893c6492548d8bc9859ebba5b1b810aa630fac63. * remove stdlib.h * Fix out of order null check
Diffstat (limited to 'src/vm/eventpipeconfiguration.cpp')
-rw-r--r--src/vm/eventpipeconfiguration.cpp63
1 files changed, 39 insertions, 24 deletions
diff --git a/src/vm/eventpipeconfiguration.cpp b/src/vm/eventpipeconfiguration.cpp
index ae1dd4e099..a74bdbc28f 100644
--- a/src/vm/eventpipeconfiguration.cpp
+++ b/src/vm/eventpipeconfiguration.cpp
@@ -20,6 +20,7 @@ EventPipeConfiguration::EventPipeConfiguration()
m_rundownEnabled = false;
m_circularBufferSizeInBytes = 1024 * 1024 * 1000; // Default to 1000MB.
m_pEnabledProviderList = NULL;
+ m_pConfigProvider = NULL;
m_pProviderList = new SList<SListElem<EventPipeProvider*>>();
}
@@ -27,7 +28,7 @@ EventPipeConfiguration::~EventPipeConfiguration()
{
CONTRACTL
{
- THROWS;
+ NOTHROW;
GC_TRIGGERS;
MODE_ANY;
}
@@ -35,8 +36,15 @@ EventPipeConfiguration::~EventPipeConfiguration()
if(m_pConfigProvider != NULL)
{
- delete(m_pConfigProvider);
- m_pConfigProvider = NULL;
+ // This unregisters the provider, which takes a
+ // HOST_BREAKABLE lock
+ EX_TRY
+ {
+ DeleteProvider(m_pConfigProvider);
+ m_pConfigProvider = NULL;
+ }
+ EX_CATCH { }
+ EX_END_CATCH(SwallowAllExceptions);
}
if(m_pEnabledProviderList != NULL)
@@ -47,19 +55,28 @@ EventPipeConfiguration::~EventPipeConfiguration()
if(m_pProviderList != NULL)
{
- // Take the lock before manipulating the provider list.
- CrstHolder _crst(EventPipe::GetLock());
-
- SListElem<EventPipeProvider*> *pElem = m_pProviderList->GetHead();
- while(pElem != NULL)
+ // We swallow exceptions here because the HOST_BREAKABLE
+ // lock may throw and this destructor gets called in throw
+ // intolerant places. If that happens the provider list will leak
+ EX_TRY
{
- // We don't delete provider itself because it can be in-use
- SListElem<EventPipeProvider*> *pCurElem = pElem;
- pElem = m_pProviderList->GetNext(pElem);
- delete(pCurElem);
+ // Take the lock before manipulating the list.
+ CrstHolder _crst(EventPipe::GetLock());
+
+ SListElem<EventPipeProvider*> *pElem = m_pProviderList->GetHead();
+ while(pElem != NULL)
+ {
+ // We don't delete provider itself because it can be in-use
+ SListElem<EventPipeProvider*> *pCurElem = pElem;
+ pElem = m_pProviderList->GetNext(pElem);
+ delete(pCurElem);
+ }
+
+ delete(m_pProviderList);
}
+ EX_CATCH { }
+ EX_END_CATCH(SwallowAllExceptions);
- delete(m_pProviderList);
m_pProviderList = NULL;
}
}
@@ -110,7 +127,7 @@ void EventPipeConfiguration::DeleteProvider(EventPipeProvider *pProvider)
CONTRACTL
{
THROWS;
- GC_NOTRIGGER;
+ GC_TRIGGERS;
MODE_ANY;
PRECONDITION(pProvider != NULL);
}
@@ -177,7 +194,7 @@ bool EventPipeConfiguration::UnregisterProvider(EventPipeProvider &provider)
CONTRACTL
{
THROWS;
- GC_NOTRIGGER;
+ GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
@@ -271,7 +288,7 @@ size_t EventPipeConfiguration::GetCircularBufferSize() const
void EventPipeConfiguration::SetCircularBufferSize(size_t circularBufferSize)
{
LIMITED_METHOD_CONTRACT;
-
+
if(!m_enabled)
{
m_circularBufferSizeInBytes = circularBufferSize;
@@ -484,9 +501,7 @@ void EventPipeConfiguration::DeleteDeferredProviders()
pElem = m_pProviderList->GetNext(pElem);
if(pProvider->GetDeleteDeferred())
{
- // The act of deleting the provider unregisters it,
- // removes it from the list, and deletes the list element
- delete(pProvider);
+ DeleteProvider(pProvider);
}
}
}
@@ -525,7 +540,7 @@ EventPipeEnabledProviderList::EventPipeEnabledProviderList(
}
m_pProviders = new EventPipeEnabledProvider[m_numProviders];
- for(int i=0; i<m_numProviders; i++)
+ for(unsigned int i=0; i<m_numProviders; i++)
{
m_pProviders[i].Set(
pConfigs[i].GetProviderName(),
@@ -538,7 +553,7 @@ EventPipeEnabledProviderList::~EventPipeEnabledProviderList()
{
CONTRACTL
{
- THROWS;
+ NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
}
@@ -582,7 +597,7 @@ EventPipeEnabledProvider* EventPipeEnabledProviderList::GetEnabledProvider(
LPCWSTR providerName = providerNameStr.GetUnicode();
EventPipeEnabledProvider *pEnabledProvider = NULL;
- for(int i=0; i<m_numProviders; i++)
+ for(unsigned int i=0; i<m_numProviders; i++)
{
EventPipeEnabledProvider *pCandidate = &m_pProviders[i];
if(pCandidate != NULL)
@@ -609,7 +624,7 @@ EventPipeEnabledProvider::~EventPipeEnabledProvider()
{
CONTRACTL
{
- THROWS;
+ NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
}
@@ -640,7 +655,7 @@ void EventPipeEnabledProvider::Set(LPCWSTR providerName, UINT64 keywords, EventP
if(providerName != NULL)
{
- unsigned int bufSize = wcslen(providerName) + 1;
+ size_t bufSize = wcslen(providerName) + 1;
m_pProviderName = new WCHAR[bufSize];
wcscpy_s(m_pProviderName, bufSize, providerName);
}