How to use the drgn.typename.PointerTypeName 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_pointer_to_function_returning_pointer_to_const(self):
        self.assertEqual(str(PointerTypeName(FunctionTypeName(PointerTypeName(BasicTypeName('int', qualifiers={'const'})), [(BasicTypeName('int'), None)]))),
                         'const int *(*)(int)')
github osandov / drgn / tests / test_typename.py View on Github external
def test_pointer_to_function_with_no_parameters(self):
        self.assertEqual(str(PointerTypeName(FunctionTypeName(BasicTypeName('int'), []))),
                         'int (*)(void)')
github osandov / drgn / tests / test_typename.py View on Github external
def test_pointer_to_variadic_function(self):
        self.assertEqual(str(PointerTypeName(FunctionTypeName(BasicTypeName('int'), [(BasicTypeName('int'), None)], variadic=True))),
                         'int (*)(int, ...)')
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
def test_pointer_to_function_returning_pointer(self):
        self.assertEqual(str(PointerTypeName(FunctionTypeName(PointerTypeName(BasicTypeName('int')), [(BasicTypeName('int'), None)]))),
                         'int *(*)(int)')
        self.assertEqual(str(PointerTypeName(FunctionTypeName(PointerTypeName(BasicTypeName('int')), [(PointerTypeName(BasicTypeName('int')), None)]))),
                         'int *(*)(int *)')
github osandov / drgn / tests / test_typename.py View on Github external
def test_pointer(self):
        self.assertEqual(str(PointerTypeName(BasicTypeName('int'))), 'int *')
        self.assertEqual(str(PointerTypeName(BasicTypeName('int'), qualifiers={'const'})),
                         'int * const')

        self.assertEqual(str(PointerTypeName(BasicTypeName('struct point'))),
                         'struct point *')

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

        self.assertEqual(str(PointerTypeName(PointerTypeName(BasicTypeName('int'),
                                                             qualifiers={'const'}))),
                         'int * const *')
github osandov / drgn / tests / test_typename.py View on Github external
def test_pointer(self):
        self.assertEqual(str(PointerTypeName(BasicTypeName('int'))), 'int *')
        self.assertEqual(str(PointerTypeName(BasicTypeName('int'), qualifiers={'const'})),
                         'int * const')

        self.assertEqual(str(PointerTypeName(BasicTypeName('struct point'))),
                         'struct point *')

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

        self.assertEqual(str(PointerTypeName(PointerTypeName(BasicTypeName('int'),
                                                             qualifiers={'const'}))),
                         'int * const *')
github osandov / drgn / drgn / type.py View on Github external
def type_name(self) -> PointerTypeName:
        return PointerTypeName(self.type.type_name(), self.qualifiers)
github osandov / drgn / drgn / typename.py View on Github external
def _parse_pointer(self, type_name: TypeName) -> Tuple[TypeName, Optional[PointerTypeName]]:
        if self._lexer.peek().kind != 'ASTERISK':
            raise ValueError("expected '*'")
        inner_type = None
        while self._lexer.peek().kind == 'ASTERISK':
            self._lexer.pop()
            qualifiers = self._parse_optional_type_qualifier_list()
            type_name = PointerTypeName(type_name, qualifiers)
            if inner_type is None:
                inner_type = type_name
        return type_name, inner_type