Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike McLaughlin <mikem@microsoft.com>2022-07-17 05:49:16 +0300
committerGitHub <noreply@github.com>2022-07-17 05:49:16 +0300
commitcd5e461e91e62756e55ba0aa6689bb73b2f87f2e (patch)
treeb7af0e9457dba14c760a8976a8cfea0a1b133871 /src/coreclr/debug
parent072eda8d6b2c24ba4c7691a780546a2d6691b1a4 (diff)
Properly calculate the ELF unwind info section size (#72146)
Properly calculate the ELF unwind info section size Uses the same method that windbg does to calculate the eh_frame section size by partial decoding the FDE/CIE's enough to figure out the total size. We can't use the .eh_frame section because ELF module sections are not in-memory. Change the ReadMemoryAdapter passed to the new PAL_GetUnwindInfoSize function to read memory directly and not add it to the memory region list
Diffstat (limited to 'src/coreclr/debug')
-rw-r--r--src/coreclr/debug/createdump/crashinfounix.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/src/coreclr/debug/createdump/crashinfounix.cpp b/src/coreclr/debug/createdump/crashinfounix.cpp
index 51a0e319e1a..d7e93bdc7a2 100644
--- a/src/coreclr/debug/createdump/crashinfounix.cpp
+++ b/src/coreclr/debug/createdump/crashinfounix.cpp
@@ -3,6 +3,12 @@
#include "createdump.h"
+#ifndef PT_ARM_EXIDX
+#define PT_ARM_EXIDX 0x70000001 /* See llvm ELF.h */
+#endif
+
+extern CrashInfo* g_crashInfo;
+
int g_readProcessMemoryErrno = 0;
bool GetStatus(pid_t pid, pid_t* ppid, pid_t* tgid, std::string* name);
@@ -334,6 +340,14 @@ CrashInfo::VisitModule(uint64_t baseAddress, std::string& moduleName)
EnumerateProgramHeaders(baseAddress);
}
+// Helper for PAL_GetUnwindInfoSize. Reads memory directly without adding it to the memory region list.
+BOOL
+ReadMemoryAdapter(PVOID address, PVOID buffer, SIZE_T size)
+{
+ size_t read = 0;
+ return g_crashInfo->ReadProcessMemory(address, buffer, size, &read);
+}
+
//
// Called for each program header adding the build id note, unwind frame
// region and module addresses to the crash info.
@@ -345,12 +359,40 @@ CrashInfo::VisitProgramHeader(uint64_t loadbias, uint64_t baseAddress, Phdr* phd
{
case PT_DYNAMIC:
case PT_NOTE:
- case PT_GNU_EH_FRAME:
- if (phdr->p_vaddr != 0 && phdr->p_memsz != 0) {
+#if defined(TARGET_ARM)
+ case PT_ARM_EXIDX:
+#endif
+ if (phdr->p_vaddr != 0 && phdr->p_memsz != 0)
+ {
InsertMemoryRegion(loadbias + phdr->p_vaddr, phdr->p_memsz);
}
break;
+ case PT_GNU_EH_FRAME:
+ if (phdr->p_vaddr != 0 && phdr->p_memsz != 0)
+ {
+ uint64_t ehFrameHdrStart = loadbias + phdr->p_vaddr;
+ uint64_t ehFrameHdrSize = phdr->p_memsz;
+ TRACE("VisitProgramHeader: ehFrameHdrStart %016llx ehFrameHdrSize %08llx\n", ehFrameHdrStart, ehFrameHdrSize);
+ InsertMemoryRegion(ehFrameHdrStart, ehFrameHdrSize);
+
+ uint64_t ehFrameStart;
+ uint64_t ehFrameSize;
+ if (PAL_GetUnwindInfoSize(baseAddress, ehFrameHdrStart, ReadMemoryAdapter, &ehFrameStart, &ehFrameSize))
+ {
+ TRACE("VisitProgramHeader: ehFrameStart %016llx ehFrameSize %08llx\n", ehFrameStart, ehFrameSize);
+ if (ehFrameStart != 0 && ehFrameSize != 0)
+ {
+ InsertMemoryRegion(ehFrameStart, ehFrameSize);
+ }
+ }
+ else
+ {
+ TRACE("VisitProgramHeader: PAL_GetUnwindInfoSize FAILED\n");
+ }
+ }
+ break;
+
case PT_LOAD:
AddModuleAddressRange(loadbias + phdr->p_vaddr, loadbias + phdr->p_vaddr + phdr->p_memsz, baseAddress);
break;