From 276b68600452b8bd093fdb4833b351592e3caaa5 Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 8 Dec 2016 20:42:34 +0100 Subject: [PATCH] Added workaround for Debian's newer lldb-server paths --- src/config.cc | 18 ++++++++---------- src/debug_lldb.cc | 22 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/config.cc b/src/config.cc index 0b56eb9..251cef4 100644 --- a/src/config.cc +++ b/src/config.cc @@ -107,16 +107,14 @@ void Config::retrieve_config() { #ifdef __linux if(terminal.clang_format_command=="clang-format" && !boost::filesystem::exists("/usr/bin/clang-format") && !boost::filesystem::exists("/usr/local/bin/clang-format")) { - if(boost::filesystem::exists("/usr/bin/clang-format-3.9")) - terminal.clang_format_command="/usr/bin/clang-format-3.9"; - else if(boost::filesystem::exists("/usr/bin/clang-format-3.8")) - terminal.clang_format_command="/usr/bin/clang-format-3.8"; - else if(boost::filesystem::exists("/usr/bin/clang-format-3.7")) - terminal.clang_format_command="/usr/bin/clang-format-3.7"; - else if(boost::filesystem::exists("/usr/bin/clang-format-3.6")) - terminal.clang_format_command="/usr/bin/clang-format-3.6"; - else if(boost::filesystem::exists("/usr/bin/clang-format-3.5")) - terminal.clang_format_command="/usr/bin/clang-format-3.5"; + auto versions={"4.0", "3.9", "3.8", "3.7", "3.6", "3.5"}; + for(auto &version: versions) { + auto corrected_command=std::string("/usr/bin/clang-format-")+version; + if(boost::filesystem::exists(corrected_command)) { + terminal.clang_format_command=corrected_command; + break; + } + } } #endif } diff --git a/src/debug_lldb.cc b/src/debug_lldb.cc index 86072a7..9c775dc 100644 --- a/src/debug_lldb.cc +++ b/src/debug_lldb.cc @@ -31,9 +31,25 @@ void log(const char *msg, void *) { Debug::LLDB::LLDB(): 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)) - setenv("LLDB_DEBUGSERVER_PATH", debugserver_path.string().c_str(), 0); + if(!getenv("LLDB_DEBUGSERVER_PATH")) { + std::string debug_server_path("/usr/local/opt/llvm/bin/debugserver"); + if(boost::filesystem::exists(debug_server_path)) + setenv("LLDB_DEBUGSERVER_PATH", debug_server_path.c_str(), 0); + } +#elif __linux + if(!getenv("LLDB_DEBUGSERVER_PATH")) { + std::string debug_server_path("/usr/bin/lldb-server"); + if(!boost::filesystem::exists(debug_server_path)) { + auto versions={"4.0", "3.9", "3.8", "3.7", "3.6", "3.5"}; + for(auto &version: versions) { + auto corrected_debug_server_path=debug_server_path+'-'+version; + if(boost::filesystem::exists(corrected_debug_server_path)) { + setenv("LLDB_DEBUGSERVER_PATH", corrected_debug_server_path.c_str(), 0); + break; + } + } + } + } #endif }