Skip to content

Commit b7dfd99

Browse files
committed
Merge remote-tracking branch 'origin/main' into wasm-workloads
2 parents 5f1b157 + 8818c15 commit b7dfd99

File tree

9 files changed

+71
-32
lines changed

9 files changed

+71
-32
lines changed

eng/Versions.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
</PropertyGroup>
4747
<PropertyGroup>
4848
<!-- Code analysis dependencies -->
49-
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>3.10.0-2.final</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
50-
<MicrosoftCodeAnalysisCSharpVersion>3.10.0-2.final</MicrosoftCodeAnalysisCSharpVersion>
51-
<MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-rc1.21320.2</MicrosoftCodeAnalysisNetAnalyzersVersion>
49+
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>3.10.0</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
50+
<MicrosoftCodeAnalysisCSharpVersion>3.10.0</MicrosoftCodeAnalysisCSharpVersion>
51+
<MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-rc1.21324.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
5252
<!-- Arcade dependencies -->
5353
<MicrosoftDotNetApiCompatVersion>6.0.0-beta.21321.1</MicrosoftDotNetApiCompatVersion>
5454
<MicrosoftDotNetBuildTasksFeedVersion>6.0.0-beta.21321.1</MicrosoftDotNetBuildTasksFeedVersion>

src/coreclr/inc/clrconfigvalues.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,8 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisGen, W("GCGenAnalysisGen"), 0, "T
722722
RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisBytes, W("GCGenAnalysisBytes"), 0, "The number of bytes to trigger generational aware analysis")
723723
RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisIndex, W("GCGenAnalysisIndex"), 0, "The gc index to trigger generational aware analysis")
724724
RETAIL_CONFIG_STRING_INFO(INTERNAL_GCGenAnalysisCmd, W("GCGenAnalysisCmd"), "An optional filter to match with the command line used to spawn the process")
725+
RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisTrace, W("GCGenAnalysisTrace"), 1, "Enable/Disable capturing a trace")
726+
RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisDump, W("GCGenAnalysisDump"), 0, "Enable/Disable capturing a dump")
725727

726728
//
727729
// Diagnostics Ports

