diff --git a/src/debug.cc b/src/debug.cc index 47c1e20..954bf27 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -24,7 +24,7 @@ using namespace std; //TODO: remove extern char **environ; void log(const char *msg, void *) { - cout << "debugger log: " << msg << endl; + std::cout << "debugger log: " << msg << std::endl; } Debug::Debug(): state(lldb::StateType::eStateInvalid), buffer_size(131072) { @@ -211,7 +211,7 @@ void Debug::start(const std::string &command, const boost::filesystem::path &pat } } event_mutex.unlock(); - this_thread::sleep_for(std::chrono::milliseconds(200)); + std::this_thread::sleep_for(std::chrono::milliseconds(200)); } }); } @@ -319,7 +319,7 @@ std::vector Debug::get_backtrace() { } std::vector Debug::get_variables() { - vector variables; + std::vector variables; event_mutex.lock(); if(state==lldb::StateType::eStateStopped) { for(uint32_t c_t=0;c_tGetNumThreads();c_t++) { @@ -335,6 +335,7 @@ std::vector Debug::get_variables() { if(declaration.IsValid()) { Debug::Variable variable; + variable.thread_index_id=thread.GetIndexID(); variable.frame_index=c_f; variable.name=value.GetName(); @@ -375,7 +376,7 @@ void Debug::delete_debug() { debug_thread.join(); } -std::string Debug::get_value(const std::string &variable, const boost::filesystem::path &file_path, unsigned int line_nr) { +std::string Debug::get_value(const std::string &variable, const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index) { std::string variable_value; event_mutex.lock(); if(state==lldb::StateType::eStateStopped) { @@ -390,7 +391,7 @@ std::string Debug::get_value(const std::string &variable, const boost::filesyste if(value.GetName()==variable) { auto declaration=value.GetDeclaration(); if(declaration.IsValid()) { - if(declaration.GetLine()==line_nr) { + if(declaration.GetLine()==line_nr && (declaration.GetColumn()==0 || declaration.GetColumn()==line_index)) { auto file_spec=declaration.GetFileSpec(); boost::filesystem::path value_decl_path=file_spec.GetDirectory(); value_decl_path/=file_spec.GetFilename(); diff --git a/src/debug.h b/src/debug.h index 91e4343..9900f9a 100644 --- a/src/debug.h +++ b/src/debug.h @@ -22,6 +22,7 @@ public: }; class Variable { public: + uint32_t thread_index_id; uint32_t frame_index; std::string name; std::string value; @@ -55,7 +56,7 @@ public: void delete_debug(); //can't use delete as function name - std::string get_value(const std::string &variable, const boost::filesystem::path &file_path, unsigned int line_nr); + std::string get_value(const std::string &variable, const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index); std::string get_return_value(const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index); bool is_invalid(); diff --git a/src/source_clang.cc b/src/source_clang.cc index a36a318..67a5128 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -420,7 +420,7 @@ void Source::ClangViewParse::show_type_tooltips(const Gdk::Rectangle &rectangle) if(Debug::get().is_stopped()) { auto location=token.get_cursor().get_referenced().get_source_location(); Glib::ustring value_type="Value"; - Glib::ustring debug_value=Debug::get().get_value(token.get_spelling(), location.get_path(), location.get_offset().line); + Glib::ustring debug_value=Debug::get().get_value(token.get_spelling(), location.get_path(), location.get_offset().line, location.get_offset().index); if(debug_value.empty()) { value_type="Return value"; auto location=token.get_cursor().get_source_location(); diff --git a/src/window.cc b/src/window.cc index 15c5d40..531cc3e 100644 --- a/src/window.cc +++ b/src/window.cc @@ -979,7 +979,7 @@ void Window::set_menu_actions() { return; for(auto &variable: variables) { - std::string row=variable.file_path.filename().string()+":"+std::to_string(variable.line_nr)+" - "+Glib::Markup::escape_text(variable.name)+""; + std::string row="#"+std::to_string(variable.thread_index_id)+":#"+std::to_string(variable.frame_index)+":"+variable.file_path.filename().string()+":"+std::to_string(variable.line_nr)+" - "+Glib::Markup::escape_text(variable.name)+""; (*rows)[row]=variable; view->selection_dialog->add_row(row);