diff --git a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp --- a/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp +++ b/lldb/source/Plugins/Process/Windows/Common/ProcessDebugger.cpp @@ -441,7 +441,7 @@ // AllocationBase is defined for MEM_COMMIT and MEM_RESERVE but not MEM_FREE. if (mem_info.State != MEM_FREE) { info.GetRange().SetRangeBase( - reinterpret_cast(mem_info.AllocationBase)); + reinterpret_cast(mem_info.BaseAddress)); info.GetRange().SetRangeEnd(reinterpret_cast(mem_info.BaseAddress) + mem_info.RegionSize); info.SetMapped(MemoryRegionInfo::eYes); diff --git a/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py b/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py --- a/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py +++ b/lldb/test/API/functionalities/memory-region/TestMemoryRegion.py @@ -27,7 +27,7 @@ substrs=["memory region ", "memory region -a"]) - def test(self): + def setup_program(self): self.build() # Set breakpoint in main and run @@ -37,6 +37,9 @@ self.runCmd("run", RUN_SUCCEEDED) + def test_command(self): + self.setup_program() + interp = self.dbg.GetCommandInterpreter() result = lldb.SBCommandReturnObject() @@ -84,3 +87,23 @@ interp.HandleCommand("memory region --all", result) self.assertTrue(result.Succeeded()) self.assertEqual(result.GetOutput(), all_regions) + + def test_unique_base_addresses(self): + # In the past on Windows we were recording AllocationBase as the base address + # of the current region, not BaseAddress. So if a range of pages was split + # into regions you would see several regions with the same base address. + # This checks that this no longer happens (and it shouldn't happen on any + # other OS either). + self.setup_program() + + process = self.dbg.GetTargetAtIndex(0).GetProcess() + regions = process.GetMemoryRegions() + base_addresses = set() + + for idx in range(regions.GetSize()): + region = lldb.SBMemoryRegionInfo() + regions.GetMemoryRegionAtIndex(idx, region) + base_address = region.GetRegionBase() + self.assertFalse(base_address in base_addresses, + "Did not expect to see a repeated base region address.") + base_addresses.add(base_address) \ No newline at end of file