Author: jmolenda Date: Mon Aug 26 17:08:27 2019 New Revision: 369990 URL: http://llvm.org/viewvc/llvm-project?rev=369990&view=rev Log: Send error message on failed attach from debugerserver.
Instead of using a magic return error code from debugserver to indicate that an attach failed because of SIP being enabled in RNBRemote::HandlePacket_v, use the extended error reporting that Pavel added to lldb/lldb-server in https://reviews.llvm.org/D45573 <rdar://problem/39398385> Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=369990&r1=369989&r2=369990&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Mon Aug 26 17:08:27 2019 @@ -2667,6 +2667,17 @@ void append_hex_value(std::ostream &ostr } } +std::string cstring_to_asciihex_string(const char *str) { + std::string hex_str; + hex_str.reserve (strlen (str) * 2); + while (str && *str) { + char hexbuf[5]; + snprintf (hexbuf, sizeof(hexbuf), "%02x", *str++); + hex_str += hexbuf; + } + return hex_str; +} + void append_hexified_string(std::ostream &ostrm, const std::string &string) { size_t string_size = string.size(); const char *string_buf = string.c_str(); @@ -3818,8 +3829,13 @@ rnb_err_t RNBRemote::HandlePacket_v(cons } } if (attach_failed_due_to_sip) { - SendPacket("E87"); // E87 is the magic value which says that we are - // not allowed to attach + std::string return_message = "E96;"; + return_message += cstring_to_asciihex_string( + "Process attach denied, possibly because " + "System Integrity Protection is enabled and " + "process does not allow attaching."); + + SendPacket(return_message.c_str()); DNBLogError("Attach failed because process does not allow " "attaching: \"%s\".", err_str); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits