def test_pfn_to_from_page(self): with self._pages() as (map, _, pfns): for i, pfn in enumerate(pfns): page = pfn_to_page(self.prog, pfn) # Test that we got the correct page by looking at the index: it # should be page i in the file. self.assertEqual(page.index, i) # Test the opposite direction. self.assertEqual(page_to_pfn(page), pfn)
def lookup_cache_by_address(obj: drgn.Object) -> Optional[drgn.Object]: pfn = virt_to_pfn(sdb.get_prog(), obj) page = pfn_to_page(pfn) cache = page.slab_cache try: # read the name to force FaultError if any _ = cache.name.string_().decode('utf-8') except drgn.FaultError: return None return cache
def test_decode_page_flags(self): with self._pages() as (map, _, pfns): page = pfn_to_page(self.prog, pfns[0]) self.assertIn("PG_swapbacked", decode_page_flags(page))