diff --git a/src/debug.cc b/src/debug.cc index 9a0b863..dbf7a8b 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -28,7 +28,7 @@ Debug::Debug(): listener("juCi++ lldb listener"), state(lldb::StateType::eStateI void Debug::start(std::shared_ptr > > breakpoints, const boost::filesystem::path &executable, const boost::filesystem::path &path, std::function callback, std::function status_callback, - std::function stop_callback) { + std::function stop_callback) { auto target=debugger.CreateTarget(executable.string().c_str()); if(!target.IsValid()) { @@ -75,7 +75,7 @@ void Debug::start(std::shared_ptrstate=lldb::StateType::eStateInvalid; event_mutex.unlock(); @@ -99,7 +99,7 @@ void Debug::start(std::shared_ptrstate=lldb::StateType::eStateInvalid; event_mutex.unlock(); @@ -178,7 +178,7 @@ std::string Debug::get_value(const std::string &variable, const boost::filesyste if(state==lldb::StateType::eStateStopped) { auto frame=process->GetSelectedThread().GetSelectedFrame(); - auto values=frame.GetVariables(true, true, true, true); + auto values=frame.GetVariables(true, true, true, false); //First try to find variable based on name, file and line number for(uint32_t value_index=0;value_index callback=nullptr, std::function status_callback=nullptr, - std::function stop_callback=nullptr); + std::function stop_callback=nullptr); void continue_debug(); //can't use continue as function name void stop(); void kill(); diff --git a/src/tooltips.cc b/src/tooltips.cc index 9874c6b..b177f62 100644 --- a/src/tooltips.cc +++ b/src/tooltips.cc @@ -143,6 +143,7 @@ void Tooltips::show(const Gdk::Rectangle& rectangle, bool disregard_drawn) { if(rectangle.intersects(tooltip.activation_rectangle)) { tooltip.adjust(disregard_drawn); tooltip.window->show_all(); + shown=true; } else if(tooltip.window) tooltip.window->hide(); @@ -154,6 +155,7 @@ void Tooltips::show(bool disregard_drawn) { tooltip.update(); tooltip.adjust(disregard_drawn); tooltip.window->show_all(); + shown=true; } } @@ -162,4 +164,5 @@ void Tooltips::hide() { if(tooltip.window) tooltip.window->hide(); } + shown=false; } diff --git a/src/tooltips.h b/src/tooltips.h index 4f21953..66d87a9 100644 --- a/src/tooltips.h +++ b/src/tooltips.h @@ -30,6 +30,7 @@ public: static void init() {drawn_tooltips_rectangle=Gdk::Rectangle();} void show(const Gdk::Rectangle& rectangle, bool disregard_drawn=false); void show(bool disregard_drawn=false); + bool shown=false; void hide(); void clear() {tooltip_list.clear();}; @@ -37,10 +38,10 @@ public: void emplace_back(Ts&&... params) { tooltip_list.emplace_back(std::forward(params)...); } - + static Gdk::Rectangle drawn_tooltips_rectangle; - private: +private: std::list tooltip_list; }; diff --git a/src/window.cc b/src/window.cc index 1767517..be1d648 100644 --- a/src/window.cc +++ b/src/window.cc @@ -116,12 +116,12 @@ Window::Window() : compiling(false), debugging(false) { about.hide(); }); - debug_update_stop_line.connect([this](){ - debug_stop_line_mutex.lock(); + debug_update_stop.connect([this](){ + debug_stop_mutex.lock(); for(int c=0;cfile_path==debug_last_stop_line.first) { - auto start_iter=view->get_buffer()->get_iter_at_line(debug_last_stop_line.second-1); + if(view->file_path==debug_last_stop.first) { + auto start_iter=view->get_buffer()->get_iter_at_line(debug_last_stop.second.first-1); 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_stop"); @@ -131,12 +131,14 @@ Window::Window() : compiling(false), debugging(false) { //Add debug stop source mark for(int c=0;cfile_path==debug_stop_line.first) { - view->get_source_buffer()->create_source_mark("debug_stop", view->get_buffer()->get_iter_at_line(debug_stop_line.second-1)); - debug_last_stop_line=debug_stop_line; + if(view->file_path==debug_stop.first) { + view->get_source_buffer()->create_source_mark("debug_stop", view->get_buffer()->get_iter_at_line(debug_stop.second.first-1)); + debug_last_stop=debug_stop; + view->get_buffer()->place_cursor(view->get_buffer()->get_insert()->get_iter()); + break; } } - debug_stop_line_mutex.unlock(); + debug_stop_mutex.unlock(); }); debug_update_status.connect([this](){ debug_status_mutex.lock(); @@ -440,10 +442,10 @@ void Window::set_menu_actions() { auto end_line_index=iter.get_line_index(); index=std::min(index, end_line_index); + view->get_buffer()->place_cursor(view->get_buffer()->get_iter_at_line_index(line, index)); while(g_main_context_pending(NULL)) g_main_context_iteration(NULL, false); if(notebook.get_current_page()!=-1 && notebook.get_current_view()==view) { - view->get_buffer()->place_cursor(view->get_buffer()->get_iter_at_line_index(line, index)); view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5); view->delayed_tooltips_connection.disconnect(); } @@ -720,12 +722,13 @@ void Window::set_menu_actions() { debug_status=status; debug_status_mutex.unlock(); debug_update_status(); - }, [this](const boost::filesystem::path &file_path, int line_nr) { - debug_stop_line_mutex.lock(); - debug_stop_line.first=file_path; - debug_stop_line.second=line_nr; - debug_stop_line_mutex.unlock(); - debug_update_stop_line(); + }, [this](const boost::filesystem::path &file_path, int line_nr, int line_index) { + debug_stop_mutex.lock(); + debug_stop.first=file_path; + debug_stop.second.first=line_nr; + debug_stop.second.second=line_index; + debug_stop_mutex.unlock(); + debug_update_stop(); //Remove debug stop source mark }); } @@ -784,18 +787,29 @@ void Window::set_menu_actions() { }); menu.add_action("debug_goto_stop", [this](){ if(debugging) { - debug_stop_line_mutex.lock(); - auto debug_stop_line_copy=debug_stop_line; - debug_stop_line_mutex.unlock(); - notebook.open(debug_stop_line_copy.first); + debug_stop_mutex.lock(); + auto debug_stop_copy=debug_stop; + debug_stop_mutex.unlock(); + notebook.open(debug_stop_copy.first); if(notebook.get_current_page()!=-1) { auto view=notebook.get_current_view(); - debug_update_stop_line(); - while(g_main_context_pending(NULL)) - g_main_context_iteration(NULL, false); - if(notebook.get_current_page()!=-1 && notebook.get_current_view()==view) { - view->get_buffer()->place_cursor(view->get_buffer()->get_iter_at_line(debug_stop_line_copy.second-1)); - view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5); + debug_update_stop(); + + int line_nr=debug_stop_copy.second.first-1; + int line_index= debug_stop_copy.second.second-1; + if(line_nrget_buffer()->get_line_count()) { + auto iter=view->get_buffer()->get_iter_at_line(line_nr); + auto end_line_iter=iter; + while(!iter.ends_line() && iter.forward_char()) {} + auto line=view->get_buffer()->get_text(iter, end_line_iter); + if(line_indexget_buffer()->place_cursor(view->get_buffer()->get_iter_at_line_index(line_nr, line_index)); + + while(g_main_context_pending(NULL)) + g_main_context_iteration(NULL, false); + if(notebook.get_current_page()!=-1 && notebook.get_current_view()==view) + view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5); + } } } } @@ -1050,12 +1064,11 @@ void Window::goto_line_entry() { if(line>0 && line<=view->get_buffer()->get_line_count()) { line--; + view->get_buffer()->place_cursor(view->get_buffer()->get_iter_at_line(line)); while(g_main_context_pending(NULL)) g_main_context_iteration(NULL, false); - if(notebook.get_current_page()!=-1 && notebook.get_current_view()==view) { - view->get_buffer()->place_cursor(view->get_buffer()->get_iter_at_line(line)); + if(notebook.get_current_page()!=-1 && notebook.get_current_view()==view) view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5); - } } } catch(const std::exception &e) {} diff --git a/src/window.h b/src/window.h index 973be5f..2c8b535 100644 --- a/src/window.h +++ b/src/window.h @@ -36,11 +36,11 @@ private: std::atomic debugging; Gtk::Label debug_status_label; - std::pair debug_last_stop_line; + std::pair > debug_last_stop; - std::pair debug_stop_line; - std::mutex debug_stop_line_mutex; - Glib::Dispatcher debug_update_stop_line; + std::pair > debug_stop; + std::mutex debug_stop_mutex; + Glib::Dispatcher debug_update_stop; std::string debug_status; std::mutex debug_status_mutex; Glib::Dispatcher debug_update_status;