Browse Source

Removed hard DebugClang dependency in Terminal

merge-requests/365/head
eidheim 10 years ago
parent
commit
a717fe7b39
  1. 10
      src/project.cc
  2. 5
      src/project.h
  3. 8
      src/terminal.cc
  4. 60
      src/window.cc
  5. 2
      src/window.h

10
src/project.cc

@ -16,6 +16,8 @@ std::atomic<bool> Project::debugging;
std::pair<boost::filesystem::path, std::pair<int, int> > Project::debug_stop; std::pair<boost::filesystem::path, std::pair<int, int> > Project::debug_stop;
boost::filesystem::path Project::debug_last_stop_file_path; boost::filesystem::path Project::debug_last_stop_file_path;
std::unique_ptr<Project::Language> Project::current_language;
void Project::debug_update_status(const std::string &debug_status) { void Project::debug_update_status(const std::string &debug_status) {
if(debug_status.empty()) { if(debug_status.empty()) {
debug_status_label().set_text(""); debug_status_label().set_text("");
@ -465,6 +467,14 @@ void Project::Clang::debug_remove_breakpoint(const boost::filesystem::path &file
DebugClang::get().remove_breakpoint(file_path, line_nr, line_count); DebugClang::get().remove_breakpoint(file_path, line_nr, line_count);
} }
bool Project::Clang::debug_is_running() {
return DebugClang::get().is_running();
}
void Project::Clang::debug_write(const std::string &buffer) {
DebugClang::get().write(buffer);
}
void Project::Clang::debug_delete() { void Project::Clang::debug_delete() {
debug_start_mutex.lock(); debug_start_mutex.lock();
DebugClang::get().delete_debug(); DebugClang::get().delete_debug();

5
src/project.h

@ -51,6 +51,8 @@ public:
virtual void debug_run_command(const std::string &command) {} virtual void debug_run_command(const std::string &command) {}
virtual void debug_add_breakpoint(const boost::filesystem::path &file_path, int line_nr) {} virtual void debug_add_breakpoint(const boost::filesystem::path &file_path, int line_nr) {}
virtual void debug_remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) {} virtual void debug_remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) {}
virtual bool debug_is_running() { return false; }
virtual void debug_write(const std::string &buffer) {}
virtual void debug_delete() {} virtual void debug_delete() {}
}; };
@ -82,6 +84,8 @@ public:
void debug_run_command(const std::string &command) override; void debug_run_command(const std::string &command) override;
void debug_add_breakpoint(const boost::filesystem::path &file_path, int line_nr) override; void debug_add_breakpoint(const boost::filesystem::path &file_path, int line_nr) override;
void debug_remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) override; void debug_remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) override;
bool debug_is_running() override;
void debug_write(const std::string &buffer) override;
void debug_delete() override; void debug_delete() override;
#endif #endif
}; };
@ -117,6 +121,7 @@ public:
}; };
static std::unique_ptr<Language> get_language(); static std::unique_ptr<Language> get_language();
static std::unique_ptr<Language> current_language;
}; };
#endif // JUCI_PROJECT_H_ #endif // JUCI_PROJECT_H_

8
src/terminal.cc

