summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2021-12-20 22:42:03 +0200
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-12-22 02:14:32 -0800
commit1ec917aa23dbc0e3d95e0dfe5f279971789cfcb8 (patch)
tree751e2f9447dc201285d076939cddd87514b178a3
parenta02d8e57101ba643c1b9978663cd43cea3caa85a (diff)
downloadserenity-1ec917aa23dbc0e3d95e0dfe5f279971789cfcb8.zip
HackStudio: Attach debuggee to "Console" terminal tab
Previously the debuggee process used the same tty of the HackStudio process. We now set things up so the debuggee gets attached to the TerminalWrapper in the "Console" tab.
-rw-r--r--Userland/DevTools/HackStudio/Debugger/Debugger.cpp8
-rw-r--r--Userland/DevTools/HackStudio/Debugger/Debugger.h3
-rw-r--r--Userland/DevTools/HackStudio/HackStudioWidget.cpp14
3 files changed, 24 insertions, 1 deletions
diff --git a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp
index 4f2a4c6447..b2464e8e54 100644
--- a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp
+++ b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp
@@ -112,7 +112,13 @@ void Debugger::stop()
void Debugger::start()
{
- m_debug_session = Debug::DebugSession::exec_and_attach(m_executable_path, m_source_root);
+
+ auto child_setup_callback = [this]() {
+ if (m_child_setup_callback)
+ return m_child_setup_callback();
+ return ErrorOr<void> {};
+ };
+ m_debug_session = Debug::DebugSession::exec_and_attach(m_executable_path, m_source_root, move(child_setup_callback));
VERIFY(!!m_debug_session);
for (const auto& breakpoint : m_breakpoints) {
diff --git a/Userland/DevTools/HackStudio/Debugger/Debugger.h b/Userland/DevTools/HackStudio/Debugger/Debugger.h
index 1ef6f67bc4..eca9d30b76 100644
--- a/Userland/DevTools/HackStudio/Debugger/Debugger.h
+++ b/Userland/DevTools/HackStudio/Debugger/Debugger.h
@@ -60,6 +60,8 @@ public:
void set_requested_debugger_action(DebuggerAction);
void reset_breakpoints() { m_breakpoints.clear(); }
+ void set_child_setup_callback(Function<ErrorOr<void>()> callback) { m_child_setup_callback = move(callback); }
+
private:
class DebuggingState {
public:
@@ -119,6 +121,7 @@ private:
Function<HasControlPassedToUser(const PtraceRegisters&)> m_on_stopped_callback;
Function<void()> m_on_continue_callback;
Function<void()> m_on_exit_callback;
+ Function<ErrorOr<void>()> m_child_setup_callback;
};
}
diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
index 320fdcca98..63977a92d4 100644
--- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp
+++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp
@@ -797,6 +797,20 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_debug_action()
}
Debugger::the().set_executable_path(get_project_executable_path());
+
+ m_terminal_wrapper->clear_including_history();
+
+ // The debugger calls wait() on the debugee, so the TerminalWrapper can't do that.
+ auto ptm_res = m_terminal_wrapper->setup_master_pseudoterminal(TerminalWrapper::WaitForChildOnExit::No);
+ if (ptm_res.is_error()) {
+ perror("setup_master_pseudoterminal");
+ return;
+ }
+
+ Debugger::the().set_child_setup_callback([this, ptm_res]() {
+ return m_terminal_wrapper->setup_slave_pseudoterminal(ptm_res.value());
+ });
+
m_debugger_thread = Threading::Thread::construct(Debugger::start_static);
m_debugger_thread->start();
m_stop_action->set_enabled(true);