mirror of https://gitlab.com/cppit/jucipp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.1 KiB
101 lines
3.1 KiB
|
8 years ago
|
#pragma once
|
||
|
6 years ago
|
#include "mutex.hpp"
|
||
|
10 years ago
|
#include <boost/filesystem.hpp>
|
||
|
8 years ago
|
#include <list>
|
||
|
8 years ago
|
#include <lldb/API/LLDB.h>
|
||
|
8 years ago
|
#include <thread>
|
||
|
8 years ago
|
#include <tuple>
|
||
|
10 years ago
|
|
||
|
10 years ago
|
namespace Debug {
|
||
|
10 years ago
|
class LLDB {
|
||
|
10 years ago
|
public:
|
||
|
10 years ago
|
class Frame {
|
||
|
|
public:
|
||
|
|
uint32_t index;
|
||
|
|
std::string module_filename;
|
||
|
10 years ago
|
boost::filesystem::path file_path;
|
||
|
10 years ago
|
std::string function_name;
|
||
|
|
int line_nr;
|
||
|
|
int line_index;
|
||
|
|
};
|
||
|
|
class Variable {
|
||
|
|
public:
|
||
|
|
uint32_t thread_index_id;
|
||
|
|
uint32_t frame_index;
|
||
|
|
std::string name;
|
||
|
|
std::string value;
|
||
|
10 years ago
|
bool declaration_found;
|
||
|
10 years ago
|
boost::filesystem::path file_path;
|
||
|
|
int line_nr;
|
||
|
|
int line_index;
|
||
|
|
};
|
||
|
8 years ago
|
|
||
|
10 years ago
|
private:
|
||
|
10 years ago
|
LLDB();
|
||
|
7 years ago
|
void destroy_();
|
||
|
|
|
||
|
|
static bool initialized;
|
||
|
8 years ago
|
|
||
|
10 years ago
|
public:
|
||
|
10 years ago
|
static LLDB &get() {
|
||
|
|
static LLDB singleton;
|
||
|
10 years ago
|
return singleton;
|
||
|
|
}
|
||
|
8 years ago
|
|
||
|
7 years ago
|
/// Must be called before application terminates (cannot be placed in destructor sadly)
|
||
|
|
static void destroy() {
|
||
|
|
if(initialized)
|
||
|
|
get().destroy_();
|
||
|
|
}
|
||
|
|
|
||
|
8 years ago
|
std::list<std::function<void(const lldb::SBProcess &)>> on_start;
|
||
|
8 years ago
|
/// The handlers are not run in the main loop.
|
||
|
8 years ago
|
std::list<std::function<void(int exit_status)>> on_exit;
|
||
|
8 years ago
|
/// The handlers are not run in the main loop.
|
||
|
8 years ago
|
std::list<std::function<void(const lldb::SBEvent &)>> on_event;
|
||
|
8 years ago
|
|
||
|
7 years ago
|
Mutex mutex;
|
||
|
8 years ago
|
|
||
|
8 years ago
|
void start(const std::string &command, const boost::filesystem::path &path = "",
|
||
|
|
const std::vector<std::pair<boost::filesystem::path, int>> &breakpoints = {},
|
||
|
|
const std::vector<std::string> &startup_commands = {}, const std::string &remote_host = "");
|
||
|
10 years ago
|
void continue_debug(); //can't use continue as function name
|
||
|
|
void stop();
|
||
|
|
void kill();
|
||
|
|
void step_over();
|
||
|
|
void step_into();
|
||
|
|
void step_out();
|
||
|
|
std::pair<std::string, std::string> run_command(const std::string &command);
|
||
|
|
std::vector<Frame> get_backtrace();
|
||
|
|
std::vector<Variable> get_variables();
|
||
|
8 years ago
|
void select_frame(uint32_t frame_index, uint32_t thread_index_id = 0);
|
||
|
|
|
||
|
7 years ago
|
/// Get value using variable name and location
|
||
|
|
std::string get_value(const std::string &variable_name, const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index);
|
||
|
|
/// Get value from expression
|
||
|
|
std::string get_value(const std::string &expression);
|
||
|
10 years ago
|
std::string get_return_value(const boost::filesystem::path &file_path, unsigned int line_nr, unsigned int line_index);
|
||
|
8 years ago
|
|
||
|
10 years ago
|
bool is_invalid();
|
||
|
|
bool is_stopped();
|
||
|
|
bool is_running();
|
||
|
8 years ago
|
|
||
|
10 years ago
|
void add_breakpoint(const boost::filesystem::path &file_path, int line_nr);
|
||
|
|
void remove_breakpoint(const boost::filesystem::path &file_path, int line_nr, int line_count);
|
||
|
8 years ago
|
|
||
|
10 years ago
|
void write(const std::string &buffer);
|
||
|
8 years ago
|
|
||
|
10 years ago
|
private:
|
||
|
8 years ago
|
std::tuple<std::vector<std::string>, std::string, std::vector<std::string>> parse_run_arguments(const std::string &command);
|
||
|
8 years ago
|
|
||
|
7 years ago
|
std::unique_ptr<lldb::SBDebugger> debugger GUARDED_BY(mutex);
|
||
|
|
std::unique_ptr<lldb::SBListener> listener GUARDED_BY(mutex);
|
||
|
|
std::unique_ptr<lldb::SBProcess> process GUARDED_BY(mutex);
|
||
|
10 years ago
|
std::thread debug_thread;
|
||
|
8 years ago
|
|
||
|
7 years ago
|
lldb::StateType state GUARDED_BY(mutex);
|
||
|
8 years ago
|
|
||
|
10 years ago
|
size_t buffer_size;
|
||
|
|
};
|
||
|
8 years ago
|
} // namespace Debug
|