Browse Source

Renamed debug/Debug to debug_clang/DebugClang

merge-requests/365/head
eidheim 10 years ago
parent
commit
f1bfcb4402
  1. 2
      src/CMakeLists.txt
  2. 48
      src/debug_clang.cc
  3. 12
      src/debug_clang.h
  4. 36
      src/project.cc
  5. 8
      src/source_clang.cc
  6. 6
      src/terminal.cc

2
src/CMakeLists.txt

@ -107,7 +107,7 @@ set(source_files juci.h
../tiny-process-library/process.cpp)
if(LIBLLDB_FOUND)
list(APPEND source_files debug.h debug.cc)
list(APPEND source_files debug_clang.h debug_clang.cc)
endif()
if(MSYS)

48
src/debug.cc → src/debug_clang.cc

@ -1,4 +1,4 @@
#include "debug.h"
#include "debug_clang.h"
#include <stdio.h>
#ifdef __APPLE__
#include <stdlib.h>
@ -27,7 +27,7 @@ void log(const char *msg, void *) {
std::cout << "debugger log: " << msg << std::endl;
}
Debug::Debug(): state(lldb::StateType::eStateInvalid), buffer_size(131072) {
DebugClang::DebugClang(): state(lldb::StateType::eStateInvalid), buffer_size(131072) {
#ifdef __APPLE__
auto debugserver_path=boost::filesystem::path("/usr/local/opt/llvm/bin/debugserver");
if(boost::filesystem::exists(debugserver_path))
@ -35,7 +35,7 @@ Debug::Debug(): state(lldb::StateType::eStateInvalid), buffer_size(131072) {
#endif
}
void Debug::start(const std::string &command, const boost::filesystem::path &path,
void DebugClang::start(const std::string &command, const boost::filesystem::path &path,
const std::vector<std::pair<boost::filesystem::path, int> > &breakpoints,
std::function<void(int exit_status)> callback,
std::function<void(const std::string &status)> status_callback,
@ -214,14 +214,14 @@ void Debug::start(const std::string &command, const boost::filesystem::path &pat
});
}
void Debug::continue_debug() {
void DebugClang::continue_debug() {
event_mutex.lock();
if(state==lldb::StateType::eStateStopped)
process->Continue();
event_mutex.unlock();
}
void Debug::stop() {
void DebugClang::stop() {
event_mutex.lock();
if(state==lldb::StateType::eStateRunning) {
auto error=process->Stop();
@ -231,7 +231,7 @@ void Debug::stop() {
event_mutex.unlock();
}
void Debug::kill() {
void DebugClang::kill() {
event_mutex.lock();
if(process) {
auto error=process->Kill();
@ -241,7 +241,7 @@ void Debug::kill() {
event_mutex.unlock();
}
void Debug::step_over() {
void DebugClang::step_over() {
event_mutex.lock();
if(state==lldb::StateType::eStateStopped) {
process->GetSelectedThread().StepOver();
@ -249,7 +249,7 @@ void Debug::step_over() {
event_mutex.unlock();
}
void Debug::step_into() {
void DebugClang::step_into() {
event_mutex.lock();
if(state==lldb::StateType::eStateStopped) {
process->GetSelectedThread().StepInto();
@ -257,7 +257,7 @@ void Debug::step_into() {
event_mutex.unlock();
}
void Debug::step_out() {
void DebugClang::step_out() {
event_mutex.lock();
if(state==lldb::StateType::eStateStopped) {
process->GetSelectedThread().StepOut();
@ -265,7 +265,7 @@ void Debug::step_out() {
event_mutex.unlock();
}
std::pair<std::string, std::string> Debug::run_command(const std::string &command) {
std::pair<std::string, std::string> DebugClang::run_command(const std::string &command) {
std::pair<std::string, std::string> command_return;
event_mutex.lock();
if(state==lldb::StateType::eStateStopped || state==lldb::StateType::eStateRunning) {
@ -278,7 +278,7 @@ std::pair<std::string, std::string> Debug::run_command(const std::string &comman
return command_return;
}
std::vector<Debug::Frame> Debug::get_backtrace() {
std::vector<DebugClang::Frame> DebugClang::get_backtrace() {
std::vector<Frame> backtrace;
event_mutex.lock();
if(state==lldb::StateType::eStateStopped) {
@ -315,8 +315,8 @@ std::vector<Debug::Frame> Debug::get_backtrace() {
return backtrace;
}
std::vector<Debug::Variable> Debug::get_variables() {
std::vector<Debug::Variable> variables;
std::vector<DebugClang::Variable> DebugClang::get_variables() {
std::vector<DebugClang::Variable> variables;
event_mutex.lock();
if(state==lldb::StateType::eStateStopped) {
for(uint32_t c_t=0;c_t<process->GetNumThreads();c_t++) {
@ -330,7 +330,7 @@ std::vector<Debug::Variable> Debug::get_variables() {
auto declaration=value.GetDeclaration();
if(declaration.IsValid()) {
Debug::Variable variable;
DebugClang::Variable variable;
variable.thread_index_id=thread.GetIndexID();
variable.frame_index=c_f;
@ -359,7 +359,7 @@ std::vector<Debug::Variable> Debug::get_variables() {
return variables;
}
void Debug::select_frame(uint32_t frame_index, uint32_t thread_index_id) {
void DebugClang::select_frame(uint32_t frame_index, uint32_t thread_index_id) {
event_mutex.lock();
if(state==lldb::StateType::eStateStopped) {
if(thread_index_id!=0)
@ -369,13 +369,13 @@ void Debug::select_frame(uint32_t frame_index, uint32_t thread_index_id) {
event_mutex.unlock();
}
void Debug::delete_debug() {
void DebugClang::delete_debug() {
kill();
if(debug_thread.joinable())
debug_thread.join();
}
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 DebugClang::get_value(const std::string &variable, const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index) {
std::string variable_value;
event_mutex.lock();
if(state==lldb::StateType::eStateStopped) {
@ -417,7 +417,7 @@ std::string Debug::get_value(const std::string &variable, const boost::filesyste
return variable_value;
}
std::string Debug::get_return_value(const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index) {
std::string DebugClang::get_return_value(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) {
@ -441,7 +441,7 @@ std::string Debug::get_return_value(const boost::filesystem::path &file_path, un
return return_value;
}
bool Debug::is_invalid() {
bool DebugClang::is_invalid() {
bool invalid;
event_mutex.lock();
invalid=state==lldb::StateType::eStateInvalid;
@ -449,7 +449,7 @@ bool Debug::is_invalid() {
return invalid;
}
bool Debug::is_stopped() {
bool DebugClang::is_stopped() {
bool stopped;
event_mutex.lock();
stopped=state==lldb::StateType::eStateStopped;
@ -457,7 +457,7 @@ bool Debug::is_stopped() {
return stopped;
}
bool Debug::is_running() {
bool DebugClang::is_running() {
bool running;
event_mutex.lock();
running=state==lldb::StateType::eStateRunning;
@ -465,7 +465,7 @@ bool Debug::is_running() {
return running;
}
void Debug::add_breakpoint(const boost::filesystem::path &file_path, int line_nr) {
void DebugClang::add_breakpoint(const boost::filesystem::path &file_path, int line_nr) {
event_mutex.lock();
if(state==lldb::eStateStopped || state==lldb::eStateRunning) {
if(!(process->GetTarget().BreakpointCreateByLocation(file_path.string().c_str(), line_nr)).IsValid())
@ -474,7 +474,7 @@ void Debug::add_breakpoint(const boost::filesystem::path &file_path, int line_nr
event_mutex.unlock();
}
void Debug::remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) {
void DebugClang::remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) {
event_mutex.lock();
if(state==lldb::eStateStopped || state==lldb::eStateRunning) {
auto target=process->GetTarget();
@ -501,7 +501,7 @@ void Debug::remove_breakpoint(const boost::filesystem::path &file_path, int line
event_mutex.unlock();
}
void Debug::write(const std::string &buffer) {
void DebugClang::write(const std::string &buffer) {
event_mutex.lock();
if(state==lldb::StateType::eStateRunning) {
process->PutSTDIN(buffer.c_str(), buffer.size());

12
src/debug.h → src/debug_clang.h

@ -1,5 +1,5 @@
#ifndef JUCI_DEBUG_H_
#define JUCI_DEBUG_H_
#ifndef JUCI_DEBUG_CLANG_H_
#define JUCI_DEBUG_CLANG_H_
#include <boost/filesystem.hpp>
#include <unordered_map>
@ -9,7 +9,7 @@
#include <thread>
#include <mutex>
class Debug {
class DebugClang {
public:
class Frame {
public:
@ -31,10 +31,10 @@ public:
int line_index;
};
private:
Debug();
DebugClang();
public:
static Debug &get() {
static Debug singleton;
static DebugClang &get() {
static DebugClang singleton;
return singleton;
}

36
src/project.cc

@ -6,7 +6,7 @@
#include "menu.h"
#include "notebook.h"
#ifdef JUCI_ENABLE_DEBUG
#include "debug.h"
#include "debug_clang.h"
#endif
std::unordered_map<std::string, std::string> Project::run_arguments;
@ -271,7 +271,7 @@ void Project::Clang::debug_start() {
debugging=false;
else {
debug_start_mutex.lock();
Debug::get().start(run_arguments, debug_build_path, *breakpoints, [this, run_arguments](int exit_status){
DebugClang::get().start(run_arguments, debug_build_path, *breakpoints, [this, run_arguments](int exit_status){
debugging=false;
Terminal::get().async_print(run_arguments+" returned: "+std::to_string(exit_status)+'\n');
}, [this](const std::string &status) {
@ -293,42 +293,42 @@ void Project::Clang::debug_start() {
}
void Project::Clang::debug_continue() {
Debug::get().continue_debug();
DebugClang::get().continue_debug();
}
void Project::Clang::debug_stop() {
if(debugging)
Debug::get().stop();
DebugClang::get().stop();
}
void Project::Clang::debug_kill() {
if(debugging)
Debug::get().kill();
DebugClang::get().kill();
}
void Project::Clang::debug_step_over() {
if(debugging)
Debug::get().step_over();
DebugClang::get().step_over();
}
void Project::Clang::debug_step_into() {
if(debugging)
Debug::get().step_into();
DebugClang::get().step_into();
}
void Project::Clang::debug_step_out() {
if(debugging)
Debug::get().step_out();
DebugClang::get().step_out();
}
void Project::Clang::debug_backtrace() {
if(debugging && Notebook::get().get_current_page()!=-1) {
auto backtrace=Debug::get().get_backtrace();
auto backtrace=DebugClang::get().get_backtrace();
auto view=Notebook::get().get_current_view();
auto iter=view->get_iter_for_dialog();
view->selection_dialog=std::unique_ptr<SelectionDialog>(new SelectionDialog(*view, view->get_buffer()->create_mark(iter), true, true));
auto rows=std::make_shared<std::unordered_map<std::string, Debug::Frame> >();
auto rows=std::make_shared<std::unordered_map<std::string, DebugClang::Frame> >();
if(backtrace.size()==0)
return;
@ -356,7 +356,7 @@ void Project::Clang::debug_backtrace() {
if(Notebook::get().get_current_page()!=-1) {
auto view=Notebook::get().get_current_view();
Debug::get().select_frame(frame.index);
DebugClang::get().select_frame(frame.index);
view->get_buffer()->place_cursor(view->get_buffer()->get_iter_at_line_index(frame.line_nr-1, frame.line_index-1));
@ -373,12 +373,12 @@ void Project::Clang::debug_backtrace() {
void Project::Clang::debug_show_variables() {
if(debugging && Notebook::get().get_current_page()!=-1) {
auto variables=Debug::get().get_variables();
auto variables=DebugClang::get().get_variables();
auto view=Notebook::get().get_current_view();
auto iter=view->get_iter_for_dialog();
view->selection_dialog=std::unique_ptr<SelectionDialog>(new SelectionDialog(*view, view->get_buffer()->create_mark(iter), true, true));
auto rows=std::make_shared<std::unordered_map<std::string, Debug::Variable> >();
auto rows=std::make_shared<std::unordered_map<std::string, DebugClang::Variable> >();
if(variables.size()==0)
return;
@ -396,7 +396,7 @@ void Project::Clang::debug_show_variables() {
if(Notebook::get().get_current_page()!=-1) {
auto view=Notebook::get().get_current_view();
Debug::get().select_frame(variable.frame_index, variable.thread_index_id);
DebugClang::get().select_frame(variable.frame_index, variable.thread_index_id);
view->get_buffer()->place_cursor(view->get_buffer()->get_iter_at_line_index(variable.line_nr-1, variable.line_index-1));
@ -451,23 +451,23 @@ void Project::Clang::debug_show_variables() {
void Project::Clang::debug_run_command(const std::string &command) {
if(debugging) {
auto command_return=Debug::get().run_command(command);
auto command_return=DebugClang::get().run_command(command);
Terminal::get().async_print(command_return.first);
Terminal::get().async_print(command_return.second, true);
}
}
void Project::Clang::debug_add_breakpoint(const boost::filesystem::path &file_path, int line_nr) {
Debug::get().add_breakpoint(file_path, line_nr);
DebugClang::get().add_breakpoint(file_path, line_nr);
}
void Project::Clang::debug_remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) {
Debug::get().remove_breakpoint(file_path, line_nr, line_count);
DebugClang::get().remove_breakpoint(file_path, line_nr, line_count);
}
void Project::Clang::debug_delete() {
debug_start_mutex.lock();
Debug::get().delete_debug();
DebugClang::get().delete_debug();
debug_start_mutex.unlock();
}
#endif

8
src/source_clang.cc

@ -3,7 +3,7 @@
#include "terminal.h"
#include "cmake.h"
#ifdef JUCI_ENABLE_DEBUG
#include "debug.h"
#include "debug_clang.h"
#endif
namespace sigc {
@ -414,15 +414,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()) {
if(DebugClang::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, location.get_offset().index);
Glib::ustring debug_value=DebugClang::get().get_value(token.get_spelling(), location.get_path(), location.get_offset().line, location.get_offset().index);
if(debug_value.empty()) {
value_type="Return value";
auto cursor=token.get_cursor();
auto offsets=cursor.get_source_range().get_offsets();
debug_value=Debug::get().get_return_value(cursor.get_source_location().get_path(), offsets.first.line, offsets.first.index);
debug_value=DebugClang::get().get_return_value(cursor.get_source_location().get_path(), offsets.first.line, offsets.first.index);
}
if(!debug_value.empty()) {
size_t pos=debug_value.find(" = ");

6
src/terminal.cc

@ -3,7 +3,7 @@
#include "logging.h"
#include "config.h"
#ifdef JUCI_ENABLE_DEBUG
#include "debug.h"
#include "debug_clang.h"
#endif
Terminal::InProgress::InProgress(const std::string& start_msg): stop(false) {
@ -240,7 +240,7 @@ bool Terminal::on_key_press_event(GdkEventKey *event) {
processes_mutex.lock();
bool debug_is_running=false;
#ifdef JUCI_ENABLE_DEBUG
debug_is_running=Debug::get().is_running();
debug_is_running=DebugClang::get().is_running();
#endif
if(processes.size()>0 || debug_is_running) {
get_buffer()->place_cursor(get_buffer()->end());
@ -262,7 +262,7 @@ bool Terminal::on_key_press_event(GdkEventKey *event) {
stdin_buffer+='\n';
if(debug_is_running) {
#ifdef JUCI_ENABLE_DEBUG
Debug::get().write(stdin_buffer);
DebugClang::get().write(stdin_buffer);
#endif
}
else

Loading…
Cancel
Save