src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,10 @@ ds_rt_generate_core_dump (DiagnosticsGenerateCoreDumpCommandPayload *payload)
195195
ds_ipc_result_t result = DS_IPC_E_FAIL;
196196
EX_TRY
197197
{
198-
#ifdef HOST_WIN32
199-
if (GenerateCrashDump (reinterpret_cast<LPCWSTR>(ds_generate_core_dump_command_payload_get_dump_name (payload)),
198+
if (GenerateDump (reinterpret_cast<LPCWSTR>(ds_generate_core_dump_command_payload_get_dump_name (payload)),
200199
static_cast<int32_t>(ds_generate_core_dump_command_payload_get_dump_type (payload)),
201200
(ds_generate_core_dump_command_payload_get_diagnostics (payload) != 0) ? true : false))
202201
result = DS_IPC_S_OK;
203-
#else
204-
MAKE_UTF8PTR_FROMWIDE_NOTHROW (dump_name, reinterpret_cast<LPCWSTR>(ds_generate_core_dump_command_payload_get_dump_name (payload)));
205-
if (dump_name != nullptr) {
206-
if (PAL_GenerateCoreDump (dump_name,
207-
static_cast<int32_t>(ds_generate_core_dump_command_payload_get_dump_type (payload)),
208-
(ds_generate_core_dump_command_payload_get_diagnostics (payload) != 0) ? true : false))
209-
result = DS_IPC_S_OK;
210-
}
211-
#endif
212202
}
213203
EX_CATCH {}
214204
EX_END_CATCH(SwallowAllExceptions);

src/coreclr/vm/excep.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4176,6 +4176,26 @@ InitializeCrashDump()
41764176

41774177
#endif // HOST_WINDOWS
41784178

4179+
bool GenerateDump(
4180+
LPCWSTR dumpName,
4181+
int dumpType,
4182+
bool diag)
4183+
{
4184+
#ifdef TARGET_UNIX
4185+
MAKE_UTF8PTR_FROMWIDE_NOTHROW (dumpNameUtf8, dumpName);
4186+
if (dumpNameUtf8 == nullptr)
4187+
{
4188+
return false;
4189+
}
4190+
else
4191+
{
4192+
return PAL_GenerateCoreDump(dumpNameUtf8, dumpType, diag);
4193+
}
4194+
#else // TARGET_UNIX
4195+
return GenerateCrashDump(dumpName, dumpType, diag);
4196+
#endif // TARGET_UNIX
4197+
}
4198+
41794199
//************************************************************************************
41804200
// Create crash dump if enabled and terminate process. Generates crash dumps for both
41814201
// Windows and Linux if enabled. For Linux, it happens in TerminateProcess in the PAL.

src/coreclr/vm/excep.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ enum UnhandledExceptionLocation
196196

197197
#ifdef HOST_WINDOWS
198198
void InitializeCrashDump();
199-
bool GenerateCrashDump(LPCWSTR dumpName, int dumpType, bool diag);
200199
void CreateCrashDumpIfEnabled(bool stackoverflow = false);
201200
#endif
201+
bool GenerateDump(LPCWSTR dumpName, int dumpType, bool diag);
202202

203203
// Generates crash dumps if enabled for both Windows and Linux
204204
void CrashDumpAndTerminateProcess(UINT exitCode);

src/coreclr/vm/finalizerthread.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,15 @@ VOID FinalizerThread::FinalizerThreadWorker(void *args)
274274
if (gcGenAnalysisState == GcGenAnalysisState::Done)
275275
{
276276
gcGenAnalysisState = GcGenAnalysisState::Disabled;
277-
EventPipeAdapter::Disable(gcGenAnalysisEventPipeSessionId);
278-
// Writing an empty file to indicate completion
279-
fclose(fopen(GENAWARE_COMPLETION_FILE_NAME,"w+"));
280-
#ifdef GEN_ANALYSIS_STRESS
277+
if (gcGenAnalysisTrace)
281278
{
279+
EventPipeAdapter::Disable(gcGenAnalysisEventPipeSessionId);
280+
#ifdef GEN_ANALYSIS_STRESS
282281
GenAnalysis::EnableGenerationalAwareSession();
283-
}
284282
#endif
283+
}
284+
// Writing an empty file to indicate completion
285+
fclose(fopen(GENAWARE_COMPLETION_FILE_NAME,"w+"));
285286
}
286287

287288
if (!bPriorityBoosted)

src/coreclr/vm/gcenv.ee.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,14 +1644,26 @@ void GCToEEInterface::AnalyzeSurvivorsFinished(size_t gcIndex, int condemnedGene
16441644
if ((condemnedGeneration == gcGenAnalysisGen) && (promoted_bytes > (uint64_t)gcGenAnalysisBytes) && (gcIndex > (uint64_t)gcGenAnalysisIndex))
16451645
#endif
16461646
{
1647-
EventPipeAdapter::ResumeSession(gcGenAnalysisEventPipeSession);
1648-
FireEtwGenAwareBegin((int)gcIndex, GetClrInstanceId());
1649-
s_forcedGCInProgress = true;
1650-
GCProfileWalkHeap(true);
1651-
s_forcedGCInProgress = false;
1652-
reportGenerationBounds();
1653-
FireEtwGenAwareEnd((int)gcIndex, GetClrInstanceId());
1654-
EventPipeAdapter::PauseSession(gcGenAnalysisEventPipeSession);
1647+
if (gcGenAnalysisTrace)
1648+
{
1649+
EventPipeAdapter::ResumeSession(gcGenAnalysisEventPipeSession);
1650+
FireEtwGenAwareBegin((int)gcIndex, GetClrInstanceId());
1651+
s_forcedGCInProgress = true;
1652+
GCProfileWalkHeap(true);
1653+
s_forcedGCInProgress = false;
1654+
reportGenerationBounds();
1655+
FireEtwGenAwareEnd((int)gcIndex, GetClrInstanceId());
1656+
EventPipeAdapter::PauseSession(gcGenAnalysisEventPipeSession);
1657+
}
1658+
if (gcGenAnalysisDump)
1659+
{
1660+
EX_TRY
1661+
{
1662+
GenerateDump (GENAWARE_DUMP_FILE_NAME, 2, false);
1663+
}
1664+
EX_CATCH {}
1665+
EX_END_CATCH(SwallowAllExceptions);
1666+
}
16551667
gcGenAnalysisState = GcGenAnalysisState::Done;
16561668
EnableFinalization(true);
16571669
}

src/coreclr/vm/genanalysis.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ int64_t gcGenAnalysisGen = -1;
1313
int64_t gcGenAnalysisBytes = 0;
1414
int64_t gcGenAnalysisIndex = 0;
1515
uint32_t gcGenAnalysisBufferMB = 0;
16+
bool gcGenAnalysisTrace = true;
17+
bool gcGenAnalysisDump = false;
1618

1719
/* static */ void GenAnalysis::Initialize()
1820
{
@@ -41,6 +43,8 @@ uint32_t gcGenAnalysisBufferMB = 0;
4143
gcGenAnalysisGen = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_GCGenAnalysisGen);
4244
gcGenAnalysisIndex = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_GCGenAnalysisIndex);
4345
gcGenAnalysisBufferMB = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_EventPipeCircularMB);
46+
gcGenAnalysisTrace = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_GCGenAnalysisTrace);
47+
gcGenAnalysisDump = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_GCGenAnalysisDump);
4448
gcGenAnalysisConfigured = GcGenAnalysisState::Enabled;
4549
}
4650
else
@@ -51,14 +55,21 @@ uint32_t gcGenAnalysisBufferMB = 0;
5155
if ((gcGenAnalysisConfigured == GcGenAnalysisState::Enabled) && (gcGenAnalysisState == GcGenAnalysisState::Uninitialized))
5256
#endif
5357
{
54-
EnableGenerationalAwareSession();
55-
}
58+
if (gcGenAnalysisTrace)
59+
{
60+
EnableGenerationalAwareSession();
61+
}
62+
if (gcGenAnalysisDump)
63+
{
64+
gcGenAnalysisState = GcGenAnalysisState::Enabled;
65+
}
66+
}
5667
}
5768

