Page MenuHomePhabricator

Implement GetMemoryRegions() for Windows Minidumps and live processes.
ClosedPublic

Authored by hhellyer on Jul 14 2016, 6:43 AM.

Details

Summary

This patch fills in the implementation of GetMemoryRegions() on the Windows live process and minidump implementations of lldb_private::Process (ProcessWindowsLive::GetMemoryRegionInfo and ProcessWinMiniDump::Impl::GetMemoryRegionInfo.) The GetMemoryRegions API was added under: http://reviews.llvm.org/D20565

The existing Windows implementations didn’t fill in the start and end addresses within MemoryRegionInfo. This patch fixes that and adds support for the new mapped flag on MemoryRegionInfo that says whether a memory range is mapped into the process address space or not.

The behaviour of both live and core implementations should match the behaviour documented on Process::GetMemoryRegionInfo (in Process.h) which in turn should match the behaviour of the qMemoryRegionInfo query documented in lldb-gdb-remote.txt.

Diff Detail

Event Timeline

hhellyer updated this revision to Diff 63968.Jul 14 2016, 6:43 AM
hhellyer retitled this revision from to Implement GetMemoryRegions() for Windows Minidumps and live processes..
hhellyer updated this object.
hhellyer added a reviewer: clayborg.
hhellyer added a subscriber: lldb-commits.

Arcanist won't upload the patch without the change to .arcconfig yet because of http://lists.llvm.org/pipermail/llvm-dev/2016-July/102305.html but I think this will be patched officially shortly! It should disappear if I update the revision for any reason once that's happened.

amccarth added inline comments.
source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
338

I'm not clear why you deleted the SetErrorString call.

hhellyer updated this revision to Diff 63975.Jul 14 2016, 7:59 AM

.arcconfig has been updated.

hhellyer added inline comments.Jul 14 2016, 8:10 AM
source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
338

Asking for an address outside a known range is not actually an error, you just get back an unmapped range that specifies how far it is to the next mapped range.
The original discussion about that happened here: https://reviews.llvm.org/D21751 - GetMemoryRegionInfo should only need to return an error if it is unimplemented. (I should probably have referenced that in the summary.)

clayborg accepted this revision.Jul 14 2016, 11:40 AM
clayborg edited edge metadata.
This revision is now accepted and ready to land.Jul 14 2016, 11:40 AM
amccarth added inline comments.Jul 14 2016, 11:49 AM
source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
338

Got it. Thanks for the explanation!

Given that, should the condition on 284 ("the mini dump contains no memory range information") actually return an error or just an unmapped range?

hhellyer added inline comments.Jul 15 2016, 1:11 AM
source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
338

I thought the most likely cause of having no memory info would be not passing the MiniDumpWithFullMemoryInfo flag to MiniDumpWriteDump will create a dump without the MemoryInfoListStream present. Saying that memory range information from a dump like that is "unsupported" seemed like the right option. I think MiniDumpWithFullMemoryInfo is part of the default set of flags used when you create a dump through task manager so most dumps should have the stream.

I won't land the patch immediately, I'm happy to change it if you'd prefer it to return an unmapped range. I think it would have to be one unmapped range that ran from load_addr to LLDB_INVALID_ADDRESS to match the expected behaviour.

amccarth accepted this revision.Jul 15 2016, 8:13 AM
amccarth added a reviewer: amccarth.

LGTM. Thanks!

source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
338

Sounds like you've thought it through more thoroughly than I, and I agree with your conclusions, so I have no objections. Thanks for the explanations.

hhellyer closed this revision.Jul 18 2016, 1:33 AM