diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h index 9049b106f02a3..a02f90891599a 100644 --- a/lldb/include/lldb/Host/Editline.h +++ b/lldb/include/lldb/Host/Editline.h @@ -57,6 +57,23 @@ #include "llvm/ADT/FunctionExtras.h" +#if defined(__clang__) && defined(__has_warning) +#if __has_warning("-Wdeprecated-declarations") +#define LLDB_DEPRECATED_WARNING_DISABLE \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#define LLDB_DEPRECATED_WARNING_RESTORE _Pragma("clang diagnostic pop") +#endif +#elif defined(__GNUC__) && __GNUC__ > 6 +#define LLDB_DEPRECATED_WARNING_DISABLE \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#define LLDB_DEPRECATED_WARNING_RESTORE _Pragma("GCC diagnostic pop") +#else +#define LLDB_DEPRECATED_WARNING_DISABLE +#define LLDB_DEPRECATED_WARNING_RESTORE +#endif + namespace lldb_private { namespace line_editor { @@ -367,7 +384,9 @@ class Editline { void SetGetCharacterFunction(EditlineGetCharCallbackType callbackFn); #if LLDB_EDITLINE_USE_WCHAR + LLDB_DEPRECATED_WARNING_DISABLE std::wstring_convert> m_utf8conv; + LLDB_DEPRECATED_WARNING_RESTORE #endif ::EditLine *m_editline = nullptr; EditlineHistorySP m_history_sp; diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index 561ec228cdb23..60117cb5f0e61 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -1574,7 +1574,9 @@ bool Editline::CompleteCharacter(char ch, EditLineGetCharType &out) { out = (unsigned char)ch; return true; #else + LLDB_DEPRECATED_WARNING_DISABLE std::codecvt_utf8 cvt; + LLDB_DEPRECATED_WARNING_RESTORE llvm::SmallString<4> input; for (;;) { const char *from_next; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp index defd72bbd9310..ba946561093eb 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp @@ -331,7 +331,8 @@ class ValidPointerChecker : public Instrumenter { return false; // Insert an instruction to call the helper with the result - CallInst::Create(m_valid_pointer_check_func, dereferenced_ptr, "", inst); + CallInst::Create(m_valid_pointer_check_func, dereferenced_ptr, "", + inst->getIterator()); return true; } @@ -418,7 +419,7 @@ class ObjcObjectChecker : public Instrumenter { ArrayRef args(arg_array, 2); - CallInst::Create(m_objc_object_check_func, args, "", inst); + CallInst::Create(m_objc_object_check_func, args, "", inst->getIterator()); return true; } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index 34461da46dfc7..b4884334236a1 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -381,8 +381,8 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) { Constant *initializer = result_global->getInitializer(); - StoreInst *synthesized_store = - new StoreInst(initializer, new_result_global, first_entry_instruction); + StoreInst *synthesized_store = new StoreInst( + initializer, new_result_global, first_entry_instruction->getIterator()); LLDB_LOG(log, "Synthesized result store \"{0}\"\n", PrintValue(synthesized_store)); @@ -416,9 +416,8 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str, "CFStringCreateWithBytes"); bool missing_weak = false; - CFStringCreateWithBytes_addr = - m_execution_unit.FindSymbol(g_CFStringCreateWithBytes_str, - missing_weak); + CFStringCreateWithBytes_addr = m_execution_unit.FindSymbol( + g_CFStringCreateWithBytes_str, missing_weak); if (CFStringCreateWithBytes_addr == LLDB_INVALID_ADDRESS || missing_weak) { LLDB_LOG(log, "Couldn't find CFStringCreateWithBytes in the target"); @@ -517,7 +516,8 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str, m_CFStringCreateWithBytes, CFSCWB_arguments, "CFStringCreateWithBytes", llvm::cast( - m_entry_instruction_finder.GetValue(function))); + m_entry_instruction_finder.GetValue(function)) + ->getIterator()); }); if (!UnfoldConstant(ns_str, nullptr, CFSCWB_Caller, m_entry_instruction_finder, @@ -824,7 +824,7 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) { CallInst *srN_call = CallInst::Create(m_sel_registerName, _objc_meth_var_name_, - "sel_registerName", selector_load); + "sel_registerName", selector_load->getIterator()); // Replace the load with the call in all users @@ -917,8 +917,9 @@ bool IRForTarget::RewritePersistentAlloc(llvm::Instruction *persistent_alloc) { // Now, since the variable is a pointer variable, we will drop in a load of // that pointer variable. - LoadInst *persistent_load = new LoadInst(persistent_global->getValueType(), - persistent_global, "", alloc); + LoadInst *persistent_load = + new LoadInst(persistent_global->getValueType(), persistent_global, "", + alloc->getIterator()); LLDB_LOG(log, "Replacing \"{0}\" with \"{1}\"", PrintValue(alloc), PrintValue(persistent_load)); @@ -1344,8 +1345,10 @@ bool IRForTarget::UnfoldConstant(Constant *old_constant, return new BitCastInst( value_maker.GetValue(function), constant_expr->getType(), - "", llvm::cast( - entry_instruction_finder.GetValue(function))); + "", + llvm::cast( + entry_instruction_finder.GetValue(function)) + ->getIterator()); }); if (!UnfoldConstant(constant_expr, llvm_function, bit_cast_maker, @@ -1379,7 +1382,8 @@ bool IRForTarget::UnfoldConstant(Constant *old_constant, return GetElementPtrInst::Create( gep->getSourceElementType(), ptr, indices, "", llvm::cast( - entry_instruction_finder.GetValue(function))); + entry_instruction_finder.GetValue(function)) + ->getIterator()); }); if (!UnfoldConstant(constant_expr, llvm_function, @@ -1559,12 +1563,14 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) { Type *int8Ty = Type::getInt8Ty(function->getContext()); ConstantInt *offset_int( ConstantInt::get(offset_type, offset, true)); - GetElementPtrInst *get_element_ptr = GetElementPtrInst::Create( - int8Ty, argument, offset_int, "", entry_instruction); + GetElementPtrInst *get_element_ptr = + GetElementPtrInst::Create(int8Ty, argument, offset_int, "", + entry_instruction->getIterator()); if (name == m_result_name && !m_result_is_pointer) { - LoadInst *load = new LoadInst(value->getType(), get_element_ptr, - "", entry_instruction); + LoadInst *load = + new LoadInst(value->getType(), get_element_ptr, "", + entry_instruction->getIterator()); return load; } else { diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index f22d626c4af2c..07211c6e9db49 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -176,9 +176,6 @@ void append_hexified_string(std::ostream &ostrm, const std::string &string) { } } -extern void ASLLogCallback(void *baton, uint32_t flags, const char *format, - va_list args); - // from System.framework/Versions/B/PrivateHeaders/sys/codesign.h extern "C" { #define CS_OPS_STATUS 0 /* return status */ @@ -1773,8 +1770,6 @@ static std::string get_value(std::string &line) { extern void FileLogCallback(void *baton, uint32_t flags, const char *format, va_list args); -extern void ASLLogCallback(void *baton, uint32_t flags, const char *format, - va_list args); rnb_err_t RNBRemote::HandlePacket_qRcmd(const char *p) { const char *c = p + strlen("qRcmd,"); @@ -1809,8 +1804,8 @@ rnb_err_t RNBRemote::HandlePacket_qRcmd(const char *p) { static_cast(strtoul(value.c_str(), &end, 0)); if (errno == 0 && end && *end == '\0') { DNBLogSetLogMask(logmask); - if (!DNBLogGetLogCallback()) - DNBLogSetLogCallback(ASLLogCallback, NULL); + if (auto log_callback = OsLogger::GetLogFunction()) + DNBLogSetLogCallback(log_callback, nullptr); return SendPacket("OK"); } errno = 0; @@ -2177,13 +2172,8 @@ rnb_err_t set_logging(const char *p) { // Enable DNB logging. // Use the existing log callback if one was already configured. if (!DNBLogGetLogCallback()) { - // Use the os_log()-based logger if available; otherwise, - // fallback to ASL. - auto log_callback = OsLogger::GetLogFunction(); - if (log_callback) + if (auto log_callback = OsLogger::GetLogFunction()) DNBLogSetLogCallback(log_callback, nullptr); - else - DNBLogSetLogCallback(ASLLogCallback, nullptr); } // Update logging to use the configured log channel bitmask. diff --git a/lldb/tools/debugserver/source/RNBServices.cpp b/lldb/tools/debugserver/source/RNBServices.cpp index 6e4b55e3e6466..bb57fb5ea027e 100644 --- a/lldb/tools/debugserver/source/RNBServices.cpp +++ b/lldb/tools/debugserver/source/RNBServices.cpp @@ -208,8 +208,8 @@ int ListApplications(std::string &plist, bool opt_runningApps, GetProcesses(plistMutableArray.get(), all_users); #endif - CFReleaser plistData( - ::CFPropertyListCreateXMLData(alloc, plistMutableArray.get())); + CFReleaser plistData(::CFPropertyListCreateData( + alloc, plistMutableArray.get(), kCFPropertyListXMLFormat_v1_0, 0, NULL)); // write plist to service port if (plistData.get() != NULL) { diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp index cfc9646ed2d08..f41a9e00ec948 100644 --- a/lldb/tools/debugserver/source/debugserver.cpp +++ b/lldb/tools/debugserver/source/debugserver.cpp @@ -759,35 +759,6 @@ static int ConnectRemote(RNBRemote *remote, const char *host, int port, return 1; } -// ASL Logging callback that can be registered with DNBLogSetLogCallback -void ASLLogCallback(void *baton, uint32_t flags, const char *format, - va_list args) { - if (format == NULL) - return; - static aslmsg g_aslmsg = NULL; - if (g_aslmsg == NULL) { - g_aslmsg = ::asl_new(ASL_TYPE_MSG); - char asl_key_sender[PATH_MAX]; - snprintf(asl_key_sender, sizeof(asl_key_sender), "com.apple.%s-%s", - DEBUGSERVER_PROGRAM_NAME, DEBUGSERVER_VERSION_STR); - ::asl_set(g_aslmsg, ASL_KEY_SENDER, asl_key_sender); - } - - int asl_level; - if (flags & DNBLOG_FLAG_FATAL) - asl_level = ASL_LEVEL_CRIT; - else if (flags & DNBLOG_FLAG_ERROR) - asl_level = ASL_LEVEL_ERR; - else if (flags & DNBLOG_FLAG_WARNING) - asl_level = ASL_LEVEL_WARNING; - else if (flags & DNBLOG_FLAG_VERBOSE) - asl_level = ASL_LEVEL_WARNING; // ASL_LEVEL_INFO; - else - asl_level = ASL_LEVEL_WARNING; // ASL_LEVEL_DEBUG; - - ::asl_vlog(NULL, g_aslmsg, asl_level, format, args); -} - // FILE based Logging callback that can be registered with // DNBLogSetLogCallback void FileLogCallback(void *baton, uint32_t flags, const char *format, @@ -948,16 +919,8 @@ int main(int argc, char *argv[]) { // Set up DNB logging by default. If the user passes different log flags or a // log file, these settings will be modified after processing the command line // arguments. - auto log_callback = OsLogger::GetLogFunction(); - if (log_callback) { - // if os_log() support is available, log through that. + if (auto log_callback = OsLogger::GetLogFunction()) DNBLogSetLogCallback(log_callback, nullptr); - DNBLog("debugserver will use os_log for internal logging."); - } else { - // Fall back to ASL support. - DNBLogSetLogCallback(ASLLogCallback, nullptr); - DNBLog("debugserver will use ASL for internal logging."); - } DNBLogSetLogMask(/*log_flags*/ 0); g_remoteSP = std::make_shared(); diff --git a/lldb/tools/debugserver/source/libdebugserver.cpp b/lldb/tools/debugserver/source/libdebugserver.cpp index 6da3708b4240b..17a5c137c1afb 100644 --- a/lldb/tools/debugserver/source/libdebugserver.cpp +++ b/lldb/tools/debugserver/source/libdebugserver.cpp @@ -311,13 +311,6 @@ RNBRunLoopMode RNBRunLoopInferiorExecuting(RNBRemoteSP &remote) { return mode; } -void ASLLogCallback(void *baton, uint32_t flags, const char *format, - va_list args) { -#if 0 - vprintf(format, args); -#endif -} - extern "C" int debug_server_main(int fd) { #if 1 g_isatty = 0; @@ -327,7 +320,6 @@ extern "C" int debug_server_main(int fd) { DNBLogSetDebug(1); DNBLogSetVerbose(1); DNBLogSetLogMask(-1); - DNBLogSetLogCallback(ASLLogCallback, NULL); #endif signal(SIGPIPE, signal_handler);