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. 30
      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; 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 Debug::is_invalid() {
bool invalid; bool invalid;
event_mutex.lock(); event_mutex.lock();

1
src/debug.h

@ -46,6 +46,7 @@ public:
void delete_debug(); //can't use delete as function name 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);
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_invalid();
bool is_stopped(); bool is_stopped();

30
src/source_clang.cc

@ -417,18 +417,26 @@ 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"); tooltip_buffer->insert_with_tag(tooltip_buffer->get_insert()->get_iter(), "\n\n"+brief_comment, "def:note");
#ifdef JUCI_ENABLE_DEBUG #ifdef JUCI_ENABLE_DEBUG
auto location=token.get_cursor().get_referenced().get_source_location(); if(Debug::get().is_stopped()) {
Glib::ustring debug_value=Debug::get().get_value(token.get_spelling(), location.get_path(), location.get_offset().line); auto location=token.get_cursor().get_referenced().get_source_location();
if(!debug_value.empty()) { Glib::ustring value_type="Value";
size_t pos=debug_value.find(" = "); Glib::ustring debug_value=Debug::get().get_value(token.get_spelling(), location.get_path(), location.get_offset().line);
if(pos!=Glib::ustring::npos) { if(debug_value.empty()) {
Glib::ustring::iterator iter; value_type="Return value";
while(!debug_value.validate(iter)) { auto location=token.get_cursor().get_source_location();
auto next_char_iter=iter; debug_value=Debug::get().get_return_value(token.get_spelling(), location.get_path(), location.get_offset().line, location.get_offset().index);
next_char_iter++; }
debug_value.replace(iter, next_char_iter, "?"); if(!debug_value.empty()) {
size_t pos=debug_value.find(" = ");
if(pos!=Glib::ustring::npos) {
Glib::ustring::iterator iter;
while(!debug_value.validate(iter)) {
auto next_char_iter=iter;
next_char_iter++;
debug_value.replace(iter, next_char_iter, "?");
}
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");
} }
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");
} }
} }
#endif #endif

Loading…
Cancel
Save