示例#1
0
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
示例#2
0
文件: test_mm.py 项目: pzakha/drgn
 def test_virt_to_from_pfn(self):
     with self._pages() as (map, _, pfns):
         for i, pfn in enumerate(pfns):
             virt = pfn_to_virt(self.prog, pfn)
             # Test that we got the correct virtual address by reading from
             # it and comparing it to the mmap.
             self.assertEqual(
                 self.prog.read(virt, mmap.PAGESIZE),
                 map[i * mmap.PAGESIZE : (i + 1) * mmap.PAGESIZE],
             )
             # Test the opposite direction.
             self.assertEqual(virt_to_pfn(virt), pfn)