Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisGen, W("GCGenAnalysisGen"), 0, "T
RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisBytes, W("GCGenAnalysisBytes"), 0, "The number of bytes to trigger generational aware analysis")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisIndex, W("GCGenAnalysisIndex"), 0, "The gc index to trigger generational aware analysis")
RETAIL_CONFIG_STRING_INFO(INTERNAL_GCGenAnalysisCmd, W("GCGenAnalysisCmd"), "An optional filter to match with the command line used to spawn the process")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisTrace, W("GCGenAnalysisTrace"), 1, "Enable/Disable capturing a trace")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisDump, W("GCGenAnalysisDump"), 0, "Enable/Disable capturing a dump")

//
// Diagnostics Ports
Expand Down
12 changes: 1 addition & 11 deletions src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,10 @@ ds_rt_generate_core_dump (DiagnosticsGenerateCoreDumpCommandPayload *payload)
ds_ipc_result_t result = DS_IPC_E_FAIL;
EX_TRY
{
#ifdef HOST_WIN32
if (GenerateCrashDump (reinterpret_cast<LPCWSTR>(ds_generate_core_dump_command_payload_get_dump_name (payload)),
if (GenerateDump (reinterpret_cast<LPCWSTR>(ds_generate_core_dump_command_payload_get_dump_name (payload)),
static_cast<int32_t>(ds_generate_core_dump_command_payload_get_dump_type (payload)),
(ds_generate_core_dump_command_payload_get_diagnostics (payload) != 0) ? true : false))
result = DS_IPC_S_OK;
#else
MAKE_UTF8PTR_FROMWIDE_NOTHROW (dump_name, reinterpret_cast<LPCWSTR>(ds_generate_core_dump_command_payload_get_dump_name (payload)));
if (dump_name != nullptr) {
if (PAL_GenerateCoreDump (dump_name,
static_cast<int32_t>(ds_generate_core_dump_command_payload_get_dump_type (payload)),
(ds_generate_core_dump_command_payload_get_diagnostics (payload) != 0) ? true : false))
result = DS_IPC_S_OK;
}
#endif
}
EX_CATCH {}
EX_END_CATCH(SwallowAllExceptions);
Expand Down
20 changes: 20 additions & 0 deletions src/coreclr/vm/excep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4176,6 +4176,26 @@ InitializeCrashDump()

#endif // HOST_WINDOWS

bool GenerateDump(
LPCWSTR dumpName,
int dumpType,
bool diag)
{
#ifdef TARGET_UNIX
MAKE_UTF8PTR_FROMWIDE_NOTHROW (dumpNameUtf8, dumpName);
if (dumpNameUtf8 == nullptr)
{
return false;
}
else
{
return PAL_GenerateCoreDump(dumpNameUtf8, dumpType, diag);
}
#else // TARGET_UNIX
return GenerateCrashDump(dumpName, dumpType, diag);
#endif // TARGET_UNIX
}

//************************************************************************************
// Create crash dump if enabled and terminate process. Generates crash dumps for both
// Windows and Linux if enabled. For Linux, it happens in TerminateProcess in the PAL.
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/excep.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ enum UnhandledExceptionLocation

#ifdef HOST_WINDOWS
void InitializeCrashDump();
bool GenerateCrashDump(LPCWSTR dumpName, int dumpType, bool diag);
void CreateCrashDumpIfEnabled(bool stackoverflow = false);
#endif
bool GenerateDump(LPCWSTR dumpName, int dumpType, bool diag);

// Generates crash dumps if enabled for both Windows and Linux
void CrashDumpAndTerminateProcess(UINT exitCode);
Expand Down
11 changes: 6 additions & 5 deletions src/coreclr/vm/finalizerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,15 @@ VOID FinalizerThread::FinalizerThreadWorker(void *args)
if (gcGenAnalysisState == GcGenAnalysisState::Done)
{
gcGenAnalysisState = GcGenAnalysisState::Disabled;
EventPipeAdapter::Disable(gcGenAnalysisEventPipeSessionId);
// Writing an empty file to indicate completion
fclose(fopen(GENAWARE_COMPLETION_FILE_NAME,"w+"));
#ifdef GEN_ANALYSIS_STRESS
if (gcGenAnalysisTrace)
{
EventPipeAdapter::Disable(gcGenAnalysisEventPipeSessionId);
#ifdef GEN_ANALYSIS_STRESS
GenAnalysis::EnableGenerationalAwareSession();
}
#endif
}
// Writing an empty file to indicate completion
fclose(fopen(GENAWARE_COMPLETION_FILE_NAME,"w+"));
}

if (!bPriorityBoosted)
Expand Down
28 changes: 20 additions & 8 deletions src/coreclr/vm/gcenv.ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1644,14 +1644,26 @@ void GCToEEInterface::AnalyzeSurvivorsFinished(size_t gcIndex, int condemnedGene
if ((condemnedGeneration == gcGenAnalysisGen) && (promoted_bytes > (uint64_t)gcGenAnalysisBytes) && (gcIndex > (uint64_t)gcGenAnalysisIndex))
#endif
{
EventPipeAdapter::ResumeSession(gcGenAnalysisEventPipeSession);
FireEtwGenAwareBegin((int)gcIndex, GetClrInstanceId());
s_forcedGCInProgress = true;
GCProfileWalkHeap(true);
s_forcedGCInProgress = false;
reportGenerationBounds();
FireEtwGenAwareEnd((int)gcIndex, GetClrInstanceId());
EventPipeAdapter::PauseSession(gcGenAnalysisEventPipeSession);
if (gcGenAnalysisTrace)
{
EventPipeAdapter::ResumeSession(gcGenAnalysisEventPipeSession);
FireEtwGenAwareBegin((int)gcIndex, GetClrInstanceId());
s_forcedGCInProgress = true;
GCProfileWalkHeap(true);
s_forcedGCInProgress = false;
reportGenerationBounds();
FireEtwGenAwareEnd((int)gcIndex, GetClrInstanceId());
EventPipeAdapter::PauseSession(gcGenAnalysisEventPipeSession);
}
if (gcGenAnalysisDump)
{
EX_TRY
{
GenerateDump (GENAWARE_DUMP_FILE_NAME, 2, false);
}
EX_CATCH {}
EX_END_CATCH(SwallowAllExceptions);
}
gcGenAnalysisState = GcGenAnalysisState::Done;
EnableFinalization(true);
}
Expand Down
17 changes: 14 additions & 3 deletions src/coreclr/vm/genanalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ int64_t gcGenAnalysisGen = -1;
int64_t gcGenAnalysisBytes = 0;
int64_t gcGenAnalysisIndex = 0;
uint32_t gcGenAnalysisBufferMB = 0;
bool gcGenAnalysisTrace = true;
bool gcGenAnalysisDump = false;

/* static */ void GenAnalysis::Initialize()
{
Expand Down Expand Up @@ -41,6 +43,8 @@ uint32_t gcGenAnalysisBufferMB = 0;
gcGenAnalysisGen = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_GCGenAnalysisGen);
gcGenAnalysisIndex = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_GCGenAnalysisIndex);
gcGenAnalysisBufferMB = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_EventPipeCircularMB);
gcGenAnalysisTrace = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_GCGenAnalysisTrace);
gcGenAnalysisDump = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_GCGenAnalysisDump);
gcGenAnalysisConfigured = GcGenAnalysisState::Enabled;
}
else
Expand All @@ -51,14 +55,21 @@ uint32_t gcGenAnalysisBufferMB = 0;
if ((gcGenAnalysisConfigured == GcGenAnalysisState::Enabled) && (gcGenAnalysisState == GcGenAnalysisState::Uninitialized))
#endif
{
EnableGenerationalAwareSession();
}
if (gcGenAnalysisTrace)
{
EnableGenerationalAwareSession();
}
if (gcGenAnalysisDump)
{
gcGenAnalysisState = GcGenAnalysisState::Enabled;
}
}
}

