Skip to content

Commit

Permalink
Tiny cleanup (#994)
Browse files Browse the repository at this point in the history
Small cleanup
  • Loading branch information
Grazfather committed Aug 26, 2023
1 parent bba5f1c commit 46fba8b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions gef.py
Expand Up @@ -5987,16 +5987,16 @@ def do_invoke(self, _: List[str], **kwargs: Any) -> None:

# qemu-user support
qemu_binary: Optional[pathlib.Path] = None
try:
if args.qemu_user:
if args.qemu_user:
try:
qemu_binary = pathlib.Path(args.qemu_binary).expanduser().absolute() if args.qemu_binary else gef.session.file
if not qemu_binary or not qemu_binary.exists():
raise FileNotFoundError(f"{qemu_binary} does not exist")
except Exception as e:
err(f"Failed to initialize qemu-user mode, reason: {str(e)}")
return
except Exception as e:
err(f"Failed to initialize qemu-user mode, reason: {str(e)}")
return

# try to establish the remote session, throw on error
# Try to establish the remote session, throw on error
# Set `.remote_initializing` to True here - `GefRemoteSessionManager` invokes code which
# calls `is_remote_debug` which checks if `remote_initializing` is True or `.remote` is None
# This prevents some spurious errors being thrown during startup
Expand Down Expand Up @@ -11195,8 +11195,9 @@ def reset_caches(self) -> None:

# `target remote` commands cannot be disabled, so print a warning message instead
errmsg = "Using `target remote` with GEF does not work, use `gef-remote` instead. You've been warned."
gdb.execute(f"define target hook-remote\n pi if calling_function() != \"connect\": err(\"{errmsg}\") \nend")
gdb.execute(f"define target hook-extended-remote\n pi if calling_function() != \"connect\": err(\"{errmsg}\") \nend")
hook = f"""pi if calling_function() != "connect": err("{errmsg}")"""
gdb.execute(f"define target hook-remote\n{hook}\nend")
gdb.execute(f"define target hook-extended-remote\n{hook}\nend")

# restore saved breakpoints (if any)
bkp_fpath = pathlib.Path(gef.config["gef.autosave_breakpoints_file"]).expanduser().absolute()
Expand Down

0 comments on commit 46fba8b

Please sign in to comment.