Browse Source

Added return value (lldb supports this when doing step out)

merge-requests/365/head
eidheim 10 years ago
parent
commit
6d6d2f31da
  1. 23
      src/debug.cc
  2. 1
      src/debug.h
  3. 10
      src/source_clang.cc

23
src/debug.cc

@ -375,6 +375,29 @@ std::string Debug::get_value(const std::string &variable, const boost::filesyste
return variable_value;
}
std::string Debug::get_return_value(const std::string &variable, const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index) {
std::string return_value;
event_mutex.lock();
if(state==lldb::StateType::eStateStopped) {
auto thread=process->GetSelectedThread();
auto thread_return_value=thread.GetStopReturnValue();
if(thread_return_value.IsValid()) {
auto line_entry=thread.GetSelectedFrame().GetLineEntry();
if(line_entry.IsValid()) {
lldb::SBStream stream;
line_entry.GetFileSpec().GetDescription(stream);
if(boost::filesystem::path(stream.GetData())==file_path && line_entry.GetLine()==line_nr && line_entry.GetColumn()==line_index) {
lldb::SBStream stream;
thread_return_value.GetDescription(stream);
return_value=stream.GetData();
}
}
}
}
event_mutex.unlock();
return return_value;
}
bool Debug::is_invalid() {
bool invalid;
event_mutex.lock();

1
src/debug.h

@ -46,6 +46,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_return_value(const std::string &variable, const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index);
bool is_invalid();
bool is_stopped();

10
src/source_clang.cc

@ -417,8 +417,15 @@ void Source::ClangViewParse::show_type_tooltips(const Gdk::Rectangle &rectangle)
tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), "\n\n"+brief_comment, "def:note");
#ifdef JUCI_ENABLE_DEBUG
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);
if(debug_value.empty()) {
value_type="Return value";
auto location=token.get_cursor().get_source_location();
debug_value=Debug::get().get_return_value(token.get_spelling(), location.get_path(), location.get_offset().line, location.get_offset().index);
}
if(!debug_value.empty()) {
size_t pos=debug_value.find(" = ");
if(pos!=Glib::ustring::npos) {
@ -428,7 +435,8 @@ void Source::ClangViewParse::show_type_tooltips(const Gdk::Rectangle &rectangle)
next_char_iter++;
debug_value.replace(iter, next_char_iter, "?");
}
tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), "\n\nValue: "+debug_value.substr(pos+3, debug_value.size()-(pos+3)-1), "def:note");
tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), "\n\n"+value_type+": "+debug_value.substr(pos+3, debug_value.size()-(pos+3)-1), "def:note");
}
}
}
#endif

Loading…
Cancel
Save