mirror of https://github.com/pwndbg/pwndbg
add type for ./pwndbg/lib/
This commit is contained in:
parent
d8a62f1120
commit
fe0c279c70
|
@ -2,3 +2,5 @@
|
|||
# while `pwndbg.gdblib.arch` will represent the `Arch` object
|
||||
from pwndbg.gdblib import arch as arch_mod
|
||||
from pwndbg.gdblib.arch import arch
|
||||
|
||||
from . import ctypes
|
||||
|
|
|
@ -15,6 +15,7 @@ import pwndbg.gdblib.arch
|
|||
import pwndbg.gdblib.events
|
||||
|
||||
module = sys.modules[__name__]
|
||||
Structure = ctypes.LittleEndianStructure # default Structure type
|
||||
|
||||
|
||||
@pwndbg.gdblib.events.start
|
||||
|
|
|
@ -57,18 +57,15 @@ def happy(typename):
|
|||
if "unsigned" in typename:
|
||||
prefix = "u"
|
||||
typename = typename.replace("unsigned ", "")
|
||||
return (
|
||||
prefix
|
||||
+ {
|
||||
"char": "char",
|
||||
"short int": "short",
|
||||
"long int": "long",
|
||||
"int": "int",
|
||||
"long long": "longlong",
|
||||
"float": "float",
|
||||
"double": "double",
|
||||
}[typename]
|
||||
)
|
||||
return prefix + {
|
||||
"char": "char",
|
||||
"short int": "short",
|
||||
"long int": "long",
|
||||
"int": "int",
|
||||
"long long": "longlong",
|
||||
"float": "float",
|
||||
"double": "double",
|
||||
}[typename]
|
||||
|
||||
|
||||
def dt(name="", addr=None, obj=None):
|
||||
|
|
|
@ -13,12 +13,9 @@ class Arch:
|
|||
self.ptrmask = (1 << 8 * ptrsize) - 1
|
||||
self.endian = endian
|
||||
|
||||
self.fmt = {
|
||||
(4, "little"): "<I",
|
||||
(4, "big"): ">I",
|
||||
(8, "little"): "<Q",
|
||||
(8, "big"): ">Q",
|
||||
}.get((self.ptrsize, self.endian))
|
||||
self.fmt = {(4, "little"): "<I", (4, "big"): ">I", (8, "little"): "<Q", (8, "big"): ">Q",}[
|
||||
(self.ptrsize, self.endian)
|
||||
] # type: str
|
||||
|
||||
if self.name == "arm" and self.endian == "big":
|
||||
self.qemu = "armeb"
|
||||
|
@ -39,4 +36,4 @@ class Arch:
|
|||
return self.unpack(self.pack(integer), signed=True) # type: ignore
|
||||
|
||||
def unsigned(self, integer: int) -> int:
|
||||
return self.unpack(self.pack(integer))
|
||||
return self.unpack(self.pack(integer)) # type: ignore
|
||||
|
|
|
@ -8,6 +8,7 @@ import functools
|
|||
import sys
|
||||
from typing import Any
|
||||
from typing import Callable
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
|
||||
try:
|
||||
|
@ -15,7 +16,7 @@ try:
|
|||
from collections.abc import Hashable
|
||||
except ImportError:
|
||||
# Python < 3.10
|
||||
from collections import Hashable
|
||||
from collections import Hashable # type: ignore
|
||||
|
||||
debug = False
|
||||
|
||||
|
@ -29,7 +30,7 @@ class memoize:
|
|||
|
||||
def __init__(self, func: Callable) -> None:
|
||||
self.func = func
|
||||
self.cache = {}
|
||||
self.cache = {} # type: Dict[Any,Any]
|
||||
self.caches.append(self) # must be provided by base class
|
||||
functools.update_wrapper(self, func)
|
||||
|
||||
|
|
Loading…
Reference in New Issue