Browse Source

Fixes to debugging

merge-requests/365/head
eidheim 10 years ago
parent
commit
ba7c44d7f8
  1. 10
      src/debug.cc
  2. 2
      src/debug.h
  3. 3
      src/tooltips.cc
  4. 5
      src/tooltips.h
  5. 69
      src/window.cc
  6. 8
      src/window.h

10
src/debug.cc

@ -28,7 +28,7 @@ Debug::Debug(): listener("juCi++ lldb listener"), state(lldb::StateType::eStateI
void Debug::start(std::shared_ptr<std::vector<std::pair<boost::filesystem::path, int> > > breakpoints, const boost::filesystem::path &executable,
const boost::filesystem::path &path, std::function<void(int exit_status)> callback,
std::function<void(const std::string &status)> status_callback,
std::function<void(const boost::filesystem::path &file_path, int line_nr)> stop_callback) {
std::function<void(const boost::filesystem::path &file_path, int line_nr, int line_index)> stop_callback) {
auto target=debugger.CreateTarget(executable.string().c_str());
if(!target.IsValid()) {
@ -75,7 +75,7 @@ void Debug::start(std::shared_ptr<std::vector<std::pair<boost::filesystem::path,
if(stop_callback) {
lldb::SBStream stream;
line_entry.GetFileSpec().GetDescription(stream);
stop_callback(stream.GetData(), line_entry.GetLine());
stop_callback(stream.GetData(), line_entry.GetLine(), line_entry.GetColumn());
}
}
@ -86,7 +86,7 @@ void Debug::start(std::shared_ptr<std::vector<std::pair<boost::filesystem::path,
if(status_callback)
status_callback("");
if(stop_callback)
stop_callback("", 0);
stop_callback("", 0, 0);
process.reset();
this->state=lldb::StateType::eStateInvalid;
event_mutex.unlock();
@ -99,7 +99,7 @@ void Debug::start(std::shared_ptr<std::vector<std::pair<boost::filesystem::path,
if(status_callback)
status_callback("");
if(stop_callback)
stop_callback("", 0);
stop_callback("", 0, 0);
process.reset();
this->state=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<values.GetSize();value_index++) {
lldb::SBStream stream;

2
src/debug.h

@ -22,7 +22,7 @@ public:
const boost::filesystem::path &executable, const boost::filesystem::path &path="",
std::function<void(int exit_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)> stop_callback=nullptr);
std::function<void(const boost::filesystem::path &file_path, int line_nr, int line_index)> stop_callback=nullptr);
void continue_debug(); //can't use continue as function name
void stop();
void kill();

3
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;
}

5
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<Ts>(params)...);
}
static Gdk::Rectangle drawn_tooltips_rectangle;
private:
private:
std::list<Tooltip> tooltip_list;
};

69
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;c<notebook.size();c++) {
auto view=notebook.get_view(c);
if(view->file_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;c<notebook.size();c++) {
auto view=notebook.get_view(c);
if(view->file_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_nr<view->get_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_index<line.bytes()) {
view->get_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) {}

8
src/window.h

@ -36,11 +36,11 @@ private:
std::atomic<bool> debugging;
Gtk::Label debug_status_label;
std::pair<boost::filesystem::path, int> debug_last_stop_line;
std::pair<boost::filesystem::path, std::pair<int, int> > debug_last_stop;
std::pair<boost::filesystem::path, int> debug_stop_line;
std::mutex debug_stop_line_mutex;
Glib::Dispatcher debug_update_stop_line;
std::pair<boost::filesystem::path, std::pair<int, int> > 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;

Loading…
Cancel
Save