Beispiel #1
0
 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)
Beispiel #2
0
 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')
Beispiel #3
0
 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)
Beispiel #4
0
 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)
Beispiel #5
0
 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)
Beispiel #6
0
 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)
Beispiel #7
0
 def dev_to_gendisk(self, dev):
     return container_of(dev, self.gendisk_type, 'part0.__dev')
Beispiel #8
0
 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)
Beispiel #9
0
 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)
Beispiel #10
0
 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')
Beispiel #11
0
 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')
Beispiel #12
0
 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')
Beispiel #13
0
 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')
Beispiel #14
0
 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')
Beispiel #15
0
 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)
Beispiel #16
0
 def dev_to_part(self, dev):
     return container_of(dev, self.hd_struct_type, '__dev')
Beispiel #17
0
 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')
Beispiel #18
0
 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')
Beispiel #19
0
 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')
Beispiel #20
0
 def test_container_of_sym(self):
     sym = gdb.lookup_symbol("test_struct", None)[0]
     with self.assertRaises(TypeError):
         print(container_of(sym, None, None))
Beispiel #21
0
 def test_container_of_sym(self):
     sym = gdb.lookup_symbol("test_struct", None)[0]
     with self.assertRaises(TypeError):
         print(container_of(sym, None, None))
Beispiel #22
0
 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)
Beispiel #23
0
 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)
Beispiel #24
0
 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']