/* static */ void GenAnalysis::EnableGenerationalAwareSession()
{
LPCWSTR outputPath = nullptr;
outputPath = GENAWARE_FILE_NAME;
outputPath = GENAWARE_TRACE_FILE_NAME;
NewArrayHolder<COR_PRF_EVENTPIPE_PROVIDER_CONFIG> pProviders;
int providerCnt = 1;
pProviders = new COR_PRF_EVENTPIPE_PROVIDER_CONFIG[providerCnt];
Expand Down
5 changes: 4 additions & 1 deletion src/coreclr/vm/genanalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ enum GcGenAnalysisState
Done = 3,
};

#define GENAWARE_FILE_NAME W("gcgenaware.nettrace")
#define GENAWARE_TRACE_FILE_NAME W("gcgenaware.nettrace")
#define GENAWARE_DUMP_FILE_NAME W("gcgenaware.dmp")
#define GENAWARE_COMPLETION_FILE_NAME "gcgenaware.nettrace.completed"

extern bool s_forcedGCInProgress;
Expand All @@ -29,6 +30,8 @@ extern GcGenAnalysisState gcGenAnalysisConfigured;
extern int64_t gcGenAnalysisGen;
extern int64_t gcGenAnalysisBytes;
extern int64_t gcGenAnalysisIndex;
extern bool gcGenAnalysisTrace;
extern bool gcGenAnalysisDump;

class GenAnalysis
{
Expand Down