How to use the drgn.typename.BasicTypeName function in drgn

To help you get started, we’ve selected a few drgn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github osandov / drgn / tests / test_typename.py View on Github external
def test_array_of_const_pointers_to_functions(self):
        self.assertEqual(str(ArrayTypeName(PointerTypeName(FunctionTypeName(BasicTypeName('int'), [(BasicTypeName('int'), None)]), qualifiers={'const'}), None)),
                         'int (* const [])(int)')
github osandov / drgn / tests / test_typename.py View on Github external
def test_pointer_to_function(self):
        self.assertEqual(str(PointerTypeName(FunctionTypeName(BasicTypeName('int'), [(BasicTypeName('int'), None)]))),
                         'int (*)(int)')
        self.assertEqual(str(PointerTypeName(FunctionTypeName(BasicTypeName('int'), [(BasicTypeName('int'), 'x')]))),
                         'int (*)(int x)')
        self.assertEqual(str(PointerTypeName(FunctionTypeName(BasicTypeName('int'), [(BasicTypeName('int'), None), (BasicTypeName('float'), None)]))),
                         'int (*)(int, float)')
github osandov / drgn / tests / test_typename.py View on Github external
def test_basic_types(self):
        self.assertEqual(str(BasicTypeName('char')), 'char')
        self.assertEqual(str(BasicTypeName('int')), 'int')
        self.assertEqual(str(BasicTypeName('float')), 'float')
        self.assertEqual(str(BasicTypeName('double')), 'double')
        self.assertEqual(str(BasicTypeName('_Bool')), '_Bool')
github osandov / drgn / tests / test_typename.py View on Github external
def test_size(self):
        self.assertEqual(str(BasicTypeName('long')), 'long')
        self.assertEqual(str(BasicTypeName('long long')), 'long long')
        self.assertEqual(str(BasicTypeName('short')), 'short')
        self.assertEqual(str(BasicTypeName('long double')), 'long double')
github osandov / drgn / tests / test_typename.py View on Github external
def test_pointer_to_function_returning_const_pointer(self):
        self.assertEqual(str(PointerTypeName(FunctionTypeName(PointerTypeName(BasicTypeName('int'), qualifiers={'const'}), [(BasicTypeName('int'), None)]))),
                         'int * const (*)(int)')
github osandov / drgn / tests / test_typename.py View on Github external
def test_sign(self):
        self.assertEqual(parse_type_name('signed int'), BasicTypeName('int'))
        self.assertEqual(parse_type_name('signed'), BasicTypeName('int'))
        self.assertEqual(parse_type_name('int signed'), BasicTypeName('int'))

        self.assertEqual(parse_type_name('unsigned'),
                         BasicTypeName('unsigned int'))
        self.assertEqual(parse_type_name('unsigned int'),
                         BasicTypeName('unsigned int'))
        self.assertEqual(parse_type_name('unsigned'),
                         BasicTypeName('unsigned int'))
        self.assertEqual(parse_type_name('int unsigned'),
                         BasicTypeName('unsigned int'))

        self.assertEqual(parse_type_name('signed char'),
                         BasicTypeName('signed char'))
        self.assertEqual(parse_type_name('char signed'),
                         BasicTypeName('signed char'))

        self.assertEqual(parse_type_name('unsigned char'),
github osandov / drgn / tests / test_typename.py View on Github external
def test_pointer_to_pointer_to_array(self):
        self.assertEqual(str(PointerTypeName(PointerTypeName(ArrayTypeName(BasicTypeName('int'), 2)))),
                         'int (**)[2]')
github osandov / drgn / tests / test_typename.py View on Github external
def test_array(self):
        self.assertEqual(parse_type_name('int []'),
                         ArrayTypeName(BasicTypeName('int'), None))
        self.assertEqual(parse_type_name('int [2]'),
                         ArrayTypeName(BasicTypeName('int'), 2))
        self.assertEqual(parse_type_name('int [0x10]'),
                         ArrayTypeName(BasicTypeName('int'), 16))
        self.assertEqual(parse_type_name('int [010]'),
                         ArrayTypeName(BasicTypeName('int'), 8))
        self.assertEqual(parse_type_name('int [2][3]'),
                         ArrayTypeName(ArrayTypeName(BasicTypeName('int'), 3), 2))
        self.assertEqual(parse_type_name('int [2][3][4]'),
                         ArrayTypeName(ArrayTypeName(ArrayTypeName(BasicTypeName('int'), 4), 3), 2))