Browse Source

Debug show variables finished

merge-requests/365/head
eidheim 10 years ago
parent
commit
653d77776f
  1. 11
      src/debug.cc
  2. 3
      src/debug.h
  3. 2
      src/source_clang.cc
  4. 2
      src/window.cc

11
src/debug.cc

@ -24,7 +24,7 @@ using namespace std; //TODO: remove
extern char **environ; extern char **environ;
void log(const char *msg, void *) { 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) { 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(); 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::Frame> Debug::get_backtrace() {
} }
std::vector<Debug::Variable> Debug::get_variables() { std::vector<Debug::Variable> Debug::get_variables() {
vector<Debug::Variable> variables; std::vector<Debug::Variable> variables;
event_mutex.lock(); event_mutex.lock();
if(state==lldb::StateType::eStateStopped) { if(state==lldb::StateType::eStateStopped) {
for(uint32_t c_t=0;c_t<process->GetNumThreads();c_t++) { for(uint32_t c_t=0;c_t<process->GetNumThreads();c_t++) {
@ -335,6 +335,7 @@ std::vector<Debug::Variable> Debug::get_variables() {
if(declaration.IsValid()) { if(declaration.IsValid()) {
Debug::Variable variable; Debug::Variable variable;
variable.thread_index_id=thread.GetIndexID();
variable.frame_index=c_f; variable.frame_index=c_f;
variable.name=value.GetName(); variable.name=value.GetName();
@ -375,7 +376,7 @@ void Debug::delete_debug() {
debug_thread.join(); 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; std::string variable_value;
event_mutex.lock(); event_mutex.lock();
if(state==lldb::StateType::eStateStopped) { 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) { if(value.GetName()==variable) {
auto declaration=value.GetDeclaration(); auto declaration=value.GetDeclaration();
if(declaration.IsValid()) { 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(); auto file_spec=declaration.GetFileSpec();
boost::filesystem::path value_decl_path=file_spec.GetDirectory(); boost::filesystem::path value_decl_path=file_spec.GetDirectory();
value_decl_path/=file_spec.GetFilename(); value_decl_path/=file_spec.GetFilename();

3
src/debug.h

@ -22,6 +22,7 @@ public:
}; };
class Variable { class Variable {
public: public:
uint32_t thread_index_id;
uint32_t frame_index; uint32_t frame_index;
std::string name; std::string name;
std::string value; std::string value;
@ -55,7 +56,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, unsigned int line_index);
std::string get_return_value(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(); bool is_invalid();

2
src/source_clang.cc

@ -420,7 +420,7 @@ void Source::ClangViewParse::show_type_tooltips(const Gdk::Rectangle &rectangle)
if(Debug::get().is_stopped()) { if(Debug::get().is_stopped()) {
auto location=token.get_cursor().get_referenced().get_source_location(); auto location=token.get_cursor().get_referenced().get_source_location();
Glib::ustring value_type="Value"; 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()) { if(debug_value.empty()) {
value_type="Return value"; value_type="Return value";
auto location=token.get_cursor().get_source_location(); auto location=token.get_cursor().get_source_location();

2
src/window.cc

@ -979,7 +979,7 @@ void Window::set_menu_actions() {
return; return;
for(auto &variable: variables) { for(auto &variable: variables) {
std::string row=variable.file_path.filename().string()+":"+std::to_string(variable.line_nr)+" - <b>"+Glib::Markup::escape_text(variable.name)+"</b>"; 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)+" - <b>"+Glib::Markup::escape_text(variable.name)+"</b>";
(*rows)[row]=variable; (*rows)[row]=variable;
view->selection_dialog->add_row(row); view->selection_dialog->add_row(row);

Loading…
Cancel
Save