From 70a1e106b1d8b63da1f5e4ea781bd52ae715e7c8 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 6 Jul 2016 22:39:44 +0200 Subject: [PATCH] Selecting variable in debug show variables now moves cursor to frame if no declaration was found --- src/debug_lldb.cc | 15 +++++++++++++++ src/debug_lldb.h | 1 + src/project.cc | 7 +++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/debug_lldb.cc b/src/debug_lldb.cc index b81a583..57d269e 100644 --- a/src/debug_lldb.cc +++ b/src/debug_lldb.cc @@ -358,6 +358,7 @@ std::vector Debug::LLDB::get_variables() { auto declaration=value.GetDeclaration(); if(declaration.IsValid()) { + variable.declaration_found=true; variable.line_nr=declaration.GetLine(); variable.line_index=declaration.GetColumn(); if(variable.line_index==0) @@ -367,6 +368,20 @@ std::vector Debug::LLDB::get_variables() { variable.file_path=filesystem::get_canonical_path(file_spec.GetDirectory()); variable.file_path/=file_spec.GetFilename(); } + else { + variable.declaration_found=false; + auto line_entry=frame.GetLineEntry(); + if(line_entry.IsValid()) { + variable.line_nr=line_entry.GetLine(); + variable.line_index=line_entry.GetColumn(); + if(variable.line_index==0) + variable.line_index=1; + + auto file_spec=line_entry.GetFileSpec(); + variable.file_path=filesystem::get_canonical_path(file_spec.GetDirectory()); + variable.file_path/=file_spec.GetFilename(); + } + } variables.emplace_back(variable); } } diff --git a/src/debug_lldb.h b/src/debug_lldb.h index 20f7276..5c2adfc 100644 --- a/src/debug_lldb.h +++ b/src/debug_lldb.h @@ -27,6 +27,7 @@ namespace Debug { uint32_t frame_index; std::string name; std::string value; + bool declaration_found; boost::filesystem::path file_path; int line_nr; int line_index; diff --git a/src/project.cc b/src/project.cc index 5cce052..b3b6a99 100644 --- a/src/project.cc +++ b/src/project.cc @@ -476,17 +476,16 @@ void Project::Clang::debug_show_variables() { view->selection_dialog->on_select=[this, rows](const std::string& selected, bool hide_window) { auto variable=rows->at(selected); + Debug::LLDB::get().select_frame(variable.frame_index, variable.thread_index_id); if(!variable.file_path.empty()) { Notebook::get().open(variable.file_path); if(auto view=Notebook::get().get_current_view()) { - Debug::LLDB::get().select_frame(variable.frame_index, variable.thread_index_id); - view->place_cursor_at_line_index(variable.line_nr-1, variable.line_index-1); view->scroll_to_cursor_delayed(view, true, true); } } - else - Info::get().print("Debugger did not report declaration for the variable: "+variable.name); + if(!variable.declaration_found) + Info::get().print("Debugger did not find declaration for the variable: "+variable.name); }; view->selection_dialog->on_hide=[this]() {