Skip to content

Commit

Permalink
[target-remote] Add post-hook for extended-remote too
Browse files Browse the repository at this point in the history
  • Loading branch information
ValekoZ committed Dec 7, 2023
1 parent e157cfe commit a48d0bc
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -11223,19 +11223,18 @@ def target_remote_posthook():

GefTmuxSetup()

# `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."
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")

# Register a post-hook for `target remote` that initialize the remote session
gdb.execute("""
define target hookpost-remote
warnmsg = "Using `target remote` with GEF should work in most cases, but use `gef-remote` if you can."
hook = f"""
define target hookpost-{{}}
pi target_remote_posthook()
context
pi if calling_function() != "connect": warn("{warnmsg}")
end
""")
"""

# Register a post-hook for `target remote` that initialize the remote session
gdb.execute(hook.format("remote"))
gdb.execute(hook.format("extended-remote"))

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

0 comments on commit a48d0bc

Please sign in to comment.