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. 58
      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;
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) {
if(debug_status.empty()) {
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);
}
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() {
debug_start_mutex.lock();
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_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 bool debug_is_running() { return false; }
virtual void debug_write(const std::string &buffer) {}
virtual void debug_delete() {}
};
@ -82,6 +84,8 @@ public:
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_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;
#endif
};
@ -117,6 +121,7 @@ public:
};
static std::unique_ptr<Language> get_language();
static std::unique_ptr<Language> current_language;
};
#endif // JUCI_PROJECT_H_

8
src/terminal.cc

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

58
src/window.cc

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

2
src/window.h

@ -33,8 +33,6 @@ private:
Gtk::AboutDialog about;
EntryBox entry_box;
std::unique_ptr<Project::Language> project_language;
void configure();
void set_menu_actions();
void activate_menu_items(bool activate=true);

Loading…
Cancel
Save