Exit with non-zero code from gdbinit.py if an exception occurs (#2242)

* Exit with non-zero code from gdbinit.py if an exception occurs

* Update gdbinit.py

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
pull/2258/head
Gulshan Singh 1 year ago committed by GitHub
parent b4d6d5cbb8
commit dc9c87254a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -8,6 +8,7 @@ import site
import subprocess import subprocess
import sys import sys
import time import time
import traceback
from glob import glob from glob import glob
from pathlib import Path from pathlib import Path
from typing import List from typing import List
@ -163,8 +164,15 @@ def main() -> None:
pwndbg.profiling.profiler.start() pwndbg.profiling.profiler.start()
main() # We wrap everything in try/except so that we can exit GDB with an error code
# This is used by tests to check if gdbinit.py failed
try:
main()
# We've already imported this in `main`, but we reimport it here so that it's available # We've already imported this in `main`, but we reimport it here so that it's
# at the global scope when some starts a Python interpreter in GDB # available at the global scope when some starts a Python interpreter in GDB
import pwndbg # noqa: F401 import pwndbg # noqa: F401
except Exception:
print(traceback.format_exc(), file=sys.stderr)
sys.exit(1)

Loading…
Cancel
Save