13427cb5bSPavel Labathimport lldb 23427cb5bSPavel Labathfrom lldbsuite.test.lldbtest import * 33427cb5bSPavel Labathfrom lldbsuite.test.decorators import * 43427cb5bSPavel Labathfrom lldbsuite.test.gdbclientutils import * 53427cb5bSPavel Labathfrom lldbsuite.test.lldbgdbclient import GDBRemoteTestBase 63427cb5bSPavel Labath 73427cb5bSPavel Labath 83427cb5bSPavel Labathclass TestGdbClientMemoryRegions(GDBRemoteTestBase): 93427cb5bSPavel Labath def test(self): 103427cb5bSPavel Labath """ 113427cb5bSPavel Labath Test handling of overflowing memory regions. In particular, make sure 123427cb5bSPavel Labath they don't trigger an infinite loop. 133427cb5bSPavel Labath """ 143427cb5bSPavel Labath 15*2238dcc3SJonas Devlieghere class MyResponder(MockGDBServerResponder): 163427cb5bSPavel Labath def qHostInfo(self): 173427cb5bSPavel Labath return "ptrsize:8;endian:little;" 183427cb5bSPavel Labath 193427cb5bSPavel Labath def qMemoryRegionInfo(self, addr): 203427cb5bSPavel Labath if addr == 0: 213427cb5bSPavel Labath return "start:0;size:8000000000000000;permissions:rw;" 223427cb5bSPavel Labath if addr == 0x8000000000000000: 233427cb5bSPavel Labath return "start:8000000000000000;size:8000000000000000;permissions:r;" 243427cb5bSPavel Labath 253427cb5bSPavel Labath self.runCmd("log enable gdb-remote packets") 263427cb5bSPavel Labath self.runCmd("log enable lldb temp") 273427cb5bSPavel Labath self.server.responder = MyResponder() 28*2238dcc3SJonas Devlieghere target = self.dbg.CreateTarget("") 293427cb5bSPavel Labath process = self.connect(target) 303427cb5bSPavel Labath 313427cb5bSPavel Labath regions = process.GetMemoryRegions() 323427cb5bSPavel Labath self.assertEqual(regions.GetSize(), 2) 333427cb5bSPavel Labath 343427cb5bSPavel Labath region = lldb.SBMemoryRegionInfo() 353427cb5bSPavel Labath self.assertTrue(regions.GetMemoryRegionAtIndex(0, region)) 363427cb5bSPavel Labath self.assertEqual(region.GetRegionBase(), 0) 373427cb5bSPavel Labath self.assertEqual(region.GetRegionEnd(), 0x8000000000000000) 383427cb5bSPavel Labath self.assertTrue(region.IsWritable()) 393427cb5bSPavel Labath 403427cb5bSPavel Labath self.assertTrue(regions.GetMemoryRegionAtIndex(1, region)) 413427cb5bSPavel Labath self.assertEqual(region.GetRegionBase(), 0x8000000000000000) 42*2238dcc3SJonas Devlieghere self.assertEqual(region.GetRegionEnd(), 0xFFFFFFFFFFFFFFFF) 433427cb5bSPavel Labath self.assertFalse(region.IsWritable()) 44