def test_container_of_named_union_long_container2(self): sym = getsym('named_union_long_container2') container = getsym('test_struct') self.assertTrue(sym.address != container.address) addr = container_of(sym, self.test_struct, 'named_union.named_union_member2') self.assertTrue(addr.address == container.address)
def test_container_of_bad_intermediate_name2(self): sym = getsym('embedded_struct_list_container') container = getsym('test_struct') self.assertTrue(sym.address != container.address) with self.assertRaises(InvalidComponentError): addr = container_of(sym, self.test_struct, 'embedded_member.good')
def test_container_of_anon_union_embedded_member2_container(self): sym = getsym('anon_union_embedded_member2_container') container = getsym('test_struct') self.assertTrue(sym.address != container.address) addr = container_of(sym, self.test_struct, 'anon_union_embedded_struct.embedded_member2') self.assertTrue(addr.address == container.address)
def test_container_of_named_union_embedded_list_container(self): sym = getsym('named_union_embedded_list_container') container = getsym('test_struct') self.assertTrue(sym.address != container.address) addr = container_of(sym, self.test_struct, 'named_union.named_union_embedded_struct.embedded_list') self.assertTrue(addr.address == container.address)
def test_container_of_embedded_struct_member1(self): sym = getsym('embedded_struct_member1_container') container = getsym('test_struct') self.assertTrue(sym.address != container.address) addr = container_of(sym, self.test_struct, 'embedded_struct_member.embedded_member1') self.assertTrue(addr.address == container.address)
def test_container_of_anon_union_long_container1(self): sym = getsym('anon_union_long_container1') container = getsym('test_struct') addr = container_of(sym, self.test_struct, 'anon_union_member1') self.assertTrue(sym.address != container.address) self.assertTrue(addr.address == container.address)
def dev_to_gendisk(self, dev): return container_of(dev, self.gendisk_type, 'part0.__dev')
def test_container_of_long_container(self): sym = getsym('long_container') container = getsym('test_struct') addr = container_of(sym, self.test_struct, 'test_member') self.assertTrue(addr.address == container.address)
def klist_for_each_entry(self, klist, gdbtype, member): for node in klist_for_each(klist): if node.type != self.klist_node_type: raise TypeError("Type {} found. Expected {}.".format(node.type), self.klist_node_type.pointer()) yield container_of(node, gdbtype, member)
def real_mount(cls, vfsmnt): if (vfsmnt.type == cls.mount_type or vfsmnt.type == cls.mount_type.pointer()): return vfsmnt return container_of(vfsmnt, cls.mount_type, 'mnt')
def test_container_of_bad_type(self): sym = getsym('embedded_struct_list_container') container = getsym('test_struct') self.assertTrue(sym.address != container.address) with self.assertRaises(InvalidArgumentTypeError): addr = container_of(sym, self.ulong, 'test_member')
def test_container_of_bad_intermediate_name2(self): sym = getsym('embedded_struct_list_container') container = getsym('test_struct') self.assertTrue(sym.address != container.address) with self.assertRaises(InvalidComponentError): addr = container_of(sym, self.test_struct, 'embedded_member.good')
def test_container_of_embedded_struct_list(self): sym = getsym('embedded_struct_list_container') container = getsym('test_struct') self.assertTrue(sym.address != container.address) addr = container_of(sym, self.test_struct, 'embedded_struct_member.embedded_list')
def real_mount(cls, vfsmnt): if (vfsmnt.type == cls.mount_type or vfsmnt.type == cls.mount_type.pointer()): return vfsmnt return container_of(vfsmnt, cls.mount_type, 'mnt')
def from_list_head(cls, list_head, kmem_cache): gdb_obj = container_of(list_head, cls.real_slab_type, cls.slab_list_head) return Slab(gdb_obj, kmem_cache)
def dev_to_part(self, dev): return container_of(dev, self.hd_struct_type, '__dev')
def _get_clone_bio_tio_3_15(self, bio: gdb.Value) -> gdb.Value: return container_of(bio['bi_private'], self._types.dm_clone_bio_info_p_type, 'clone')
def _get_clone_bio_rq_info_3_7(self, bio: gdb.Value) -> gdb.Value: return container_of(bio, self._types.dm_rq_clone_bio_info_p_type, 'clone')
def test_container_of_bad_type(self): sym = getsym('embedded_struct_list_container') container = getsym('test_struct') self.assertTrue(sym.address != container.address) with self.assertRaises(InvalidArgumentTypeError): addr = container_of(sym, self.ulong, 'test_member')
def test_container_of_sym(self): sym = gdb.lookup_symbol("test_struct", None)[0] with self.assertRaises(TypeError): print(container_of(sym, None, None))
def test_container_of_sym(self): sym = gdb.lookup_symbol("test_struct", None)[0] with self.assertRaises(TypeError): print(container_of(sym, None, None))
def test_container_of_long_container(self): sym = getsym('long_container') container = getsym('test_struct') addr = container_of(sym, self.test_struct, 'test_member') self.assertTrue(addr.address == container.address)
def test_container_of_anon_struct_long_container1(self): sym = getsym('anon_struct_long_container1') container = getsym('test_struct') addr = container_of(sym, self.test_struct, 'anon_struct_member1') self.assertTrue(sym.address != container.address) self.assertTrue(addr.address == container.address)
def inode_to_block_device(self, inode): if inode['i_sb'] != self.blockdev_superblock: raise TypeError("inode does not correspond to block device") return container_of(inode, self.bdev_inode_type, 'vfs_inode')['bdev']