Skip to content

Commit

Permalink
added exit msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
khlevin committed Nov 13, 2024
1 parent 4bb4897 commit 611a925
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/chatdbg/chatdbg_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ def stop_handler(event):
gdb.events.stop.connect(stop_handler)


def on_exit(event):
print(
f"Thank you for using ChatDBG!\nIf you've enjoyed your experience, feel free to share your success stories here: https://github.com/plasma-umass/ChatDBG/issues/53"
)


# Register the exit event handler
gdb.events.exited.connect(on_exit)


class Code(gdb.Command):

def __init__(self):
Expand Down
5 changes: 5 additions & 0 deletions src/chatdbg/chatdbg_lldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def __init__(self, prompt, debugger) -> None:
super().__init__(prompt)
self._debugger = debugger

def _exit_message(self):
print(
f"Thank you for using ChatDBG!\nIf you've enjoyed your experience, feel free to share your success stories here: https://github.com/plasma-umass/ChatDBG/issues/53"
)

def _message_is_a_bad_command_error(self, message):
return message.strip().endswith("is not a valid command.")

Expand Down
7 changes: 6 additions & 1 deletion src/chatdbg/chatdbg_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def __init__(self, *args, **kwargs):
self._text_width = 120
self._assistant = None
atexit.register(lambda: self._close_assistant())
atexit.register(
lambda: print(
f"Thank you for using ChatDBG!\nIf you've enjoyed your experience, feel free to share your success stories here: https://github.com/plasma-umass/ChatDBG/issues/53"
)
)

self._history = CommandHistory(self.prompt)
self._error_message = ""
Expand Down Expand Up @@ -287,7 +292,7 @@ def _getval(self, arg):
try:
if chatdbg_config.unsafe:
return super._getval(arg)
else:
else:
return sandbox_eval(arg, self.curframe.f_globals, self.curframe_locals)
except NameError as e:
self.error(f"NameError: {e}")
Expand Down
5 changes: 5 additions & 0 deletions src/chatdbg/native_util/dbg_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def dialog(self, user_text):
break

assistant.close()
# Only implemented in LLDB
self._exit_message()

def _exit_message(self):
pass

# Return string for valid command. None if the command is not valid.
def _run_one_command(self, command):
Expand Down

0 comments on commit 611a925

Please sign in to comment.