Browse Source

Added remote debugging, and some minor cleanup

merge-requests/365/head
eidheim 10 years ago
parent
commit
2de9932835
  1. 13
      src/debug_clang.cc
  2. 3
      src/debug_clang.h
  3. 4
      src/notebook.cc
  4. 33
      src/project.cc
  5. 5
      src/project.h
  6. 6
      src/source.cc
  7. 4
      src/window.cc

13
src/debug_clang.cc

@ -41,7 +41,8 @@ void Debug::Clang::start(const std::string &command, const boost::filesystem::pa
const std::vector<std::pair<boost::filesystem::path, int> > &breakpoints, const std::vector<std::pair<boost::filesystem::path, int> > &breakpoints,
std::function<void(int exit_status)> callback, std::function<void(int exit_status)> callback,
std::function<void(const std::string &status)> status_callback, std::function<void(const std::string &status)> status_callback,
std::function<void(const boost::filesystem::path &file_path, int line_nr, int line_index)> stop_callback) { std::function<void(const boost::filesystem::path &file_path, int line_nr, int line_index)> stop_callback,
const std::string &plugin, const std::string &url) {
if(!debugger) { if(!debugger) {
lldb::SBDebugger::Initialize(); lldb::SBDebugger::Initialize();
debugger=std::unique_ptr<lldb::SBDebugger>(new lldb::SBDebugger(lldb::SBDebugger::Create(true, log, nullptr))); debugger=std::unique_ptr<lldb::SBDebugger>(new lldb::SBDebugger(lldb::SBDebugger::Create(true, log, nullptr)));
@ -100,6 +101,9 @@ void Debug::Clang::start(const std::string &command, const boost::filesystem::pa
} }
lldb::SBError error; lldb::SBError error;
if(!plugin.empty() && plugin!="host")
process = std::unique_ptr<lldb::SBProcess>(new lldb::SBProcess(target.ConnectRemote(*listener, url.c_str(), plugin.c_str(), error)));
else
process = std::unique_ptr<lldb::SBProcess>(new lldb::SBProcess(target.Launch(*listener, argv, const_cast<const char**>(environ), nullptr, nullptr, nullptr, path.string().c_str(), lldb::eLaunchFlagNone, false, error))); process = std::unique_ptr<lldb::SBProcess>(new lldb::SBProcess(target.Launch(*listener, argv, const_cast<const char**>(environ), nullptr, nullptr, nullptr, path.string().c_str(), lldb::eLaunchFlagNone, false, error)));
if(error.Fail()) { if(error.Fail()) {
Terminal::get().async_print(std::string("Error (debug): ")+error.GetCString()+'\n', true); Terminal::get().async_print(std::string("Error (debug): ")+error.GetCString()+'\n', true);
@ -486,6 +490,10 @@ void Debug::Clang::write(const std::string &buffer) {
std::vector<std::string> Debug::Clang::get_platform_list() { std::vector<std::string> Debug::Clang::get_platform_list() {
//Could not find a way to do this through liblldb //Could not find a way to do this through liblldb
static std::vector<std::string> platform_list;
if(!platform_list.empty())
return platform_list;
std::stringstream stream; std::stringstream stream;
Process process(Config::get().terminal.lldb_command, "", [&stream](const char *bytes, size_t n) { Process process(Config::get().terminal.lldb_command, "", [&stream](const char *bytes, size_t n) {
stream.write(bytes, n); stream.write(bytes, n);
@ -494,10 +502,9 @@ std::vector<std::string> Debug::Clang::get_platform_list() {
process.close_stdin(); process.close_stdin();
auto exit_status=process.get_exit_status(); auto exit_status=process.get_exit_status();
if(exit_status!=0) { if(exit_status!=0) {
Terminal::get().print("Error (debug): "+Config::get().terminal.lldb_command+" returned "+std::to_string(exit_status)+'\n'); Terminal::get().print("Error (debug): "+Config::get().terminal.lldb_command+" returned "+std::to_string(exit_status)+'\n', true);
return {}; return {};
} }
std::vector<std::string> platform_list;
std::string line; std::string line;
while(std::getline(stream, line)) { while(std::getline(stream, line)) {
if(line.find("host")==0 || line.find("remote-")==0) { if(line.find("host")==0 || line.find("remote-")==0) {

3
src/debug_clang.h

@ -43,7 +43,8 @@ namespace Debug {
const std::vector<std::pair<boost::filesystem::path, int> > &breakpoints={}, const std::vector<std::pair<boost::filesystem::path, int> > &breakpoints={},
std::function<void(int exit_status)> callback=nullptr, std::function<void(int exit_status)> callback=nullptr,
std::function<void(const std::string &status)> status_callback=nullptr, std::function<void(const std::string &status)> status_callback=nullptr,
std::function<void(const boost::filesystem::path &file_path, int line_nr, int line_index)> stop_callback=nullptr); std::function<void(const boost::filesystem::path &file_path, int line_nr, int line_index)> stop_callback=nullptr,
const std::string &plugin="", const std::string &url="");
void continue_debug(); //can't use continue as function name void continue_debug(); //can't use continue as function name
void stop(); void stop();
void kill(); void kill();

4
src/notebook.cc

@ -444,8 +444,10 @@ std::pair<size_t, int> Notebook::get_notebook_page(size_t index) {
void Notebook::set_current_view(Source::View *view) { void Notebook::set_current_view(Source::View *view) {
intermediate_view=nullptr; intermediate_view=nullptr;
if(current_view!=view) { if(current_view!=view) {
if(auto view=get_current_view()) if(auto view=get_current_view()) {
view->hide_tooltips();
view->hide_dialogs(); view->hide_dialogs();
}
current_view=view; current_view=view;
if(on_change_page) if(on_change_page)
on_change_page(view); on_change_page(view);

33
src/project.cc

@ -158,28 +158,26 @@ void Project::Base::debug_start() {
#ifdef JUCI_ENABLE_DEBUG #ifdef JUCI_ENABLE_DEBUG
Project::Clang::DebugOptionsPopover::DebugOptionsPopover() : Gtk::Popover() { Project::Clang::DebugOptionsPopover::DebugOptionsPopover() : Gtk::Popover() {
auto platform_list=Debug::Clang::get_platform_list(); auto lldb_platform_list=Debug::Clang::get_platform_list();
for(auto &platform: platform_list) for(auto &platform: lldb_platform_list)
platform_list_combo_box_text.append(platform); platform_list.append(platform);
if(platform_list_combo_box_text.get_model()->children().size()>0) if(platform_list.get_model()->children().size()>0)
platform_list_combo_box_text.set_active(0); platform_list.set_active(0);
url_entry.set_sensitive(false); url.set_sensitive(false);
platform_list_combo_box_text.signal_changed().connect([this]() { platform_list.signal_changed().connect([this]() {
url_entry.set_sensitive(platform_list_combo_box_text.get_active_row_number()>0); url.set_sensitive(platform_list.get_active_row_number()>0);
}); });
url_entry.set_placeholder_text("URL"); url.set_placeholder_text("URL");
cross_compiling_vbox.pack_start(platform_list_combo_box_text, true, true); cross_compiling_vbox.pack_start(platform_list, true, true);
cross_compiling_vbox.pack_end(url_entry, true, true); cross_compiling_vbox.pack_end(url, true, true);
cross_compiling_frame.set_label("Cross Compiling"); cross_compiling_frame.set_label("Cross Compiling");
cross_compiling_frame.add(cross_compiling_vbox); cross_compiling_frame.add(cross_compiling_vbox);
vbox.pack_start(cross_compiling_frame, true, true); vbox.pack_start(cross_compiling_frame, true, true);
not_yet_implemented_label.set_text("Not yet implemented");
vbox.pack_end(not_yet_implemented_label, true, true);
add(vbox); add(vbox);
show_all(); show_all();
set_visible(false); set_visible(false);
@ -351,6 +349,13 @@ void Project::Clang::debug_start() {
if(exit_status!=EXIT_SUCCESS) if(exit_status!=EXIT_SUCCESS)
debugging=false; debugging=false;
else { else {
std::string plugin, url;
auto options_it=debug_options_popovers.find(project_path.string());
if(options_it!=debug_options_popovers.end()) {
auto plugin_selection=options_it->second.platform_list.get_active_text();
plugin=plugin_selection.substr(0, plugin_selection.find("\n"));
url=options_it->second.url.get_text();
}
std::unique_lock<std::mutex> lock(debug_start_mutex); std::unique_lock<std::mutex> lock(debug_start_mutex);
Debug::Clang::get().start(run_arguments, project_path, *breakpoints, [this, run_arguments](int exit_status){ Debug::Clang::get().start(run_arguments, project_path, *breakpoints, [this, run_arguments](int exit_status){
debugging=false; debugging=false;
@ -369,7 +374,7 @@ void Project::Clang::debug_start() {
if(auto view=Notebook::get().get_current_view()) if(auto view=Notebook::get().get_current_view())
view->get_buffer()->place_cursor(view->get_buffer()->get_insert()->get_iter()); view->get_buffer()->place_cursor(view->get_buffer()->get_insert()->get_iter());
}); });
}); }, plugin, url);
} }
}); });
} }

5
src/project.h

@ -61,13 +61,12 @@ namespace Project {
class DebugOptionsPopover : public Gtk::Popover { class DebugOptionsPopover : public Gtk::Popover {
public: public:
DebugOptionsPopover(); DebugOptionsPopover();
Gtk::ComboBoxText platform_list;
Gtk::Entry url;
private: private:
Gtk::VBox vbox; Gtk::VBox vbox;
Gtk::Frame cross_compiling_frame; Gtk::Frame cross_compiling_frame;
Gtk::VBox cross_compiling_vbox; Gtk::VBox cross_compiling_vbox;
Gtk::ComboBoxText platform_list_combo_box_text;
Gtk::Entry url_entry;
Gtk::Label not_yet_implemented_label;
}; };
static std::unordered_map<std::string, DebugOptionsPopover> debug_options_popovers; static std::unordered_map<std::string, DebugOptionsPopover> debug_options_popovers;
#endif #endif

6
src/source.cc

@ -418,7 +418,7 @@ void Source::View::set_tooltip_and_dialog_events() {
delayed_tooltips_connection.disconnect(); delayed_tooltips_connection.disconnect();
if(mark->get_name()=="insert") { if(mark->get_name()=="insert") {
delayed_tooltips_connection.disconnect(); hide_tooltips();
delayed_tooltips_connection=Glib::signal_timeout().connect([this]() { delayed_tooltips_connection=Glib::signal_timeout().connect([this]() {
Tooltips::init(); Tooltips::init();
Gdk::Rectangle rectangle; Gdk::Rectangle rectangle;
@ -434,8 +434,6 @@ void Source::View::set_tooltip_and_dialog_events() {
} }
return false; return false;
}, 500); }, 500);
type_tooltips.hide();
diagnostic_tooltips.hide();
if(autocomplete_dialog) if(autocomplete_dialog)
autocomplete_dialog->hide(); autocomplete_dialog->hide();
@ -458,7 +456,7 @@ void Source::View::set_tooltip_and_dialog_events() {
}); });
signal_leave_notify_event().connect([this](GdkEventCrossing*) { signal_leave_notify_event().connect([this](GdkEventCrossing*) {
delayed_tooltips_connection.disconnect(); hide_tooltips();
return false; return false;
}); });
} }

4
src/window.cc

@ -147,8 +147,10 @@ Window::Window() {
}; };
signal_focus_out_event().connect([](GdkEventFocus *event) { signal_focus_out_event().connect([](GdkEventFocus *event) {
if(auto view=Notebook::get().get_current_view()) if(auto view=Notebook::get().get_current_view()) {
view->hide_tooltips();
view->hide_dialogs(); view->hide_dialogs();
}
return false; return false;
}); });

Loading…
Cancel
Save