Skip to content

Commit

Permalink
print warning messages when using target remote with gef (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Oct 13, 2022
1 parent f2050af commit 33fe436
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions gef.py
Expand Up @@ -356,6 +356,15 @@ def is_alive() -> bool:
return False


def calling_function() -> Optional[str]:
"""Return the name of the calling function"""
try:
stack_info = traceback.extract_stack()[-3]
return stack_info.name
except:
return None


#
# Decorators
#
Expand Down Expand Up @@ -10859,3 +10868,8 @@ def reset_caches(self) -> None:
new_objfile_handler(None)

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

0 comments on commit 33fe436

Please sign in to comment.