From: Thanik Kanagaratnam Date: Sat, 17 Feb 2024 19:36:15 +0000 (-0500) Subject: Added symbols loading when loading in-memory modules X-Git-Tag: accepted/tizen/unified/20240326.104902~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c36eecfd3b9bc9966c905718342043d0c44d40b;p=sdk%2Ftools%2Fnetcoredbg.git Added symbols loading when loading in-memory modules --- diff --git a/src/managed/interop.cpp b/src/managed/interop.cpp index 7c46649..7396dbf 100644 --- a/src/managed/interop.cpp +++ b/src/managed/interop.cpp @@ -111,9 +111,11 @@ constexpr char UtilsClassName[] = "NetCoreDbg.Utils"; // Returns the number of bytes read. int ReadMemoryForSymbols(uint64_t address, char *buffer, int cb) { - // TODO: In-memory PDB? - // OSPageSize() for Linux/Windows already implemented in code. - return 0; + if (address == 0 || buffer == 0 || cb == 0) + return 0; + + std::memcpy(buffer, (const void*) address, cb); + return cb; } } // unnamed namespace diff --git a/src/metadata/modules.cpp b/src/metadata/modules.cpp index 7ec0e2e..26cc23a 100644 --- a/src/metadata/modules.cpp +++ b/src/metadata/modules.cpp @@ -493,11 +493,29 @@ static HRESULT LoadSymbols(IMetaDataImport *pMD, ICorDebugModule *pModule, VOID IfFailRet(pModule->GetBaseAddress(&peAddress)); IfFailRet(pModule->GetSize(&peSize)); + std::vector peBuf; + ULONG64 peBufAddress = 0; + if (isInMemory) + { + ICorDebugProcess* process = 0; + IfFailRet(pModule->GetProcess(&process)); + + if (peAddress != 0 && peSize != 0) + { + peBuf.resize(peSize); + peBufAddress = (ULONG64)&peBuf[0]; + SIZE_T read = 0; + IfFailRet(process->ReadMemory(peAddress, peSize, &peBuf[0], &read)); + if (read != peSize) + return E_FAIL; + } + } + return Interop::LoadSymbolsForPortablePDB( GetModuleFileName(pModule), isInMemory, isInMemory, // isFileLayout - peAddress, + peBufAddress, peSize, 0, // inMemoryPdbAddress 0, // inMemoryPdbSize