Skip to content

Commit

Permalink
Add stub files for the gdb module.
Browse files Browse the repository at this point in the history
  • Loading branch information
visemet committed Mar 12, 2022
1 parent 8ef2ffc commit 1798b5f
Show file tree
Hide file tree
Showing 11 changed files with 553 additions and 0 deletions.
63 changes: 63 additions & 0 deletions stubs/gdb/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###
# Copyright 2022-present MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
"""https://sourceware.org/gdb/onlinedocs/gdb/Python-API.html"""

from gdb import events as events
from gdb import printing as printing
from gdb._basic import parse_and_eval as parse_and_eval
from gdb._basic import execute as execute
from gdb._errors import error as error
from gdb._errors import MemoryError as MemoryError
from gdb._errors import GdbError as GdbError
from gdb._inferior import Inferior as Inferior
from gdb._inferior import selected_inferior as selected_inferior
from gdb._objfile import Objfile as Objfile
from gdb._objfile import current_objfile as current_objfile
from gdb._progspace import Progspace as Progspace
from gdb._symbol import Symbol as Symbol
from gdb._symbol import lookup_symbol as lookup_symbol
from gdb._type import Type as Type
from gdb._type import TypeCode
from gdb._type import lookup_type as lookup_type
from gdb._value import Value as Value

TYPE_CODE_BITSTRING = TypeCode.TYPE_CODE_BITSTRING
TYPE_CODE_PTR = TypeCode.TYPE_CODE_PTR
TYPE_CODE_ARRAY = TypeCode.TYPE_CODE_ARRAY
TYPE_CODE_STRUCT = TypeCode.TYPE_CODE_STRUCT
TYPE_CODE_UNION = TypeCode.TYPE_CODE_UNION
TYPE_CODE_ENUM = TypeCode.TYPE_CODE_ENUM
TYPE_CODE_FLAGS = TypeCode.TYPE_CODE_FLAGS
TYPE_CODE_FUNC = TypeCode.TYPE_CODE_FUNC
TYPE_CODE_INT = TypeCode.TYPE_CODE_INT
TYPE_CODE_FLT = TypeCode.TYPE_CODE_FLT
TYPE_CODE_VOID = TypeCode.TYPE_CODE_VOID
TYPE_CODE_SET = TypeCode.TYPE_CODE_SET
TYPE_CODE_RANGE = TypeCode.TYPE_CODE_RANGE
TYPE_CODE_STRING = TypeCode.TYPE_CODE_STRING
TYPE_CODE_ERROR = TypeCode.TYPE_CODE_ERROR
TYPE_CODE_METHOD = TypeCode.TYPE_CODE_METHOD
TYPE_CODE_METHODPTR = TypeCode.TYPE_CODE_METHODPTR
TYPE_CODE_MEMBERPTR = TypeCode.TYPE_CODE_MEMBERPTR
TYPE_CODE_REF = TypeCode.TYPE_CODE_REF
TYPE_CODE_RVALUE_REF = TypeCode.TYPE_CODE_RVALUE_REF
TYPE_CODE_CHAR = TypeCode.TYPE_CODE_CHAR
TYPE_CODE_BOOL = TypeCode.TYPE_CODE_BOOL
TYPE_CODE_COMPLEX = TypeCode.TYPE_CODE_COMPLEX
TYPE_CODE_TYPEDEF = TypeCode.TYPE_CODE_TYPEDEF
TYPE_CODE_NAMESPACE = TypeCode.TYPE_CODE_NAMESPACE
TYPE_CODE_DECFLOAT = TypeCode.TYPE_CODE_DECFLOAT
TYPE_CODE_INTERNAL_FUNCTION = TypeCode.TYPE_CODE_INTERNAL_FUNCTION
35 changes: 35 additions & 0 deletions stubs/gdb/_basic.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
###
# Copyright 2022-present MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
"""https://sourceware.org/gdb/onlinedocs/gdb/Basic-Python.html"""

import typing

from gdb._value import Value


def parse_and_eval(expression: str, /) -> Value:
...


@typing.overload
def execute(command: str, /, *, from_tty: bool = False,
to_string: typing.Literal[False] = False) -> None:
...


