Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiny cleanup #994

Merged
merged 1 commit into from
Aug 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions gef.py
Original file line number Diff line number Diff line change
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
Loading