Skip to content

🍒 Cherrypicks to stop compiling LLDB with -Wno-deprecated-declarations #9442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lldb/include/lldb/Host/Editline.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -367,7 +384,9 @@ class Editline {
void SetGetCharacterFunction(EditlineGetCharCallbackType callbackFn);

#if LLDB_EDITLINE_USE_WCHAR
LLDB_DEPRECATED_WARNING_DISABLE
std::wstring_convert<std::codecvt_utf8<wchar_t>> m_utf8conv;
LLDB_DEPRECATED_WARNING_RESTORE
#endif
::EditLine *m_editline = nullptr;
EditlineHistorySP m_history_sp;
Expand Down
2 changes: 2 additions & 0 deletions lldb/source/Host/common/Editline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<wchar_t> cvt;
LLDB_DEPRECATED_WARNING_RESTORE
llvm::SmallString<4> input;
for (;;) {
const char *from_next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -418,7 +419,7 @@ class ObjcObjectChecker : public Instrumenter {

ArrayRef<llvm::Value *> 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;
}
Expand Down
38 changes: 22 additions & 16 deletions lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -517,7 +516,8 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
m_CFStringCreateWithBytes, CFSCWB_arguments,
"CFStringCreateWithBytes",
llvm::cast<Instruction>(
m_entry_instruction_finder.GetValue(function)));
m_entry_instruction_finder.GetValue(function))
->getIterator());
});

if (!UnfoldConstant(ns_str, nullptr, CFSCWB_Caller, m_entry_instruction_finder,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -1344,8 +1345,10 @@ bool IRForTarget::UnfoldConstant(Constant *old_constant,

return new BitCastInst(
value_maker.GetValue(function), constant_expr->getType(),
"", llvm::cast<Instruction>(
entry_instruction_finder.GetValue(function)));
"",
llvm::cast<Instruction>(
entry_instruction_finder.GetValue(function))
->getIterator());
});

if (!UnfoldConstant(constant_expr, llvm_function, bit_cast_maker,
Expand Down Expand Up @@ -1379,7 +1382,8 @@ bool IRForTarget::UnfoldConstant(Constant *old_constant,
return GetElementPtrInst::Create(
gep->getSourceElementType(), ptr, indices, "",
llvm::cast<Instruction>(
entry_instruction_finder.GetValue(function)));
entry_instruction_finder.GetValue(function))
->getIterator());
});

if (!UnfoldConstant(constant_expr, llvm_function,
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 3 additions & 13 deletions lldb/tools/debugserver/source/RNBRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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,");
Expand Down Expand Up @@ -1809,8 +1804,8 @@ rnb_err_t RNBRemote::HandlePacket_qRcmd(const char *p) {
static_cast<uint32_t>(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;
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions lldb/tools/debugserver/source/RNBServices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ int ListApplications(std::string &plist, bool opt_runningApps,
GetProcesses(plistMutableArray.get(), all_users);
#endif

CFReleaser<CFDataRef> plistData(
::CFPropertyListCreateXMLData(alloc, plistMutableArray.get()));
CFReleaser<CFDataRef> plistData(::CFPropertyListCreateData(
alloc, plistMutableArray.get(), kCFPropertyListXMLFormat_v1_0, 0, NULL));

// write plist to service port
if (plistData.get() != NULL) {
Expand Down
39 changes: 1 addition & 38 deletions lldb/tools/debugserver/source/debugserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<RNBRemote>();
Expand Down
8 changes: 0 additions & 8 deletions lldb/tools/debugserver/source/libdebugserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down