@typing.overload
def execute(command: str, /, *, from_tty: bool = False, to_string: typing.Literal[True]) -> str:
...
28 changes: 28 additions & 0 deletions stubs/gdb/_errors.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
###
# Copyright 2022-present MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
"""https://sourceware.org/gdb/onlinedocs/gdb/Exception-Handling.htm"""


class error(RuntimeError):
...


class MemoryError(error):
...


class GdbError(Exception):
...
29 changes: 29 additions & 0 deletions stubs/gdb/_inferior.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
###
# Copyright 2022-present MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
"""https://sourceware.org/gdb/current/onlinedocs/gdb/Inferiors-In-Python.html"""

from gdb._progspace import Progspace


class Inferior:

@property
def progspace(self) -> Progspace:
...


def selected_inferior() -> Inferior:
...
24 changes: 24 additions & 0 deletions stubs/gdb/_objfile.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
###
# Copyright 2022-present MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
"""https://sourceware.org/gdb/onlinedocs/gdb/Objfiles-In-Python.html"""


class Objfile:
pass


def current_objfile() -> Objfile:
...
25 changes: 25 additions & 0 deletions stubs/gdb/_progspace.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
###
# Copyright 2022-present MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
"""https://sourceware.org/gdb/current/onlinedocs/gdb/Progspaces-In-Python.html"""

import typing


class Progspace:

@property
def filename(self) -> typing.Optional[str]:
...
34 changes: 34 additions & 0 deletions stubs/gdb/_symbol.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
###
# Copyright 2022-present MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
"""https://sourceware.org/gdb/onlinedocs/gdb/Symbols-In-Python.html"""
import typing

from gdb._type import Type
from gdb._value import Value


class Symbol:

@property
def type(self) -> Type:
...

def value(self) -> Value:
...


def lookup_symbol(symbol_name: str, /) -> typing.Tuple[typing.Optional[Symbol], bool]:
...
87 changes: 87 additions & 0 deletions stubs/gdb/_type.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
###
# Copyright 2022-present MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
"""https://sourceware.org/gdb/onlinedocs/gdb/Types-In-Python.html"""

import enum
import typing


class TypeCode(enum.IntEnum):
"""https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/gdbtypes.h;hb=refs/tags/gdb-8.3.1-release#l90"""
TYPE_CODE_BITSTRING = -1
TYPE_CODE_PTR = 1
TYPE_CODE_ARRAY = 2
TYPE_CODE_STRUCT = 3
TYPE_CODE_UNION = 4
TYPE_CODE_ENUM = 5
TYPE_CODE_FLAGS = 6
TYPE_CODE_FUNC = 7
TYPE_CODE_INT = 8
TYPE_CODE_FLT = 9
TYPE_CODE_VOID = 10
TYPE_CODE_SET = 11
TYPE_CODE_RANGE = 12
TYPE_CODE_STRING = 13
TYPE_CODE_ERROR = 14
TYPE_CODE_METHOD = 15
TYPE_CODE_METHODPTR = 16
TYPE_CODE_MEMBERPTR = 17
TYPE_CODE_REF = 18
TYPE_CODE_RVALUE_REF = 19
TYPE_CODE_CHAR = 20
TYPE_CODE_BOOL = 21
TYPE_CODE_COMPLEX = 22
TYPE_CODE_TYPEDEF = 23
TYPE_CODE_NAMESPACE = 24
TYPE_CODE_DECFLOAT = 25
TYPE_CODE_INTERNAL_FUNCTION = 27


class Type:

@property
def code(self) -> TypeCode:
...

@property
def name(self) -> typing.Optional[str]:
...

@property
def tag(self) -> typing.Optional[str]:
...

def unqualified(self) -> Type:
...

def reference(self) -> Type:
...

def pointer(self) -> Type:
...

def strip_typedefs(self) -> Type:
...

def target(self) -> Type:
...

def template_argument(self, n: int, /) -> Type:
...


def lookup_type(typename: str, /) -> Type:
...
Loading

0 comments on commit 1798b5f

Please sign in to comment.