[Lldb-commits] [lldb] r226742 - Implement ProcessWindows::GetMemoryRegionInfo.
Zachary Turner
zturner at google.com
Wed Jan 21 15:26:41 PST 2015
Author: zturner
Date: Wed Jan 21 17:26:40 2015
New Revision: 226742
URL: http://llvm.org/viewvc/llvm-project?rev=226742&view=rev
Log:
Implement ProcessWindows::GetMemoryRegionInfo.
Modified:
lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.cpp
lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.h
Modified: lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.cpp?rev=226742&r1=226741&r2=226742&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.cpp Wed Jan 21 17:26:40 2015
@@ -434,6 +434,44 @@ ProcessWindows::DoWriteMemory(lldb::addr
return bytes_written;
}
+Error
+ProcessWindows::GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info)
+{
+ Error error;
+ llvm::sys::ScopedLock lock(m_mutex);
+
+ if (!m_session_data)
+ {
+ error.SetErrorString("ProcessWindows::GetMemoryRegionInfo called with no debugging session.");
+ return error;
+ }
+
+ HostProcess process = m_session_data->m_debugger->GetProcess();
+ lldb::process_t handle = process.GetNativeProcess().GetSystemHandle();
+ if (handle == nullptr || handle == LLDB_INVALID_PROCESS)
+ {
+ error.SetErrorString("ProcessWindows::GetMemoryRegionInfo called with an invalid target process.");
+ return error;
+ }
+
+ void *addr = reinterpret_cast<void *>(vm_addr);
+ MEMORY_BASIC_INFORMATION mem_info = {0};
+ SIZE_T result = ::VirtualQueryEx(handle, addr, &mem_info, sizeof(mem_info));
+ if (result == 0)
+ {
+ error.SetError(::GetLastError(), eErrorTypeWin32);
+ return error;
+ }
+
+ bool readable = !(mem_info.Protect & PAGE_NOACCESS);
+ bool executable = mem_info.Protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY);
+ bool writable = mem_info.Protect & (PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY | PAGE_READWRITE | PAGE_WRITECOPY);
+ info.SetReadable(readable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+ info.SetExecutable(executable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+ info.SetWritable(writable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+ return error;
+}
+
lldb::addr_t
ProcessWindows::GetImageInfoAddress()
{
Modified: lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.h?rev=226742&r1=226741&r2=226742&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/ProcessWindows.h Wed Jan 21 17:26:40 2015
@@ -102,6 +102,7 @@ public:
size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, lldb_private::Error &error) override;
size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, lldb_private::Error &error) override;
+ lldb_private::Error GetMemoryRegionInfo(lldb::addr_t vm_addr, lldb_private::MemoryRegionInfo &info) override;
// IDebugDelegate overrides.
void OnExitProcess(uint32_t exit_code) override;
More information about the lldb-commits
mailing list