[Lldb-commits] [lldb] 0df5229 - Revert "Reland "[lldb] Remove non address bits when looking up memory regions""
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Fri Nov 26 07:35:21 PST 2021
Author: David Spickett
Date: 2021-11-26T15:35:02Z
New Revision: 0df522969a7a0128052bd79182c8d58e00556e2f
URL: https://github.com/llvm/llvm-project/commit/0df522969a7a0128052bd79182c8d58e00556e2f
DIFF: https://github.com/llvm/llvm-project/commit/0df522969a7a0128052bd79182c8d58e00556e2f.diff
LOG: Revert "Reland "[lldb] Remove non address bits when looking up memory regions""
This reverts commit fac3f20de55769d028bd92220e74f22fa57dd4b2.
I found this has broken how we detect the last memory region in
GetMemoryRegions/"memory region" command.
When you're debugging an AArch64 system with pointer authentication,
the ABI plugin will remove the top bit from the end address of the last
user mapped area.
(lldb)
[0x0000fffffffdf000-0x0001000000000000) rw- [stack]
ABI plugin removes anything above the 48th bit (48 bit virtual addresses
by default on AArch64, leaving an address of 0.
(lldb)
[0x0000000000000000-0x0000000000400000) ---
You get back a mapping for 0 and get into an infinite loop.
Added:
Modified:
lldb/include/lldb/Target/Process.h
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.h
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h
lldb/source/Target/Process.cpp
Removed:
lldb/test/API/linux/aarch64/tagged_memory_region/Makefile
lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py
lldb/test/API/linux/aarch64/tagged_memory_region/main.c
################################################################################
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 4627502abd25d..e27cb8cbf2aa4 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -1762,7 +1762,7 @@ class Process : public std::enable_shared_from_this<Process>,
///
/// If load_addr is within the address space the process has mapped
/// range_info will be filled in with the start and end of that range as
- /// well as the permissions for that range and range_info. GetMapped will
+ /// well as the permissions for that range and range_info.GetMapped will
/// return true.
///
/// If load_addr is outside any mapped region then range_info will have its
@@ -1771,21 +1771,23 @@ class Process : public std::enable_shared_from_this<Process>,
/// there are no valid mapped ranges between load_addr and the end of the
/// process address space.
///
- /// GetMemoryRegionInfo calls DoGetMemoryRegionInfo. Override that function in
- /// process subclasses.
+ /// GetMemoryRegionInfo will only return an error if it is unimplemented for
+ /// the current process.
///
/// \param[in] load_addr
- /// The load address to query the range_info for. May include non
- /// address bits, these will be removed by the the ABI plugin if there is
- /// one.
+ /// The load address to query the range_info for.
///
/// \param[out] range_info
/// An range_info value containing the details of the range.
///
/// \return
/// An error value.
- Status GetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo &range_info);
+ virtual Status GetMemoryRegionInfo(lldb::addr_t load_addr,
+ MemoryRegionInfo &range_info) {
+ Status error;
+ error.SetErrorString("Process::GetMemoryRegionInfo() not supported");
+ return error;
+ }
/// Obtain all the mapped memory regions within this process.
///
@@ -2605,26 +2607,6 @@ void PruneThreadPlans();
virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
Status &error) = 0;
- /// DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has
- /// removed non address bits from load_addr. Override this method in
- /// subclasses of Process.
- ///
- /// See GetMemoryRegionInfo for details of the logic.
- ///
- /// \param[in] load_addr
- /// The load address to query the range_info for. (non address bits
- /// removed)
- ///
- /// \param[out] range_info
- /// An range_info value containing the details of the range.
- ///
- /// \return
- /// An error value.
- virtual Status DoGetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo &range_info) {
- return Status("Process::DoGetMemoryRegionInfo() not supported");
- }
-
lldb::StateType GetPrivateState();
/// The "private" side of resuming a process. This doesn't alter the state
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index f6e89bb0662a3..97ba1bdc9ee9e 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -601,8 +601,8 @@ Status ProcessWindows::DoDeallocateMemory(lldb::addr_t ptr) {
return ProcessDebugger::DeallocateMemory(ptr);
}
-Status ProcessWindows::DoGetMemoryRegionInfo(lldb::addr_t vm_addr,
- MemoryRegionInfo &info) {
+Status ProcessWindows::GetMemoryRegionInfo(lldb::addr_t vm_addr,
+ MemoryRegionInfo &info) {
return ProcessDebugger::GetMemoryRegionInfo(vm_addr, info);
}
diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
index 6f6f93f588e33..fc83649818edd 100644
--- a/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
+++ b/lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
@@ -78,6 +78,8 @@ class ProcessWindows : public Process, public ProcessDebugger {
lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions,
Status &error) override;
Status DoDeallocateMemory(lldb::addr_t ptr) override;
+ Status GetMemoryRegionInfo(lldb::addr_t vm_addr,
+ MemoryRegionInfo &info) override;
lldb::addr_t GetImageInfoAddress() override;
@@ -101,10 +103,6 @@ class ProcessWindows : public Process, public ProcessDebugger {
Status EnableWatchpoint(Watchpoint *wp, bool notify = true) override;
Status DisableWatchpoint(Watchpoint *wp, bool notify = true) override;
-protected:
- Status DoGetMemoryRegionInfo(lldb::addr_t vm_addr,
- MemoryRegionInfo &info) override;
-
private:
struct WatchpointInfo {
uint32_t slot_id;
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 23b346d5c17f1..b852a01643753 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -281,8 +281,8 @@ size_t ProcessElfCore::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
return DoReadMemory(addr, buf, size, error);
}
-Status ProcessElfCore::DoGetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo ®ion_info) {
+Status ProcessElfCore::GetMemoryRegionInfo(lldb::addr_t load_addr,
+ MemoryRegionInfo ®ion_info) {
region_info.Clear();
const VMRangeToPermissions::Entry *permission_entry =
m_core_range_infos.FindEntryThatContainsOrFollows(load_addr);
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
index fd36e50278168..67df3c5fac76a 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -86,6 +86,10 @@ class ProcessElfCore : public lldb_private::PostMortemProcess {
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
lldb_private::Status &error) override;
+ lldb_private::Status
+ GetMemoryRegionInfo(lldb::addr_t load_addr,
+ lldb_private::MemoryRegionInfo ®ion_info) override;
+
lldb::addr_t GetImageInfoAddress() override;
lldb_private::ArchSpec GetArchitecture();
@@ -101,10 +105,6 @@ class ProcessElfCore : public lldb_private::PostMortemProcess {
bool DoUpdateThreadList(lldb_private::ThreadList &old_thread_list,
lldb_private::ThreadList &new_thread_list) override;
- lldb_private::Status
- DoGetMemoryRegionInfo(lldb::addr_t load_addr,
- lldb_private::MemoryRegionInfo ®ion_info) override;
-
private:
struct NT_FILE_Entry {
lldb::addr_t start;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 3e6cf495cf031..3ade8c815febb 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2877,8 +2877,8 @@ lldb::addr_t ProcessGDBRemote::DoAllocateMemory(size_t size,
return allocated_addr;
}
-Status ProcessGDBRemote::DoGetMemoryRegionInfo(addr_t load_addr,
- MemoryRegionInfo ®ion_info) {
+Status ProcessGDBRemote::GetMemoryRegionInfo(addr_t load_addr,
+ MemoryRegionInfo ®ion_info) {
Status error(m_gdb_comm.GetMemoryRegionInfo(load_addr, region_info));
return error;
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 9b0ae6507b6e7..488336b8c1b85 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -144,6 +144,9 @@ class ProcessGDBRemote : public Process,
lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions,
Status &error) override;
+ Status GetMemoryRegionInfo(lldb::addr_t load_addr,
+ MemoryRegionInfo ®ion_info) override;
+
Status DoDeallocateMemory(lldb::addr_t ptr) override;
// Process STDIO
@@ -417,9 +420,6 @@ class ProcessGDBRemote : public Process,
Status DoWriteMemoryTags(lldb::addr_t addr, size_t len, int32_t type,
const std::vector<uint8_t> &tags) override;
- Status DoGetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo ®ion_info) override;
-
private:
// For ProcessGDBRemote only
std::string m_partial_profile_data;
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
index 59c04590672d3..6aed04565eb01 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -633,8 +633,8 @@ size_t ProcessMachCore::DoReadMemory(addr_t addr, void *buf, size_t size,
return bytes_read;
}
-Status ProcessMachCore::DoGetMemoryRegionInfo(addr_t load_addr,
- MemoryRegionInfo ®ion_info) {
+Status ProcessMachCore::GetMemoryRegionInfo(addr_t load_addr,
+ MemoryRegionInfo ®ion_info) {
region_info.Clear();
const VMRangeToPermissions::Entry *permission_entry =
m_core_range_infos.FindEntryThatContainsOrFollows(load_addr);
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
index b5ca515a7d3fb..e55bfcfcc723b 100644
--- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
+++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.h
@@ -68,6 +68,10 @@ class ProcessMachCore : public lldb_private::PostMortemProcess {
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
lldb_private::Status &error) override;
+ lldb_private::Status
+ GetMemoryRegionInfo(lldb::addr_t load_addr,
+ lldb_private::MemoryRegionInfo ®ion_info) override;
+
lldb::addr_t GetImageInfoAddress() override;
protected:
@@ -80,10 +84,6 @@ class ProcessMachCore : public lldb_private::PostMortemProcess {
lldb_private::ObjectFile *GetCoreObjectFile();
- lldb_private::Status
- DoGetMemoryRegionInfo(lldb::addr_t load_addr,
- lldb_private::MemoryRegionInfo ®ion_info) override;
-
private:
bool GetDynamicLoaderAddress(lldb::addr_t addr);
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
index 736cfa0700886..08cf58b0a84a1 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -439,8 +439,8 @@ void ProcessMinidump::BuildMemoryRegions() {
llvm::sort(*m_memory_regions);
}
-Status ProcessMinidump::DoGetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo ®ion) {
+Status ProcessMinidump::GetMemoryRegionInfo(lldb::addr_t load_addr,
+ MemoryRegionInfo ®ion) {
BuildMemoryRegions();
region = MinidumpParser::GetMemoryRegionInfo(*m_memory_regions, load_addr);
return Status();
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.h b/lldb/source/Plugins/Process/minidump/ProcessMinidump.h
index 5360269199cdd..3501d38a0f27e 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.h
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.h
@@ -75,6 +75,9 @@ class ProcessMinidump : public PostMortemProcess {
ArchSpec GetArchitecture();
+ Status GetMemoryRegionInfo(lldb::addr_t load_addr,
+ MemoryRegionInfo &range_info) override;
+
Status GetMemoryRegions(
lldb_private::MemoryRegionInfos ®ion_list) override;
@@ -95,9 +98,6 @@ class ProcessMinidump : public PostMortemProcess {
bool DoUpdateThreadList(ThreadList &old_thread_list,
ThreadList &new_thread_list) override;
- Status DoGetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo &range_info) override;
-
void ReadModuleList();
lldb::ModuleSP GetOrCreateModule(lldb_private::UUID minidump_uuid,
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index 15d3d43d99937..c1b7294a7f586 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -248,8 +248,8 @@ ArchSpec ScriptedProcess::GetArchitecture() {
return GetTarget().GetArchitecture();
}
-Status ScriptedProcess::DoGetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo ®ion) {
+Status ScriptedProcess::GetMemoryRegionInfo(lldb::addr_t load_addr,
+ MemoryRegionInfo ®ion) {
CheckInterpreterAndScriptObject();
Status error;
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
index c8355f35548a8..d56658a2e48af 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -84,6 +84,9 @@ class ScriptedProcess : public Process {
ArchSpec GetArchitecture();
+ Status GetMemoryRegionInfo(lldb::addr_t load_addr,
+ MemoryRegionInfo &range_info) override;
+
Status
GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list) override;
@@ -97,9 +100,6 @@ class ScriptedProcess : public Process {
bool DoUpdateThreadList(ThreadList &old_thread_list,
ThreadList &new_thread_list) override;
- Status DoGetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo &range_info) override;
-
private:
friend class ScriptedThread;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 84dc2b94a0eb3..94f378886e50e 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -5853,13 +5853,6 @@ Process::AdvanceAddressToNextBranchInstruction(Address default_stop_addr,
return retval;
}
-Status Process::GetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo &range_info) {
- if (auto abi = GetABI())
- load_addr = abi->FixDataAddress(load_addr);
- return DoGetMemoryRegionInfo(load_addr, range_info);
-}
-
Status
Process::GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list) {
diff --git a/lldb/test/API/linux/aarch64/tagged_memory_region/Makefile b/lldb/test/API/linux/aarch64/tagged_memory_region/Makefile
deleted file mode 100644
index 10495940055b6..0000000000000
--- a/lldb/test/API/linux/aarch64/tagged_memory_region/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := main.c
-
-include Makefile.rules
diff --git a/lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py b/lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py
deleted file mode 100644
index b175f6234b10b..0000000000000
--- a/lldb/test/API/linux/aarch64/tagged_memory_region/TestAArch64LinuxTaggedMemoryRegion.py
+++ /dev/null
@@ -1,42 +0,0 @@
-"""
-Test that "memory region" lookup uses the ABI plugin to remove
-non address bits from addresses before lookup.
-"""
-
-
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class AArch64LinuxTaggedMemoryRegionTestCase(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- NO_DEBUG_INFO_TESTCASE = True
-
- # AArch64 Linux always enables the top byte ignore feature
- @skipUnlessArch("aarch64")
- @skipUnlessPlatform(["linux"])
- def test_mte_regions(self):
- self.build()
- self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
-
- lldbutil.run_break_set_by_file_and_line(self, "main.c",
- line_number('main.c', '// Set break point at this line.'),
- num_expected_locations=1)
-
- self.runCmd("run", RUN_SUCCEEDED)
-
- if self.process().GetState() == lldb.eStateExited:
- self.fail("Test program failed to run.")
-
- self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
- substrs=['stopped',
- 'stop reason = breakpoint'])
-
- # Despite the non address bits we should find a region
- self.expect("memory region the_page", patterns=[
- "\[0x[0-9A-Fa-f]+-0x[0-9A-Fa-f]+\) r-x"])
diff --git a/lldb/test/API/linux/aarch64/tagged_memory_region/main.c b/lldb/test/API/linux/aarch64/tagged_memory_region/main.c
deleted file mode 100644
index 29f99d73e12d1..0000000000000
--- a/lldb/test/API/linux/aarch64/tagged_memory_region/main.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <asm/hwcap.h>
-#include <sys/auxv.h>
-#include <sys/mman.h>
-#include <unistd.h>
-
-int main(int argc, char const *argv[]) {
- void *the_page = mmap(0, sysconf(_SC_PAGESIZE), PROT_READ | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- if (the_page == MAP_FAILED)
- return 1;
-
- // Put something in the top byte (AArch64 Linux always enables top byte
- // ignore)
- the_page = (void *)((size_t)the_page | ((size_t)0x34 << 56));
-
- return 0; // Set break point at this line.
-}
More information about the lldb-commits
mailing list