@ -2,9 +2,7 @@
#include <iostream> #include <iostream>
#include "logging.h" #include "logging.h"
#include "config.h" #include "config.h"
#ifdef JUCI_ENABLE_DEBUG #include "project.h"
#include "debug_clang.h"
#endif
Terminal::InProgress::InProgress(const std::string& start_msg): stop(false) { Terminal::InProgress::InProgress(const std::string& start_msg): stop(false) {
start(start_msg); start(start_msg);
@ -240,7 +238,7 @@ bool Terminal::on_key_press_event(GdkEventKey *event) {
processes_mutex.lock(); processes_mutex.lock();
bool debug_is_running=false; bool debug_is_running=false;
#ifdef JUCI_ENABLE_DEBUG #ifdef JUCI_ENABLE_DEBUG
debug_is_running=DebugClang::get().is_running(); debug_is_running=Project::current_language?Project::current_language->debug_is_running():false;
#endif #endif
if(processes.size()>0 || debug_is_running) { if(processes.size()>0 || debug_is_running) {
get_buffer()->place_cursor(get_buffer()->end()); get_buffer()->place_cursor(get_buffer()->end());
@ -262,7 +260,7 @@ bool Terminal::on_key_press_event(GdkEventKey *event) {
stdin_buffer+='\n'; stdin_buffer+='\n';
if(debug_is_running) { if(debug_is_running) {
#ifdef JUCI_ENABLE_DEBUG #ifdef JUCI_ENABLE_DEBUG
DebugClang::get().write(stdin_buffer); Project::current_language->debug_write(stdin_buffer);
#endif #endif
} }
else else

60
src/window.cc

@ -536,9 +536,9 @@ void Window::set_menu_actions() {
if(Config::get().project.save_on_compile_or_run) if(Config::get().project.save_on_compile_or_run)
notebook.save_project_files(); notebook.save_project_files();
project_language=Project::get_language(); Project::current_language=Project::get_language();
project_language->compile_and_run(); Project::current_language->compile_and_run();
}); });
menu.add_action("compile", [this]() { menu.add_action("compile", [this]() {
if(Project::compiling || Project::debugging) if(Project::compiling || Project::debugging)
@ -547,8 +547,8 @@ void Window::set_menu_actions() {
if(Config::get().project.save_on_compile_or_run) if(Config::get().project.save_on_compile_or_run)
notebook.save_project_files(); notebook.save_project_files();
project_language=Project::get_language(); Project::current_language=Project::get_language();
project_language->compile(); Project::current_language->compile();
}); });
menu.add_action("run_command", [this]() { menu.add_action("run_command", [this]() {
@ -615,51 +615,51 @@ void Window::set_menu_actions() {
if(Project::compiling) if(Project::compiling)
return; return;
else if(Project::debugging) { else if(Project::debugging) {
project_language->debug_continue(); Project::current_language->debug_continue();
return; return;
} }
if(Config::get().project.save_on_compile_or_run) if(Config::get().project.save_on_compile_or_run)
notebook.save_project_files(); notebook.save_project_files();
project_language=Project::get_language(); Project::current_language=Project::get_language();
project_language->debug_start(); Project::current_language->debug_start();
}); });
menu.add_action("debug_stop", [this]() { menu.add_action("debug_stop", [this]() {
if(project_language) if(Project::current_language)
project_language->debug_stop(); Project::current_language->debug_stop();
}); });
menu.add_action("debug_kill", [this]() { menu.add_action("debug_kill", [this]() {
if(project_language) if(Project::current_language)
project_language->debug_kill(); Project::current_language->debug_kill();
}); });
menu.add_action("debug_step_over", [this]() { menu.add_action("debug_step_over", [this]() {
if(project_language) if(Project::current_language)
project_language->debug_step_over(); Project::current_language->debug_step_over();
}); });
menu.add_action("debug_step_into", [this]() { menu.add_action("debug_step_into", [this]() {
if(project_language) if(Project::current_language)
project_language->debug_step_into(); Project::current_language->debug_step_into();
}); });
menu.add_action("debug_step_out", [this]() { menu.add_action("debug_step_out", [this]() {
if(project_language) if(Project::current_language)
project_language->debug_step_out(); Project::current_language->debug_step_out();
}); });
menu.add_action("debug_backtrace", [this]() { menu.add_action("debug_backtrace", [this]() {
if(project_language) if(Project::current_language)
project_language->debug_backtrace(); Project::current_language->debug_backtrace();
}); });
menu.add_action("debug_show_variables", [this]() { menu.add_action("debug_show_variables", [this]() {
if(project_language) if(Project::current_language)
project_language->debug_show_variables(); Project::current_language->debug_show_variables();
}); });
menu.add_action("debug_run_command", [this]() { menu.add_action("debug_run_command", [this]() {
entry_box.clear(); entry_box.clear();
entry_box.entries.emplace_back(last_run_debug_command, [this](const std::string& content){ entry_box.entries.emplace_back(last_run_debug_command, [this](const std::string& content){
if(content!="") { if(content!="") {
if(project_language) if(Project::current_language)
project_language->debug_run_command(content); Project::current_language->debug_run_command(content);
last_run_debug_command=content; last_run_debug_command=content;
} }
entry_box.hide(); entry_box.hide();
@ -681,13 +681,13 @@ void Window::set_menu_actions() {
auto end_iter=start_iter; auto end_iter=start_iter;
while(!end_iter.ends_line() && end_iter.forward_char()) {} while(!end_iter.ends_line() && end_iter.forward_char()) {}
view->get_source_buffer()->remove_source_marks(start_iter, end_iter, "debug_breakpoint"); view->get_source_buffer()->remove_source_marks(start_iter, end_iter, "debug_breakpoint");
if(project_language) if(Project::current_language)
project_language->debug_remove_breakpoint(view->file_path, line_nr+1, view->get_buffer()->get_line_count()+1); Project::current_language->debug_remove_breakpoint(view->file_path, line_nr+1, view->get_buffer()->get_line_count()+1);
} }
else { else {
view->get_source_buffer()->create_source_mark("debug_breakpoint", view->get_buffer()->get_insert()->get_iter()); view->get_source_buffer()->create_source_mark("debug_breakpoint", view->get_buffer()->get_insert()->get_iter());
if(project_language) if(Project::current_language)
project_language->debug_add_breakpoint(view->file_path, line_nr+1); Project::current_language->debug_add_breakpoint(view->file_path, line_nr+1);
} }
} }
}); });
@ -817,8 +817,8 @@ bool Window::on_delete_event(GdkEventAny *event) {
} }
Terminal::get().kill_async_processes(); Terminal::get().kill_async_processes();
#ifdef JUCI_ENABLE_DEBUG #ifdef JUCI_ENABLE_DEBUG
if(project_language) if(Project::current_language)
project_language->debug_delete(); Project::current_language->debug_delete();
#endif #endif
return false; return false;
} }

2
src/window.h

@ -32,8 +32,6 @@ private:
Gtk::HBox info_and_status_hbox; Gtk::HBox info_and_status_hbox;
Gtk::AboutDialog about; Gtk::AboutDialog about;
EntryBox entry_box; EntryBox entry_box;
std::unique_ptr<Project::Language> project_language;
void configure(); void configure();
void set_menu_actions(); void set_menu_actions();

Loading…
Cancel
Save