Add more type hint

pull/1200/head
syheliel 3 years ago committed by Disconnect3d
parent ce7de2d443
commit d5d39c85eb

@ -1,6 +1,8 @@
import argparse
import functools
import io
from typing import Dict
from typing import List
import gdb
@ -15,7 +17,7 @@ import pwndbg.hexdump
import pwndbg.symbol
import pwndbg.ui
commands = []
commands = [] # type: List[Command]
command_names = set()
@ -50,7 +52,7 @@ class Command(gdb.Command):
"""Generic command wrapper"""
builtin_override_whitelist = {"up", "down", "search", "pwd", "start"}
history = {}
history = {} # type: Dict[int,str]
def __init__(self, function, prefix=False, command_name=None):
if command_name is None:

@ -1,4 +1,5 @@
import argparse
from typing import Dict
import pwndbg.commands
from pwndbg.color import message
@ -9,7 +10,7 @@ parser.add_argument(
)
parser.add_argument("comment", type=str, default=None, help="The text you want to comment")
file_lists = {} # This saves all comments.
file_lists = {} # type:Dict[str,str] #This saves all comments.
@pwndbg.commands.ArgparsedCommand(parser)

@ -4,6 +4,7 @@ import os
import sys
from collections import defaultdict
from io import open
from typing import Dict
import gdb
@ -66,7 +67,7 @@ config_context_sections = pwndbg.config.Parameter(
)
# Storing output configuration per section
outputs = {}
outputs = {} # type: Dict[str,str]
output_settings = {}

@ -915,11 +915,11 @@ def try_free(addr):
tc_idx = (chunk_size_unmasked - chunk_minsize + malloc_alignment - 1) // malloc_alignment
if tc_idx < allocator.mp["tcache_bins"]:
print(message.notice("Tcache checks"))
e = addr + 2 * size_sz
e += allocator.tcache_entry.keys().index("key") * ptr_size
e = pwndbg.gdblib.memory.pvoid(e)
e_addr = addr + 2 * size_sz
e_addr += allocator.tcache_entry.keys().index("key") * ptr_size
e_addr = pwndbg.gdblib.memory.pvoid(e)
tcache_addr = int(allocator.thread_cache.address)
if e == tcache_addr:
if e_addr == tcache_addr:
# todo, actually do checks
print(
message.error(

@ -8,7 +8,7 @@ import pwndbg.commands
import pwndbg.gdblib.regs
import pwndbg.symbol
errno.errorcode[0] = "OK"
errno.errorcode[0] = "OK" # type: ignore # manually add error code 0 for "OK"
parser = argparse.ArgumentParser(
description="""

@ -1,4 +1,6 @@
import argparse
from typing import List
from typing import Optional
import pwndbg.color
import pwndbg.commands
@ -78,7 +80,7 @@ parser = argparse.ArgumentParser(
parser.add_argument("mapping_names", type=address_range, nargs="+", help="Mapping name ")
def maybe_points_to_ranges(ptr: int, rs: [AddrRange]):
def maybe_points_to_ranges(ptr: int, rs: List[AddrRange]):
try:
pointee = pwndbg.gdblib.memory.pvoid(ptr)
except Exception:
@ -110,7 +112,7 @@ def p2p_walk(addr, ranges, current_level):
@pwndbg.commands.ArgparsedCommand(parser)
@pwndbg.commands.OnlyWhenRunning
def p2p(mapping_names: [] = None):
def p2p(mapping_names: Optional[List] = None):
if not mapping_names:
return

@ -3,6 +3,7 @@ import binascii
import codecs
import os
import struct
from typing import Set
import pwndbg.color.memory as M
import pwndbg.commands
@ -13,7 +14,7 @@ import pwndbg.search
import pwndbg.vmmap
from pwndbg.color import message
saved = set()
saved = set() # type:Set[int]
def print_search_hit(address):

@ -60,8 +60,8 @@ shellcmd_names = [
"zsh",
]
pwncmds = filter(pwndbg.lib.which.which, pwncmds)
shellcmds = filter(pwndbg.lib.which.which, shellcmd_names)
pwncmds = list(filter(pwndbg.lib.which.which, pwncmds))
shellcmds = list(filter(pwndbg.lib.which.which, shellcmd_names))
def register_shell_function(cmd, deprecated=False):

@ -26,6 +26,23 @@ import gdb
import pwndbg.decorators
main_arena: int
thread_arena: int
mp_: int
tcache: int
debug_events: int
syntax_highlight: int
hexdump_width: int
hexdump_bytes: int
show_compact_regs_min_width: int
show_flags: bool
show_retaddr_reg: bool
left_pad_disasm: bool
ida_rpc_host: str
ida_rpc_port: int
ida_enabled: bool
ida_timeout: int
glibc: str
TYPES = collections.OrderedDict()
# The value is a plain boolean.
@ -226,7 +243,7 @@ class Parameter(gdb.Parameter):
return self.value // other
def __pow__(self, other):
return self.value**other
return self.value ** other
def __mod__(self, other):
return self.value % other

@ -3,4 +3,4 @@
from pwndbg.gdblib import arch as arch_mod
from pwndbg.gdblib.arch import arch
from . import ctypes
__all__ = ["ctypes", "memory", "typeinfo"]

@ -7,6 +7,8 @@ by using a decorator.
import sys
from functools import partial
from functools import wraps
from typing import Callable
from typing import List
import gdb

@ -13,6 +13,7 @@ import pwndbg.lib.memoize
import pwndbg.lib.tempfile
module = sys.modules[__name__]
ptrsize: int
def lookup_types(*types):

@ -7,6 +7,8 @@ related information.
import functools
import sys
from types import ModuleType
from typing import Any
from typing import Callable
import gdb
@ -78,6 +80,7 @@ class module(ModuleType):
return wrapper
OnlyWhenRunning: Callable[[Any], Any]
# To prevent garbage collection
tether = sys.modules[__name__]

Loading…
Cancel
Save