Skip to content

Commit 4a89e23

Browse files
committed
More code review feedback chantges
1 parent b1f2d13 commit 4a89e23

File tree

4 files changed

+14
-28
lines changed

4 files changed

+14
-28
lines changed

src/coreclr/debug/createdump/crashinfo.cpp

+7-20
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ CrashInfo::LogMessage(
149149
// Gather all the necessary crash dump info.
150150
//
151151
bool
152-
CrashInfo::GatherCrashInfo(DumpType* dumpType)
152+
CrashInfo::GatherCrashInfo(DumpType dumpType)
153153
{
154154
// Get the info about the threads (registers, etc.)
155155
for (ThreadInfo* thread : m_threads)
@@ -182,7 +182,7 @@ CrashInfo::GatherCrashInfo(DumpType* dumpType)
182182
}
183183
#endif
184184
// Load and initialize DAC interfaces
185-
if (!InitializeDAC())
185+
if (!InitializeDAC(dumpType))
186186
{
187187
return false;
188188
}
@@ -208,13 +208,8 @@ CrashInfo::GatherCrashInfo(DumpType* dumpType)
208208
region.Trace();
209209
}
210210
}
211-
// If the DAC module present side-by-side (the default for single-file and native AOT apps), fallback to full dump.
212-
if (m_pClrDataProcess == nullptr)
213-
{
214-
*dumpType = DumpType::Full;
215-
}
216211
// If full memory dump, include everything regardless of permissions
217-
if (*dumpType == DumpType::Full)
212+
if (dumpType == DumpType::Full)
218213
{
219214
for (const MemoryRegion& region : m_moduleMappings)
220215
{
@@ -233,7 +228,7 @@ CrashInfo::GatherCrashInfo(DumpType* dumpType)
233228
{
234229
// Add all the heap read/write memory regions (m_otherMappings contains the heaps). On Alpine
235230
// the heap regions are marked RWX instead of just RW.
236-
if (*dumpType == DumpType::Heap)
231+
if (dumpType == DumpType::Heap)
237232
{
238233
for (const MemoryRegion& region : m_otherMappings)
239234
{
@@ -283,9 +278,9 @@ GetHResultString(HRESULT hr)
283278
// Enumerate all the memory regions using the DAC memory region support given a minidump type
284279
//
285280
bool
286-
CrashInfo::InitializeDAC()
281+
CrashInfo::InitializeDAC(DumpType dumpType)
287282
{
288-
// Don't attempt to load the DAC if createdump is statically linked into the runtime
283+
// Don't attempt to load the DAC if native AOT app (there is no DAC)
289284
if (m_appModel == AppModelType::NativeAOT)
290285
{
291286
return true;
@@ -312,15 +307,7 @@ CrashInfo::InitializeDAC()
312307
m_dacModule = dlopen(dacPath.c_str(), RTLD_LAZY);
313308
if (m_dacModule == nullptr)
314309
{
315-
// Don't fail for single-file apps when the DAC can't be found. Will fall back to full dump.
316-
if (m_appModel == AppModelType::SingleFile)
317-
{
318-
result = true;
319-
}
320-
else
321-
{
322-
printf_error("InitializeDAC: dlopen(%s) FAILED %s\n", dacPath.c_str(), dlerror());
323-
}
310+
printf_error("InitializeDAC: dlopen(%s) FAILED %s\n", dacPath.c_str(), dlerror());
324311
goto exit;
325312
}
326313
pfnDllMain = (PFN_DLLMAIN)dlsym(m_dacModule, "DllMain");

src/coreclr/debug/createdump/crashinfo.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class CrashInfo : public ICLRDataEnumMemoryRegionsCallback, public ICLRDataLoggi
9393
bool Initialize();
9494
void CleanupAndResumeProcess();
9595
bool EnumerateAndSuspendThreads();
96-
bool GatherCrashInfo(DumpType* dumpType);
96+
bool GatherCrashInfo(DumpType dumpType);
9797
void CombineMemoryRegions();
9898
bool EnumerateMemoryRegionsWithDAC(DumpType dumpType);
9999
bool ReadMemory(void* address, void* buffer, size_t size); // read memory and add to dump
@@ -154,7 +154,7 @@ class CrashInfo : public ICLRDataEnumMemoryRegionsCallback, public ICLRDataLoggi
154154
void VisitProgramHeader(uint64_t loadbias, uint64_t baseAddress, ElfW(Phdr)* phdr);
155155
bool EnumerateMemoryRegions();
156156
#endif
157-
bool InitializeDAC();
157+
bool InitializeDAC(DumpType dumpType);
158158
bool EnumerateManagedModules();
159159
bool UnwindAllThreads();
160160
void AddOrReplaceModuleMapping(CLRDATA_ADDRESS baseAddress, ULONG64 size, const std::string& pszName);

src/coreclr/debug/createdump/createdump.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ typedef int T_CONTEXT;
9090
#include <array>
9191
#include <string>
9292

93-
enum DumpType
93+
enum class DumpType
9494
{
9595
Mini,
9696
Heap,
9797
Triage,
9898
Full
9999
};
100100

101-
enum AppModelType
101+
enum class AppModelType
102102
{
103103
Normal,
104104
SingleFile,

src/coreclr/debug/createdump/createdumpunix.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ bool
1414
CreateDump(const CreateDumpOptions& options)
1515
{
1616
ReleaseHolder<CrashInfo> crashInfo = new CrashInfo(options);
17-
DumpType dumpType = options.DumpType;
1817
DumpWriter dumpWriter(*crashInfo);
1918
std::string dumpPath;
2019
bool result = false;
@@ -43,7 +42,7 @@ CreateDump(const CreateDumpOptions& options)
4342
goto exit;
4443
}
4544
// Gather all the info about the process, threads (registers, etc.) and memory regions
46-
if (!crashInfo->GatherCrashInfo(&dumpType))
45+
if (!crashInfo->GatherCrashInfo(options.DumpType))
4746
{
4847
goto exit;
4948
}
@@ -61,14 +60,14 @@ CreateDump(const CreateDumpOptions& options)
6160
if (options.CreateDump)
6261
{
6362
// Gather all the useful memory regions from the DAC
64-
if (!crashInfo->EnumerateMemoryRegionsWithDAC(dumpType))
63+
if (!crashInfo->EnumerateMemoryRegionsWithDAC(options.DumpType))
6564
{
6665
goto exit;
6766
}
6867
// Join all adjacent memory regions
6968
crashInfo->CombineMemoryRegions();
7069

71-
printf_status("Writing %s to file %s\n", GetDumpTypeString(dumpType), dumpPath.c_str());
70+
printf_status("Writing %s to file %s\n", GetDumpTypeString(options.DumpType), dumpPath.c_str());
7271

7372
// Write the actual dump file
7473
if (!dumpWriter.OpenDump(dumpPath.c_str()))

0 commit comments

Comments
 (0)