mirror of https://github.com/pwndbg/pwndbg
Fix some mypy errors
This commit is contained in:
parent
fd5e722cbc
commit
2be84a9b4d
|
@ -1,5 +1,7 @@
|
|||
import os.path
|
||||
import re
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
|
||||
import pygments
|
||||
import pygments.formatters
|
||||
|
@ -20,7 +22,7 @@ style = theme.Parameter(
|
|||
|
||||
formatter = pygments.formatters.Terminal256Formatter(style=str(style))
|
||||
pwntools_lexer = PwntoolsLexer()
|
||||
lexer_cache = {}
|
||||
lexer_cache: Dict[str, Any] = {}
|
||||
|
||||
|
||||
@pwndbg.config.Trigger([style])
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
import types
|
||||
from imp import reload as _reload
|
||||
|
||||
import pwndbg
|
||||
import pwndbg.commands
|
||||
import pwndbg.gdblib.events
|
||||
import pwndbg.lib.memoize
|
||||
|
||||
try:
|
||||
from __builtins__ import reload as _reload
|
||||
except Exception:
|
||||
from imp import reload as _reload
|
||||
|
||||
|
||||
def rreload(module, mdict=None):
|
||||
"""Recursively reload modules."""
|
||||
|
|
|
@ -7,6 +7,11 @@ by using a decorator.
|
|||
import sys
|
||||
from functools import partial
|
||||
from functools import wraps
|
||||
from typing import Any
|
||||
from typing import Callable
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
from typing import Set
|
||||
|
||||
import gdb
|
||||
|
||||
|
@ -101,7 +106,7 @@ gdb.events.before_prompt = before_prompt_event
|
|||
|
||||
# In order to support reloading, we must be able to re-fire
|
||||
# all 'objfile' and 'stop' events.
|
||||
registered = {
|
||||
registered: Dict[Any, List[Callable]] = {
|
||||
gdb.events.exited: [],
|
||||
gdb.events.cont: [],
|
||||
gdb.events.new_objfile: [],
|
||||
|
@ -122,7 +127,7 @@ except (NameError, AttributeError):
|
|||
# objects are loaded. This greatly slows down the debugging session.
|
||||
# In order to combat this, we keep track of which objfiles have been loaded
|
||||
# this session, and only emit objfile events for each *new* file.
|
||||
objfile_cache = dict()
|
||||
objfile_cache: Dict[str, Set[str]] = {}
|
||||
|
||||
|
||||
def connect(func, event_handler, name=""):
|
||||
|
|
|
@ -6,6 +6,7 @@ import ctypes
|
|||
import re
|
||||
import sys
|
||||
from types import ModuleType
|
||||
from typing import Dict
|
||||
|
||||
import gdb
|
||||
|
||||
|
@ -41,7 +42,7 @@ ARCH_GET_GS = 0x1004
|
|||
|
||||
|
||||
class module(ModuleType):
|
||||
last = {}
|
||||
last: Dict[str, int] = {}
|
||||
|
||||
@pwndbg.lib.memoize.reset_on_stop
|
||||
@pwndbg.lib.memoize.reset_on_prompt
|
||||
|
|
|
@ -6,6 +6,8 @@ Generally not needed, except under qemu-user and for when
|
|||
binaries do things to remap the stack (e.g. pwnies' postit).
|
||||
"""
|
||||
|
||||
from typing import Dict
|
||||
|
||||
import gdb
|
||||
|
||||
import pwndbg.gdblib.abi
|
||||
|
@ -17,7 +19,7 @@ import pwndbg.lib.memoize
|
|||
# Dictionary of stack ranges.
|
||||
# Key is the gdb thread ptid
|
||||
# Value is a pwndbg.lib.memory.Page object
|
||||
stacks = {}
|
||||
stacks: Dict[int, pwndbg.lib.memory.Page] = {}
|
||||
|
||||
# Whether the stack is protected by NX.
|
||||
# This is updated automatically by is_executable.
|
||||
|
|
|
@ -224,6 +224,8 @@ def address(symbol: str) -> int:
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@pwndbg.lib.memoize.reset_on_objfile
|
||||
def static_linkage_symbol_address(symbol):
|
||||
|
|
|
@ -21,7 +21,9 @@ class module(ModuleType):
|
|||
|
||||
def get_tls_base_via_errno_location(self) -> int:
|
||||
"""Heuristically determine the base address of the TLS."""
|
||||
if pwndbg.symbol.address("__errno_location") is None or pwndbg.gdblib.arch.current not in (
|
||||
if pwndbg.gdblib.symbol.address(
|
||||
"__errno_location"
|
||||
) is None or pwndbg.gdblib.arch.current not in (
|
||||
"x86-64",
|
||||
"i386",
|
||||
"arm",
|
||||
|
|
|
@ -189,6 +189,7 @@ NETLINK_TYPES = {
|
|||
|
||||
class Netlink(inode):
|
||||
eth = 0
|
||||
pid = None
|
||||
|
||||
def __str__(self):
|
||||
return NETLINK_TYPES.get(self.eth, "(unknown netlink)")
|
||||
|
|
Loading…
Reference in New Issue