Browse Source

Can now add/remove breakpoints when debug is in running state, also removes stop line mark when debug is in running state

merge-requests/365/head
eidheim 10 years ago
parent
commit
dc8dcae1ff
  1. 9
      src/debug.cc
  2. 8
      src/window.cc

9
src/debug.cc

@ -87,7 +87,9 @@ void Debug::start(std::shared_ptr<std::vector<std::pair<boost::filesystem::path,
stop_callback("", 0, 0); stop_callback("", 0, 0);
} }
} }
else if(state==lldb::StateType::eStateRunning) {
stop_callback("", 0, 0);
}
else if(state==lldb::StateType::eStateExited) { else if(state==lldb::StateType::eStateExited) {
auto exit_status=process->GetExitStatus(); auto exit_status=process->GetExitStatus();
if(callback) if(callback)
@ -101,7 +103,6 @@ void Debug::start(std::shared_ptr<std::vector<std::pair<boost::filesystem::path,
event_mutex.unlock(); event_mutex.unlock();
return; return;
} }
else if(state==lldb::StateType::eStateCrashed) { else if(state==lldb::StateType::eStateCrashed) {
if(callback) if(callback)
callback(-1); callback(-1);
@ -250,7 +251,7 @@ bool Debug::is_running() {
void Debug::add_breakpoint(const boost::filesystem::path &file_path, int line_nr) { void Debug::add_breakpoint(const boost::filesystem::path &file_path, int line_nr) {
event_mutex.lock(); event_mutex.lock();
if(state==lldb::eStateStopped) { if(state==lldb::eStateStopped || state==lldb::eStateRunning) {
if(!(process->GetTarget().BreakpointCreateByLocation(file_path.string().c_str(), line_nr)).IsValid()) if(!(process->GetTarget().BreakpointCreateByLocation(file_path.string().c_str(), line_nr)).IsValid())
Terminal::get().async_print("Error (debug): Could not create breakpoint at: "+file_path.string()+":"+std::to_string(line_nr)+'\n', true); Terminal::get().async_print("Error (debug): Could not create breakpoint at: "+file_path.string()+":"+std::to_string(line_nr)+'\n', true);
} }
@ -259,7 +260,7 @@ void Debug::add_breakpoint(const boost::filesystem::path &file_path, int line_nr
void Debug::remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) { void Debug::remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) {
event_mutex.lock(); event_mutex.lock();
if(state==lldb::eStateStopped) { if(state==lldb::eStateStopped || state==lldb::eStateRunning) {
auto target=process->GetTarget(); auto target=process->GetTarget();
for(int line_nr_try=line_nr;line_nr_try<line_count;line_nr_try++) { for(int line_nr_try=line_nr;line_nr_try<line_count;line_nr_try++) {
for(uint32_t b_index=0;b_index<target.GetNumBreakpoints();b_index++) { for(uint32_t b_index=0;b_index<target.GetNumBreakpoints();b_index++) {

8
src/window.cc

@ -770,8 +770,8 @@ void Window::set_menu_actions() {
entry_box.show(); entry_box.show();
}); });
menu.add_action("debug_toggle_breakpoint", [this](){ menu.add_action("debug_toggle_breakpoint", [this](){
bool debug_is_stopped=Debug::get().is_stopped(); bool debug_is_stopped_or_running=Debug::get().is_stopped() || Debug::get().is_running();
if(Debug::get().is_invalid() || debug_is_stopped) { if(Debug::get().is_invalid() || debug_is_stopped_or_running) {
if(notebook.get_current_page()!=-1) { if(notebook.get_current_page()!=-1) {
auto view=notebook.get_current_view(); auto view=notebook.get_current_view();
auto line_nr=view->get_buffer()->get_insert()->get_iter().get_line(); auto line_nr=view->get_buffer()->get_insert()->get_iter().get_line();
@ -781,12 +781,12 @@ 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(debug_is_stopped) if(debug_is_stopped_or_running)
Debug::get().remove_breakpoint(view->file_path, line_nr+1, view->get_buffer()->get_line_count()+1); Debug::get().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(debug_is_stopped) if(debug_is_stopped_or_running)
Debug::get().add_breakpoint(view->file_path, line_nr+1); Debug::get().add_breakpoint(view->file_path, line_nr+1);
} }
} }

Loading…
Cancel
Save