Browse Source

Added lldb rust formatters startup commands to lldb if debugging Rust

merge-requests/365/head
eidheim 8 years ago
parent
commit
8e7604022d
  1. 8
      src/debug_lldb.cc
  2. 2
      src/debug_lldb.h
  3. 14
      src/project.cc

8
src/debug_lldb.cc

@ -89,7 +89,7 @@ std::tuple<std::vector<std::string>, std::string, std::vector<std::string> > Deb
void Debug::LLDB::start(const std::string &command, const boost::filesystem::path &path,
const std::vector<std::pair<boost::filesystem::path, int> > &breakpoints,
const std::string &remote_host) {
const std::vector<std::string> &startup_commands, const std::string &remote_host) {
if(!debugger) {
lldb::SBDebugger::Initialize();
debugger=std::make_unique<lldb::SBDebugger>(lldb::SBDebugger::Create(true, log, nullptr));
@ -181,6 +181,12 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
debug_thread.join();
for(auto &handler: on_start)
handler(*process);
for(auto &command: startup_commands) {
lldb::SBCommandReturnObject command_return_object;
debugger->GetCommandInterpreter().HandleCommand(command.c_str(), command_return_object, false);
}
debug_thread=std::thread([this]() {
lldb::SBEvent event;
while(true) {

2
src/debug_lldb.h

@ -47,7 +47,7 @@ namespace Debug {
void start(const std::string &command, const boost::filesystem::path &path="",
const std::vector<std::pair<boost::filesystem::path, int> > &breakpoints={},
const std::string &remote_host="");
const std::vector<std::string> &startup_commands={}, const std::string &remote_host="");
void continue_debug(); //can't use continue as function name
void stop();
void kill();

14
src/project.cc

@ -365,7 +365,19 @@ void Project::LLDB::debug_start() {
});
on_event_it=std::prev(Debug::LLDB::get().on_event.end());
Debug::LLDB::get().start(*run_arguments, *project_path, breakpoints, remote_host);
std::vector<std::string> startup_commands;
if(dynamic_cast<CargoBuild*>(self->build.get())) {
std::stringstream istream, ostream;
if(Terminal::get().process(istream, ostream, "rustc --print sysroot")==0) {
auto sysroot=ostream.str();
while(!sysroot.empty() && (sysroot.back()=='\n' || sysroot.back()=='\r'))
sysroot.pop_back();
startup_commands.emplace_back("command script import \""+sysroot+"/lib/rustlib/etc/lldb_rust_formatters.py\"");
startup_commands.emplace_back("type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust");
startup_commands.emplace_back("type category enable Rust");
}
}
Debug::LLDB::get().start(*run_arguments, *project_path, breakpoints, std::move(startup_commands), remote_host);
});
}
});

Loading…
Cancel
Save