Remove debug-only file writers. (dotnet/coreclr#20612)
authorBrian Robbins <brianrob@microsoft.com>
Thu, 25 Oct 2018 19:58:56 +0000 (12:58 -0700)
committerGitHub <noreply@github.com>
Thu, 25 Oct 2018 19:58:56 +0000 (12:58 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/6dd4270daf3ee49a08adedaf71a087de32c810a2

src/coreclr/src/vm/eventpipe.cpp
src/coreclr/src/vm/eventpipe.h
src/coreclr/src/vm/eventpipefile.cpp
src/coreclr/src/vm/eventpipefile.h

index 08e9ef1..5ff8111 100644 (file)
@@ -33,10 +33,6 @@ LPCWSTR EventPipe::s_pOutputPath = NULL;
 EventPipeFile* EventPipe::s_pFile = NULL;
 EventPipeEventSource* EventPipe::s_pEventSource = NULL;
 LPCWSTR EventPipe::s_pCommandLine = NULL;
-#ifdef _DEBUG
-EventPipeFile* EventPipe::s_pSyncFile = NULL;
-EventPipeJsonFile* EventPipe::s_pJsonFile = NULL;
-#endif // _DEBUG
 unsigned long EventPipe::s_nextFileIndex;
 HANDLE EventPipe::s_fileSwitchTimerHandle = NULL;
 ULONGLONG EventPipe::s_lastFileSwitchTime = 0;
@@ -336,21 +332,6 @@ EventPipeSessionID EventPipe::Enable(LPCWSTR strOutputPath, EventPipeSession *pS
         s_pFile = new EventPipeFile(nextTraceFilePath);
     }
 
-#ifdef _DEBUG
-    if((CLRConfig::GetConfigValue(CLRConfig::INTERNAL_EnableEventPipe) & 2) == 2)
-    {
-        // Create a synchronous file.
-        SString eventPipeSyncFileOutputPath;
-        eventPipeSyncFileOutputPath.Printf("Process-%d.sync.netperf", GetCurrentProcessId());
-        s_pSyncFile = new EventPipeFile(eventPipeSyncFileOutputPath);
-
-        // Create a JSON file.
-        SString outputFilePath;
-        outputFilePath.Printf("Process-%d.PerfView.json", GetCurrentProcessId());
-        s_pJsonFile = new EventPipeJsonFile(outputFilePath);
-    }
-#endif // _DEBUG
-
     // Save the session.
     s_pSession = pSession;
 
@@ -454,18 +435,6 @@ void EventPipe::Disable(EventPipeSessionID id)
             delete(s_pFile);
             s_pFile = NULL;
         }
-#ifdef _DEBUG
-        if(s_pSyncFile != NULL)
-        {
-            delete(s_pSyncFile);
-            s_pSyncFile = NULL;
-        }
-        if(s_pJsonFile != NULL)
-        {
-            delete(s_pJsonFile);
-            s_pJsonFile = NULL;
-        }
-#endif // _DEBUG
 
         // De-allocate buffers.
         s_pBufferManager->DeAllocateBuffers();
@@ -803,11 +772,7 @@ void EventPipe::WriteEventInternal(EventPipeEvent &event, EventPipeEventPayload
 
     if(!s_pConfig->RundownEnabled() && s_pBufferManager != NULL)
     {
-        if(!s_pBufferManager->WriteEvent(pThread, *s_pSession, event, payload, pActivityId, pRelatedActivityId))
-        {
-            // This is used in DEBUG to make sure that we don't log an event synchronously that we didn't log to the buffer.
-            return;
-        }
+        s_pBufferManager->WriteEvent(pThread, *s_pSession, event, payload, pActivityId, pRelatedActivityId);
     }
     else if(s_pConfig->RundownEnabled())
     {
@@ -852,39 +817,6 @@ void EventPipe::WriteEventInternal(EventPipeEvent &event, EventPipeEventPayload
             }
         }
     }
-
-// This section requires a call to GCX_PREEMP which violates the GC_NOTRIGGER contract
-// It should only be enabled when debugging this specific component and contracts are off
-#ifdef DEBUG_JSON_EVENT_FILE
-    {
-        GCX_PREEMP();
-
-        BYTE *pData = payload.GetFlatData();
-        if (pData != NULL)
-        {
-            // Create an instance of the event for the synchronous path.
-            EventPipeEventInstance instance(
-                event,
-                pThread->GetOSThreadId(),
-                pData,
-                payload.GetSize(),
-                pActivityId,
-                pRelatedActivityId);
-
-            // Write to the EventPipeFile if it exists.
-            if(s_pSyncFile != NULL)
-            {
-                s_pSyncFile->WriteEvent(instance);
-            }
-
-            // Write to the EventPipeJsonFile if it exists.
-            if(s_pJsonFile != NULL)
-            {
-                s_pJsonFile->WriteEvent(instance);
-            }
-        }
-    }
-#endif // DEBUG_JSON_EVENT_FILE
 }
 
 void EventPipe::WriteSampleProfileEvent(Thread *pSamplingThread, EventPipeEvent *pEvent, Thread *pTargetThread, StackContents &stackContents, BYTE *pData, unsigned int length)
