Browse Source

Renamed DebugClang to Clang in namespace Debug (Debug::Clang)

merge-requests/365/head
eidheim 10 years ago
parent
commit
2770463c09
  1. 46
      src/debug_clang.cc
  2. 20
      src/debug_clang.h
  3. 38
      src/project.cc
  4. 6
      src/source_clang.cc

46
src/debug_clang.cc

@ -27,7 +27,7 @@ void log(const char *msg, void *) {
std::cout << "debugger log: " << msg << std::endl;
}
DebugClang::DebugClang(): state(lldb::StateType::eStateInvalid), buffer_size(131072) {
Debug::Clang::Clang(): 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 @@ DebugClang::DebugClang(): state(lldb::StateType::eStateInvalid), buffer_size(131
#endif
}
void DebugClang::start(const std::string &command, const boost::filesystem::path &path,
void Debug::Clang::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 DebugClang::start(const std::string &command, const boost::filesystem::path
});
}
void DebugClang::continue_debug() {
void Debug::Clang::continue_debug() {
event_mutex.lock();
if(state==lldb::StateType::eStateStopped)
process->Continue();
event_mutex.unlock();
}
void DebugClang::stop() {
void Debug::Clang::stop() {
event_mutex.lock();
if(state==lldb::StateType::eStateRunning) {
auto error=process->Stop();
@ -231,7 +231,7 @@ void DebugClang::stop() {
event_mutex.unlock();
}
void DebugClang::kill() {
void Debug::Clang::kill() {
event_mutex.lock();
if(process) {
auto error=process->Kill();
@ -241,7 +241,7 @@ void DebugClang::kill() {
event_mutex.unlock();
}
void DebugClang::step_over() {
void Debug::Clang::step_over() {
event_mutex.lock();
if(state==lldb::StateType::eStateStopped) {
process->GetSelectedThread().StepOver();
@ -249,7 +249,7 @@ void DebugClang::step_over() {
event_mutex.unlock();
}
void DebugClang::step_into() {
void Debug::Clang::step_into() {
event_mutex.lock();
if(state==lldb::StateType::eStateStopped) {
process->GetSelectedThread().StepInto();
@ -257,7 +257,7 @@ void DebugClang::step_into() {
event_mutex.unlock();
}
void DebugClang::step_out() {
void Debug::Clang::step_out() {
event_mutex.lock();
if(state==lldb::StateType::eStateStopped) {
process->GetSelectedThread().StepOut();
@ -265,7 +265,7 @@ void DebugClang::step_out() {
event_mutex.unlock();
}
std::pair<std::string, std::string> DebugClang::run_command(const std::string &command) {
std::pair<std::string, std::string> Debug::Clang::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> DebugClang::run_command(const std::string &c
return command_return;
}
std::vector<DebugClang::Frame> DebugClang::get_backtrace() {
std::vector<Debug::Clang::Frame> Debug::Clang::get_backtrace() {
std::vector<Frame> backtrace;
event_mutex.lock();
if(state==lldb::StateType::eStateStopped) {
@ -315,8 +315,8 @@ std::vector<DebugClang::Frame> DebugClang::get_backtrace() {
return backtrace;
}
std::vector<DebugClang::Variable> DebugClang::get_variables() {
std::vector<DebugClang::Variable> variables;
std::vector<Debug::Clang::Variable> Debug::Clang::get_variables() {
std::vector<Debug::Clang::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<DebugClang::Variable> DebugClang::get_variables() {
auto declaration=value.GetDeclaration();
if(declaration.IsValid()) {
DebugClang::Variable variable;
Debug::Clang::Variable variable;
variable.thread_index_id=thread.GetIndexID();
variable.frame_index=c_f;
@ -359,7 +359,7 @@ std::vector<DebugClang::Variable> DebugClang::get_variables() {
return variables;
}
void DebugClang::select_frame(uint32_t frame_index, uint32_t thread_index_id) {
void Debug::Clang::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 DebugClang::select_frame(uint32_t frame_index, uint32_t thread_index_id) {
event_mutex.unlock();
}
void DebugClang::delete_debug() {
void Debug::Clang::delete_debug() {
kill();
if(debug_thread.joinable())
debug_thread.join();
}
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 Debug::Clang::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 DebugClang::get_value(const std::string &variable, const boost::file
return variable_value;
}
std::string DebugClang::get_return_value(const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index) {
std::string Debug::Clang::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 DebugClang::get_return_value(const boost::filesystem::path &file_pat
return return_value;
}
bool DebugClang::is_invalid() {
bool Debug::Clang::is_invalid() {
bool invalid;
event_mutex.lock();
invalid=state==lldb::StateType::eStateInvalid;
@ -449,7 +449,7 @@ bool DebugClang::is_invalid() {
return invalid;
}
bool DebugClang::is_stopped() {
bool Debug::Clang::is_stopped() {
bool stopped;
event_mutex.lock();
stopped=state==lldb::StateType::eStateStopped;
@ -457,7 +457,7 @@ bool DebugClang::is_stopped() {
return stopped;
}
bool DebugClang::is_running() {
bool Debug::Clang::is_running() {
bool running;
event_mutex.lock();
running=state==lldb::StateType::eStateRunning;
@ -465,7 +465,7 @@ bool DebugClang::is_running() {
return running;
}
void DebugClang::add_breakpoint(const boost::filesystem::path &file_path, int line_nr) {
void Debug::Clang::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 DebugClang::add_breakpoint(const boost::filesystem::path &file_path, int li
event_mutex.unlock();
}
void DebugClang::remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) {
void Debug::Clang::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 DebugClang::remove_breakpoint(const boost::filesystem::path &file_path, int
event_mutex.unlock();
}
void DebugClang::write(const std::string &buffer) {
void Debug::Clang::write(const std::string &buffer) {
event_mutex.lock();
if(state==lldb::StateType::eStateRunning) {
process->PutSTDIN(buffer.c_str(), buffer.size());

20
src/debug_clang.h

@ -9,8 +9,9 @@
#include <thread>
#include <mutex>
class DebugClang {
public:
namespace Debug {
class Clang {
public:
class Frame {
public:
uint32_t index;
@ -30,11 +31,11 @@ public:
int line_nr;
int line_index;
};
private:
DebugClang();
public:
static DebugClang &get() {
static DebugClang singleton;
private:
Clang();
public:
static Clang &get() {
static Clang singleton;
return singleton;
}
@ -68,7 +69,7 @@ public:
void write(const std::string &buffer);
private:
private:
std::unique_ptr<lldb::SBDebugger> debugger;
std::unique_ptr<lldb::SBListener> listener;
std::unique_ptr<lldb::SBProcess> process;
@ -78,6 +79,7 @@ private:
std::mutex event_mutex;
size_t buffer_size;
};
};
}
#endif

38
src/project.cc

@ -273,7 +273,7 @@ void Project::Clang::debug_start() {
debugging=false;
else {
debug_start_mutex.lock();
DebugClang::get().start(run_arguments, debug_build_path, *breakpoints, [this, run_arguments](int exit_status){
Debug::Clang::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) {
@ -295,42 +295,42 @@ void Project::Clang::debug_start() {
}
void Project::Clang::debug_continue() {
DebugClang::get().continue_debug();
Debug::Clang::get().continue_debug();
}
void Project::Clang::debug_stop() {
if(debugging)
DebugClang::get().stop();
Debug::Clang::get().stop();
}
void Project::Clang::debug_kill() {
if(debugging)
DebugClang::get().kill();
Debug::Clang::get().kill();
}
void Project::Clang::debug_step_over() {
if(debugging)
DebugClang::get().step_over();
Debug::Clang::get().step_over();
}
void Project::Clang::debug_step_into() {
if(debugging)
DebugClang::get().step_into();
Debug::Clang::get().step_into();
}
void Project::Clang::debug_step_out() {
if(debugging)
DebugClang::get().step_out();
Debug::Clang::get().step_out();
}
void Project::Clang::debug_backtrace() {
if(debugging && Notebook::get().get_current_page()!=-1) {
auto backtrace=DebugClang::get().get_backtrace();
auto backtrace=Debug::Clang::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, DebugClang::Frame> >();
auto rows=std::make_shared<std::unordered_map<std::string, Debug::Clang::Frame> >();
if(backtrace.size()==0)
return;
@ -358,7 +358,7 @@ void Project::Clang::debug_backtrace() {
if(Notebook::get().get_current_page()!=-1) {
auto view=Notebook::get().get_current_view();
DebugClang::get().select_frame(frame.index);
Debug::Clang::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));
@ -375,12 +375,12 @@ void Project::Clang::debug_backtrace() {
void Project::Clang::debug_show_variables() {
if(debugging && Notebook::get().get_current_page()!=-1) {
auto variables=DebugClang::get().get_variables();
auto variables=Debug::Clang::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, DebugClang::Variable> >();
auto rows=std::make_shared<std::unordered_map<std::string, Debug::Clang::Variable> >();
if(variables.size()==0)
return;
@ -398,7 +398,7 @@ void Project::Clang::debug_show_variables() {
if(Notebook::get().get_current_page()!=-1) {
auto view=Notebook::get().get_current_view();
DebugClang::get().select_frame(variable.frame_index, variable.thread_index_id);
Debug::Clang::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));
@ -453,31 +453,31 @@ void Project::Clang::debug_show_variables() {
void Project::Clang::debug_run_command(const std::string &command) {
if(debugging) {
auto command_return=DebugClang::get().run_command(command);
auto command_return=Debug::Clang::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) {
DebugClang::get().add_breakpoint(file_path, line_nr);
Debug::Clang::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) {
DebugClang::get().remove_breakpoint(file_path, line_nr, line_count);
Debug::Clang::get().remove_breakpoint(file_path, line_nr, line_count);
}
bool Project::Clang::debug_is_running() {
return DebugClang::get().is_running();
return Debug::Clang::get().is_running();
}
void Project::Clang::debug_write(const std::string &buffer) {
DebugClang::get().write(buffer);
Debug::Clang::get().write(buffer);
}
void Project::Clang::debug_delete() {
debug_start_mutex.lock();
DebugClang::get().delete_debug();
Debug::Clang::get().delete_debug();
debug_start_mutex.unlock();
}
#endif

6
src/source_clang.cc

@ -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(DebugClang::get().is_stopped()) {
if(Debug::Clang::get().is_stopped()) {
auto location=token.get_cursor().get_referenced().get_source_location();
Glib::ustring value_type="Value";
Glib::ustring debug_value=DebugClang::get().get_value(token.get_spelling(), location.get_path(), location.get_offset().line, location.get_offset().index);
Glib::ustring debug_value=Debug::Clang::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=DebugClang::get().get_return_value(cursor.get_source_location().get_path(), offsets.first.line, offsets.first.index);
debug_value=Debug::Clang::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(" = ");

Loading…
Cancel
Save