Skip to content

Commit

Permalink
rearrange
Browse files Browse the repository at this point in the history
  • Loading branch information
khlevin committed Nov 13, 2024
1 parent 611a925 commit b48b39d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 22 deletions.
10 changes: 2 additions & 8 deletions src/chatdbg/chatdbg_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
)
from chatdbg.util.config import chatdbg_config
from chatdbg.native_util.safety import command_is_safe
from chatdbg.util.exit_message import print_exit_message

# The file produced by the panic handler if the Rust program is using the chatdbg crate.
RUST_PANIC_LOG_FILENAME = "panic_log.txt"
Expand All @@ -39,15 +40,8 @@ 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)
gdb.events.exited.connect(print_exit_message)


class Code(gdb.Command):
Expand Down
8 changes: 4 additions & 4 deletions src/chatdbg/chatdbg_lldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
_SkippedFramesEntry,
)
from chatdbg.util.config import chatdbg_config
from chatdbg.util.exit_message import print_exit_message
from chatdbg.native_util.safety import command_is_safe

# The file produced by the panic handler if the Rust program is using the chatdbg crate.
Expand Down Expand Up @@ -78,10 +79,9 @@ 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 dialog(self, user_text):
super().dialog(user_text)
print_exit_message()

def _message_is_a_bad_command_error(self, message):
return message.strip().endswith("is not a valid command.")
Expand Down
7 changes: 2 additions & 5 deletions src/chatdbg/chatdbg_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from chatdbg.util.config import chatdbg_config
from chatdbg.util.log import ChatDBGLog
from chatdbg.util.history import CommandHistory
from chatdbg.util.exit_message import print_exit_message


def load_ipython_extension(ipython):
Expand Down Expand Up @@ -79,11 +80,7 @@ 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"
)
)
atexit.register(print_exit_message)

self._history = CommandHistory(self.prompt)
self._error_message = ""
Expand Down
5 changes: 0 additions & 5 deletions src/chatdbg/native_util/dbg_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ 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
3 changes: 3 additions & 0 deletions src/chatdbg/util/exit_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def print_exit_message(event=None) -> str:
print("Thank you for using ChatDBG!")
print("Share your success stories here: github.com/plasma-umass/ChatDBG/issues/53")

0 comments on commit b48b39d

Please sign in to comment.