|
|
|
|
@ -250,13 +250,13 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Debug::LLDB::continue_debug() { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::StateType::eStateStopped) |
|
|
|
|
process->Continue(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Debug::LLDB::stop() { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::StateType::eStateRunning) { |
|
|
|
|
auto error = process->Stop(); |
|
|
|
|
if(error.Fail()) |
|
|
|
|
@ -265,7 +265,7 @@ void Debug::LLDB::stop() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Debug::LLDB::kill() { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(process) { |
|
|
|
|
auto error = process->Kill(); |
|
|
|
|
if(error.Fail()) |
|
|
|
|
@ -274,21 +274,21 @@ void Debug::LLDB::kill() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Debug::LLDB::step_over() { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::StateType::eStateStopped) { |
|
|
|
|
process->GetSelectedThread().StepOver(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Debug::LLDB::step_into() { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::StateType::eStateStopped) { |
|
|
|
|
process->GetSelectedThread().StepInto(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Debug::LLDB::step_out() { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::StateType::eStateStopped) { |
|
|
|
|
process->GetSelectedThread().StepOut(); |
|
|
|
|
} |
|
|
|
|
@ -296,7 +296,7 @@ void Debug::LLDB::step_out() {
|
|
|
|
|
|
|
|
|
|
std::pair<std::string, std::string> Debug::LLDB::run_command(const std::string &command) { |
|
|
|
|
std::pair<std::string, std::string> command_return; |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::StateType::eStateStopped || state == lldb::StateType::eStateRunning) { |
|
|
|
|
lldb::SBCommandReturnObject command_return_object; |
|
|
|
|
debugger->GetCommandInterpreter().HandleCommand(command.c_str(), command_return_object, true); |
|
|
|
|
@ -312,7 +312,7 @@ std::pair<std::string, std::string> Debug::LLDB::run_command(const std::string &
|
|
|
|
|
|
|
|
|
|
std::vector<Debug::LLDB::Frame> Debug::LLDB::get_backtrace() { |
|
|
|
|
std::vector<Frame> backtrace; |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::StateType::eStateStopped) { |
|
|
|
|
auto thread = process->GetSelectedThread(); |
|
|
|
|
for(uint32_t c_f = 0; c_f < thread.GetNumFrames(); c_f++) { |
|
|
|
|
@ -348,7 +348,7 @@ std::vector<Debug::LLDB::Frame> Debug::LLDB::get_backtrace() {
|
|
|
|
|
|
|
|
|
|
std::vector<Debug::LLDB::Variable> Debug::LLDB::get_variables() { |
|
|
|
|
std::vector<Debug::LLDB::Variable> variables; |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::StateType::eStateStopped) { |
|
|
|
|
for(uint32_t c_t = 0; c_t < process->GetNumThreads(); c_t++) { |
|
|
|
|
auto thread = process->GetThreadAtIndex(c_t); |
|
|
|
|
@ -402,7 +402,7 @@ std::vector<Debug::LLDB::Variable> Debug::LLDB::get_variables() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Debug::LLDB::select_frame(uint32_t frame_index, uint32_t thread_index_id) { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::StateType::eStateStopped) { |
|
|
|
|
if(thread_index_id != 0) |
|
|
|
|
process->SetSelectedThreadByIndexID(thread_index_id); |
|
|
|
|
@ -419,7 +419,7 @@ void Debug::LLDB::cancel() {
|
|
|
|
|
|
|
|
|
|
std::string Debug::LLDB::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::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::StateType::eStateStopped) { |
|
|
|
|
auto frame = process->GetSelectedThread().GetSelectedFrame(); |
|
|
|
|
|
|
|
|
|
@ -462,7 +462,7 @@ std::string Debug::LLDB::get_value(const std::string &variable, const boost::fil
|
|
|
|
|
|
|
|
|
|
std::string Debug::LLDB::get_return_value(const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index) { |
|
|
|
|
std::string return_value; |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::StateType::eStateStopped) { |
|
|
|
|
auto thread = process->GetSelectedThread(); |
|
|
|
|
auto thread_return_value = thread.GetStopReturnValue(); |
|
|
|
|
@ -484,22 +484,22 @@ std::string Debug::LLDB::get_return_value(const boost::filesystem::path &file_pa
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Debug::LLDB::is_invalid() { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
return state == lldb::StateType::eStateInvalid; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Debug::LLDB::is_stopped() { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
return state == lldb::StateType::eStateStopped; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Debug::LLDB::is_running() { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
return state == lldb::StateType::eStateRunning; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Debug::LLDB::add_breakpoint(const boost::filesystem::path &file_path, int line_nr) { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::eStateStopped || state == lldb::eStateRunning) { |
|
|
|
|
if(!(process->GetTarget().BreakpointCreateByLocation(file_path.string().c_str(), line_nr)).IsValid()) |
|
|
|
|
Terminal::get().async_print("Error (debug): Could not create breakpoint at: " + file_path.string() + ":" + std::to_string(line_nr) + '\n', true); |
|
|
|
|
@ -507,7 +507,7 @@ void Debug::LLDB::add_breakpoint(const boost::filesystem::path &file_path, int l
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Debug::LLDB::remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count) { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::eStateStopped || state == lldb::eStateRunning) { |
|
|
|
|
auto target = process->GetTarget(); |
|
|
|
|
for(int line_nr_try = line_nr; line_nr_try < line_count; line_nr_try++) { |
|
|
|
|
@ -532,7 +532,7 @@ void Debug::LLDB::remove_breakpoint(const boost::filesystem::path &file_path, in
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Debug::LLDB::write(const std::string &buffer) { |
|
|
|
|
std::unique_lock<std::mutex> lock(mutex); |
|
|
|
|
std::lock_guard<std::mutex> lock(mutex); |
|
|
|
|
if(state == lldb::StateType::eStateRunning) { |
|
|
|
|
process->PutSTDIN(buffer.c_str(), buffer.size()); |
|
|
|
|
} |
|
|
|
|
|