@@ -904,34 +836,8 @@ void EventPipe::WriteSampleProfileEvent(Thread *pSamplingThread, EventPipeEvent
     {
         // Specify the sampling thread as the "current thread", so that we select the right buffer.
         // Specify the target thread so that the event gets properly attributed.
-        if(!s_pBufferManager->WriteEvent(pSamplingThread, *s_pSession, *pEvent, payload, NULL /* pActivityId */, NULL /* pRelatedActivityId */, pTargetThread, &stackContents))
-        {
-            // This is used in DEBUG to make sure that we don't log an event synchronously that we didn't log to the buffer.
-            return;
-        }
-    }
-
-#ifdef _DEBUG
-    {
-        GCX_PREEMP();
-
-        // Create an instance for the synchronous path.
-        SampleProfilerEventInstance instance(*s_pSession, *pEvent, pTargetThread, pData, length);
-        stackContents.CopyTo(instance.GetStack());
-
-        // Write to the EventPipeFile.
-        if(s_pSyncFile != NULL)
-        {
-            s_pSyncFile->WriteEvent(instance);
-        }
-
-        // Write to the EventPipeJsonFile if it exists.
-        if(s_pJsonFile != NULL)
-        {
-            s_pJsonFile->WriteEvent(instance);
-        }
+        s_pBufferManager->WriteEvent(pSamplingThread, *s_pSession, *pEvent, payload, NULL /* pActivityId */, NULL /* pRelatedActivityId */, pTargetThread, &stackContents);
     }
-#endif // _DEBUG
 }
 
 bool EventPipe::WalkManagedStackForCurrentThread(StackContents &stackContents)
index c96e78b..b9d3fab 100644 (file)
@@ -329,10 +329,6 @@ class EventPipe
         static EventPipeFile *s_pFile;
         static EventPipeEventSource *s_pEventSource;
         static LPCWSTR s_pCommandLine;
-#ifdef _DEBUG
-        static EventPipeFile *s_pSyncFile;
-        static EventPipeJsonFile *s_pJsonFile;
-#endif // _DEBUG
         const static DWORD FileSwitchTimerPeriodMS = 1000;
         static HANDLE s_fileSwitchTimerHandle;
         static ULONGLONG s_lastFileSwitchTime;
index 907a5dc..424bbef 100644 (file)
 #ifdef FEATURE_PERFTRACING
 
 EventPipeFile::EventPipeFile(
-    SString &outputFilePath
-#ifdef _DEBUG
-    ,
-    bool lockOnWrite
-#endif // _DEBUG
-)
+    SString &outputFilePath)
 {
     CONTRACTL
     {
@@ -32,10 +27,6 @@ EventPipeFile::EventPipeFile(
 
     m_pBlock = new EventPipeBlock(100 * 1024);
 
-#ifdef _DEBUG
-    m_lockOnWrite = lockOnWrite;
-#endif // _DEBUG
-
     // File start time information.
     GetSystemTime(&m_fileOpenSystemTime);
     QueryPerformanceCounter(&m_fileOpenTimeStamp);
@@ -158,16 +149,6 @@ void EventPipeFile::WriteToBlock(EventPipeEventInstance &instance, unsigned int
         return; // the block is not full, we added the event and continue
     }
 
-#ifdef _DEBUG
-    if (m_lockOnWrite)
-    {
-        // Take the serialization lock.
-        // This is used for synchronous file writes.
-        // The circular buffer path only writes from one thread.
-        SpinLockHolder _slh(&m_serializationLock);
-    }
-#endif // _DEBUG
-
     // we can't write this event to the current block (it's full)
     // so we write what we have in the block to the serializer
     m_pSerializer->WriteObject(m_pBlock);
index 48f0bb0..29c2b19 100644 (file)
@@ -18,12 +18,7 @@ class EventPipeFile : public FastSerializableObject
 {
     public:
 
-        EventPipeFile(SString &outputFilePath
-#ifdef _DEBUG
-            ,
-            bool lockOnWrite = false
-#endif // _DEBUG
-        );
+        EventPipeFile(SString &outputFilePath);
         ~EventPipeFile();
 
         void WriteEvent(EventPipeEventInstance &instance);
@@ -98,10 +93,6 @@ class EventPipeFile : public FastSerializableObject
         MapSHashWithRemove<EventPipeEvent*, unsigned int> *m_pMetadataIds;
 
         Volatile<LONG> m_metadataIdCounter;
-
-#ifdef _DEBUG
-        bool m_lockOnWrite;
-#endif // _DEBUG
 };
 
 #endif // FEATURE_PERFTRACING