Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added symbols loading when loading in-memory modules #164

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
8 changes: 5 additions & 3 deletions src/managed/interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 19 additions & 1 deletion src/metadata/modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,29 @@ static HRESULT LoadSymbols(IMetaDataImport *pMD, ICorDebugModule *pModule, VOID
IfFailRet(pModule->GetBaseAddress(&peAddress));
IfFailRet(pModule->GetSize(&peSize));

std::vector<unsigned char> peBuf;
ULONG64 peBufAddress = 0;
if (isInMemory)
{
ToRelease<ICorDebugProcess> process;
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
Expand Down