Browse Source

Revert "Debug return value now found based on previous frame function name"

This reverts commit 534a245453.
merge-requests/365/head
eidheim 10 years ago
parent
commit
30f7411ccf
  1. 13
      src/debug.cc
  2. 5
      src/debug.h
  3. 3
      src/source_clang.cc

13
src/debug.cc

@ -126,13 +126,6 @@ void Debug::start(const std::string &command, const boost::filesystem::path &pat
break; break;
} }
} }
last_function_name=current_function_name;
auto function_name_cstr=process->GetSelectedThread().GetSelectedFrame().GetFunctionName();
if(function_name_cstr!=NULL)
current_function_name=function_name_cstr;
else
current_function_name.clear();
} }
//Update debug status //Update debug status
@ -382,7 +375,7 @@ 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 &function_name, const boost::filesystem::path &file_path) { std::string Debug::get_return_value(const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index) {
std::string return_value; std::string return_value;
event_mutex.lock(); event_mutex.lock();
if(state==lldb::StateType::eStateStopped) { if(state==lldb::StateType::eStateStopped) {
@ -393,8 +386,8 @@ std::string Debug::get_return_value(const std::string &function_name, const boos
if(line_entry.IsValid()) { if(line_entry.IsValid()) {
lldb::SBStream stream; lldb::SBStream stream;
line_entry.GetFileSpec().GetDescription(stream); line_entry.GetFileSpec().GetDescription(stream);
auto pos=last_function_name.find('('); if(boost::filesystem::path(stream.GetData())==file_path && line_entry.GetLine()==line_nr &&
if(pos!=std::string::npos && last_function_name.substr(0, pos)==function_name && boost::filesystem::path(stream.GetData())==file_path) { (line_entry.GetColumn()==0 || line_entry.GetColumn()==line_index)) {
lldb::SBStream stream; lldb::SBStream stream;
thread_return_value.GetDescription(stream); thread_return_value.GetDescription(stream);
return_value=stream.GetData(); return_value=stream.GetData();

5
src/debug.h

@ -46,7 +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 &function_name, const boost::filesystem::path &file_path); std::string get_return_value(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();
@ -67,9 +67,6 @@ private:
std::mutex event_mutex; std::mutex event_mutex;
size_t buffer_size; size_t buffer_size;
std::string last_function_name;
std::string current_function_name;
}; };
#endif #endif

3
src/source_clang.cc

@ -423,7 +423,8 @@ void Source::ClangViewParse::show_type_tooltips(const Gdk::Rectangle &rectangle)
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);
if(debug_value.empty()) { if(debug_value.empty()) {
value_type="Return value"; value_type="Return value";
debug_value=Debug::get().get_return_value(token.get_spelling(), token.get_cursor().get_source_location().get_path()); auto location=token.get_cursor().get_source_location();
debug_value=Debug::get().get_return_value(location.get_path(), location.get_offset().line, location.get_offset().index);
} }
if(!debug_value.empty()) { if(!debug_value.empty()) {
size_t pos=debug_value.find(" = "); size_t pos=debug_value.find(" = ");

Loading…
Cancel
Save