mirror of https://github.com/pwndbg/pwndbg
Don't catch the error of the heap commands when `set exception-* on` (#1270)
* Don't catch the error of the heap commands for developers * Use `pwndbg.config` and re-raise the error See https://github.com/pwndbg/pwndbg/pull/1270#discussion_r992209956 * Update pwndbg/commands/__init__.py Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
This commit is contained in:
parent
8da9c5b9f9
commit
75ece8e2a8
|
@ -15,6 +15,7 @@ import pwndbg.exception
|
||||||
import pwndbg.gdblib.memory
|
import pwndbg.gdblib.memory
|
||||||
import pwndbg.gdblib.regs
|
import pwndbg.gdblib.regs
|
||||||
import pwndbg.gdblib.symbol
|
import pwndbg.gdblib.symbol
|
||||||
|
import pwndbg.heap
|
||||||
import pwndbg.hexdump
|
import pwndbg.hexdump
|
||||||
import pwndbg.ui
|
import pwndbg.ui
|
||||||
from pwndbg.heap.ptmalloc import SymbolUnresolvableError
|
from pwndbg.heap.ptmalloc import SymbolUnresolvableError
|
||||||
|
@ -276,6 +277,7 @@ def OnlyWithResolvedHeapSyms(function):
|
||||||
e = lambda s: print(message.error(s))
|
e = lambda s: print(message.error(s))
|
||||||
w = lambda s: print(message.warn(s))
|
w = lambda s: print(message.warn(s))
|
||||||
if pwndbg.heap.current.can_be_resolved():
|
if pwndbg.heap.current.can_be_resolved():
|
||||||
|
# Note: We will still raise the error for developers when exception-* is set to "on"
|
||||||
try:
|
try:
|
||||||
return function(*a, **kw)
|
return function(*a, **kw)
|
||||||
except SymbolUnresolvableError as err:
|
except SymbolUnresolvableError as err:
|
||||||
|
@ -283,14 +285,18 @@ def OnlyWithResolvedHeapSyms(function):
|
||||||
w(
|
w(
|
||||||
f"You can try to determine the libc symbols addresses manually and set them appropriately. For this, see the `heap_config` command output and set the config about `{err.symbol}`."
|
f"You can try to determine the libc symbols addresses manually and set them appropriately. For this, see the `heap_config` command output and set the config about `{err.symbol}`."
|
||||||
)
|
)
|
||||||
|
if pwndbg.config.exception_verbose.value or pwndbg.config.exception_debugger.value:
|
||||||
|
raise err
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
e(f"{function.__name__}: Unknown error: `{err}` when running this symbols.")
|
e(f"{function.__name__}: An unknown error occurred when running this command.")
|
||||||
if pwndbg.config.resolve_heap_via_heuristic:
|
if pwndbg.config.resolve_heap_via_heuristic:
|
||||||
w(
|
w(
|
||||||
"Maybe you can try to determine the libc symbols addresses manually, set them appropriately and re-run this command. For this, see the `heap_config` command output and set the `main_arena`, `mp_`, `global_max_fast`, `tcache` and `thread_arena` addresses."
|
"Maybe you can try to determine the libc symbols addresses manually, set them appropriately and re-run this command. For this, see the `heap_config` command output and set the `main_arena`, `mp_`, `global_max_fast`, `tcache` and `thread_arena` addresses."
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
w("You can try `set resolve-heap-via-heuristic on` and re-run this command.\n")
|
w("You can try `set resolve-heap-via-heuristic on` and re-run this command.\n")
|
||||||
|
if pwndbg.config.exception_verbose or pwndbg.config.exception_debugger:
|
||||||
|
raise err
|
||||||
else:
|
else:
|
||||||
print(message.error(f"{function.__name__}: "), end="")
|
print(message.error(f"{function.__name__}: "), end="")
|
||||||
if not pwndbg.config.resolve_heap_via_heuristic:
|
if not pwndbg.config.resolve_heap_via_heuristic:
|
||||||
|
|
Loading…
Reference in New Issue