5869
/* static */ void GenAnalysis::EnableGenerationalAwareSession()
5970
{
6071
LPCWSTR outputPath = nullptr;
61-
outputPath = GENAWARE_FILE_NAME;
72+
outputPath = GENAWARE_TRACE_FILE_NAME;
6273
NewArrayHolder<COR_PRF_EVENTPIPE_PROVIDER_CONFIG> pProviders;
6374
int providerCnt = 1;
6475
pProviders = new COR_PRF_EVENTPIPE_PROVIDER_CONFIG[providerCnt];

src/coreclr/vm/genanalysis.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ enum GcGenAnalysisState
1818
Done = 3,
1919
};
2020

21-
#define GENAWARE_FILE_NAME W("gcgenaware.nettrace")
21+
#define GENAWARE_TRACE_FILE_NAME W("gcgenaware.nettrace")
22+
#define GENAWARE_DUMP_FILE_NAME W("gcgenaware.dmp")
2223
#define GENAWARE_COMPLETION_FILE_NAME "gcgenaware.nettrace.completed"
2324

2425
extern bool s_forcedGCInProgress;
@@ -29,6 +30,8 @@ extern GcGenAnalysisState gcGenAnalysisConfigured;
2930
extern int64_t gcGenAnalysisGen;
3031
extern int64_t gcGenAnalysisBytes;
3132
extern int64_t gcGenAnalysisIndex;
33+
extern bool gcGenAnalysisTrace;
34+
extern bool gcGenAnalysisDump;
3235

3336
class GenAnalysis
3437
{

0 commit comments

Comments
 (0)