How to use the drgn.typename.parse_type_name 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_basic_types(self):
        self.assertEqual(parse_type_name('char'), BasicTypeName('char'))
        self.assertEqual(parse_type_name('int'), BasicTypeName('int'))
        self.assertEqual(parse_type_name('float'), BasicTypeName('float'))
        self.assertEqual(parse_type_name('double'), BasicTypeName('double'))
        self.assertEqual(parse_type_name('_Bool'), BasicTypeName('_Bool'))
github osandov / drgn / tests / test_typename.py View on Github external
def test_size(self):
        self.assertEqual(parse_type_name('long int'), BasicTypeName('long'))
        self.assertEqual(parse_type_name('long'), BasicTypeName('long'))
        self.assertEqual(parse_type_name('int long'), BasicTypeName('long'))

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

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

        self.assertEqual(parse_type_name('long double'),
                         BasicTypeName('long double'))
        self.assertEqual(parse_type_name('double long'),
                         BasicTypeName('long double'))

        self.assertRaises(ValueError, parse_type_name, 'short long int')
        self.assertRaises(ValueError, parse_type_name, 'long long long int')
        self.assertRaises(ValueError, parse_type_name, 'short double')
        self.assertRaises(ValueError, parse_type_name, 'double short')
        self.assertRaises(ValueError, parse_type_name, 'long long double')
        self.assertRaises(ValueError, parse_type_name, 'long double long')
        self.assertRaises(ValueError, parse_type_name, 'double long long')
        self.assertRaises(ValueError, parse_type_name, 'long char')
        self.assertRaises(ValueError, parse_type_name, 'char long')
github osandov / drgn / tests / test_typename.py View on Github external
def test_basic_types(self):
        self.assertEqual(parse_type_name('char'), BasicTypeName('char'))
        self.assertEqual(parse_type_name('int'), BasicTypeName('int'))
        self.assertEqual(parse_type_name('float'), BasicTypeName('float'))
        self.assertEqual(parse_type_name('double'), BasicTypeName('double'))
        self.assertEqual(parse_type_name('_Bool'), BasicTypeName('_Bool'))
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'),
                         BasicTypeName('unsigned char'))
        self.assertEqual(parse_type_name('char unsigned'),
                         BasicTypeName('unsigned char'))
github osandov / drgn / tests / test_typename.py View on Github external
def test_size(self):
        self.assertEqual(parse_type_name('long int'), BasicTypeName('long'))
        self.assertEqual(parse_type_name('long'), BasicTypeName('long'))
        self.assertEqual(parse_type_name('int long'), BasicTypeName('long'))

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

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

        self.assertEqual(parse_type_name('long double'),
                         BasicTypeName('long double'))
        self.assertEqual(parse_type_name('double long'),
                         BasicTypeName('long double'))

        self.assertRaises(ValueError, parse_type_name, 'short long int')
github osandov / drgn / tests / test_typename.py View on Github external
def test_tagged_type(self):
        self.assertEqual(parse_type_name('struct point'),
                         StructTypeName('point'))
        self.assertEqual(parse_type_name('union value'),
                         UnionTypeName('value'))
        self.assertEqual(parse_type_name('enum color'), EnumTypeName('color'))
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'),
                         BasicTypeName('unsigned char'))
        self.assertEqual(parse_type_name('char unsigned'),
github osandov / drgn / tests / test_typename.py View on Github external
def test_array_of_pointers(self):
        self.assertEqual(parse_type_name('int *[2][3]'),
                         ArrayTypeName(ArrayTypeName(PointerTypeName(BasicTypeName('int')), 3), 2))
github osandov / drgn / tests / test_typename.py View on Github external
def test_pointer(self):
        self.assertEqual(parse_type_name('int *'),
                         PointerTypeName(BasicTypeName('int')))
        self.assertEqual(parse_type_name('int * const'),
                         PointerTypeName(BasicTypeName('int'),
                                         qualifiers={'const'}))

        self.assertEqual(parse_type_name('struct point *'),
                         PointerTypeName(StructTypeName('point')))

        self.assertEqual(parse_type_name('int **'),
                         PointerTypeName(PointerTypeName(BasicTypeName('int'))))

        self.assertEqual(parse_type_name('int *((*))'),
                         PointerTypeName(PointerTypeName(BasicTypeName('int'))))

        self.assertEqual(parse_type_name('int * const *'),
                         PointerTypeName(PointerTypeName(BasicTypeName('int'),
                                                         qualifiers={'const'})))
github osandov / drgn / tests / test_typename.py View on Github external
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'),
                         BasicTypeName('unsigned char'))
        self.assertEqual(parse_type_name('char unsigned'),
                         BasicTypeName('unsigned char'))

        self.assertRaises(ValueError, parse_type_name, 'signed unsigned int')
        self.assertRaises(ValueError, parse_type_name, 'signed _Bool')
        self.assertRaises(ValueError, parse_type_name, '_Bool signed')