diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
commit | f73363f1dd94996356cefbf24388f561891acf0b (patch) | |
tree | e3c31248bdb36eaec5fd833490d4278162dba2a0 /source/Plugins/Process/MacOSX-Kernel | |
parent | 160ee69dd7ae18978f4068116777639ea98dc951 (diff) |
Notes
Diffstat (limited to 'source/Plugins/Process/MacOSX-Kernel')
-rw-r--r-- | source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp | 67 | ||||
-rw-r--r-- | source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp | 57 | ||||
-rw-r--r-- | source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp | 18 |
3 files changed, 51 insertions, 91 deletions
diff --git a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp index 3d9f498b1e9ac..116155d9a2324 100644 --- a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -59,15 +59,6 @@ bool CommunicationKDP::SendRequestPacket( return SendRequestPacketNoLock(request_packet); } -#if 0 -typedef struct { - uint8_t request; // Either: CommandType | ePacketTypeRequest, or CommandType | ePacketTypeReply - uint8_t sequence; - uint16_t length; // Length of entire packet including this header - uint32_t key; // Session key -} kdp_hdr_t; -#endif - void CommunicationKDP::MakeRequestPacketHeader(CommandType request_type, PacketStreamType &request_packet, uint16_t request_length) { @@ -127,16 +118,14 @@ bool CommunicationKDP::SendRequestAndGetReply( } } else if (reply_sequence_id > request_sequence_id) { // Sequence ID was greater than the sequence ID of the packet we - // sent, something - // is really wrong... + // sent, something is really wrong... reply_packet.Clear(); return false; } else { - // The reply sequence ID was less than our current packet's sequence - // ID - // so we should keep trying to get a response because this was a - // response - // for a previous packet that we must have retried. + // The reply sequence ID was less than our current packet's + // sequence ID so we should keep trying to get a response because + // this was a response for a previous packet that we must have + // retried. } } else { // Break and retry sending the packet as we didn't get a response due @@ -186,7 +175,7 @@ bool CommunicationKDP::GetSequenceMutex( bool CommunicationKDP::WaitForNotRunningPrivate( const std::chrono::microseconds &timeout) { - return m_is_running.WaitForValueEqualTo(false, timeout, NULL); + return m_is_running.WaitForValueEqualTo(false, timeout); } size_t @@ -324,9 +313,9 @@ bool CommunicationKDP::CheckForPacket(const uint8_t *src, size_t src_len, offset = 2; const uint16_t length = packet.GetU16(&offset); if (length <= bytes_available) { - // We have an entire packet ready, we need to copy the data - // bytes into a buffer that will be owned by the packet and - // erase the bytes from our communcation buffer "m_bytes" + // We have an entire packet ready, we need to copy the data bytes into + // a buffer that will be owned by the packet and erase the bytes from + // our communcation buffer "m_bytes" packet.SetData(DataBufferSP(new DataBufferHeap(&m_bytes[0], length))); m_bytes.erase(0, length); @@ -341,8 +330,8 @@ bool CommunicationKDP::CheckForPacket(const uint8_t *src, size_t src_len, } break; default: - // Unrecognized reply command byte, erase this byte and try to get back on - // track + // Unrecognized reply command byte, erase this byte and try to get back + // on track if (log) log->Printf("CommunicationKDP::%s: tossing junk byte: 0x%2.2x", __FUNCTION__, (uint8_t)m_bytes[0]); @@ -436,34 +425,6 @@ bool CommunicationKDP::SendRequestVersion() { return false; } -#if 0 // Disable KDP_IMAGEPATH for now, it seems to hang the KDP connection... -const char * -CommunicationKDP::GetImagePath () -{ - if (m_image_path.empty()) - SendRequestImagePath(); - return m_image_path.c_str(); -} - -bool -CommunicationKDP::SendRequestImagePath () -{ - PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order); - const CommandType command = KDP_IMAGEPATH; - const uint32_t command_length = 8; - MakeRequestPacketHeader (command, request_packet, command_length); - DataExtractor reply_packet; - if (SendRequestAndGetReply (command, request_packet, reply_packet)) - { - const char *path = reply_packet.PeekCStr(8); - if (path && path[0]) - m_kernel_version.assign (path); - return true; - } - return false; -} -#endif - uint32_t CommunicationKDP::GetCPUMask() { if (!HostInfoIsValid()) SendRequestHostInfo(); @@ -495,7 +456,7 @@ lldb_private::UUID CommunicationKDP::GetUUID() { if (uuid_str.size() < 32) return uuid; - if (uuid.SetFromCString(uuid_str.c_str()) == 0) { + if (uuid.SetFromStringRef(uuid_str) == 0) { UUID invalid_uuid; return invalid_uuid; } @@ -1245,8 +1206,8 @@ uint32_t CommunicationKDP::SendRequestReadRegisters(uint32_t cpu, if (src) { ::memcpy(dst, src, bytes_to_copy); error.Clear(); - // Return the number of bytes we could have returned regardless if - // we copied them or not, just so we know when things don't match up + // Return the number of bytes we could have returned regardless if we + // copied them or not, just so we know when things don't match up return src_len; } } diff --git a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index f01f1ace583cb..2e707ab2e3633 100644 --- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -172,10 +172,10 @@ ProcessKDP::ProcessKDP(TargetSP target_sp, ListenerSP listener_sp) //---------------------------------------------------------------------- ProcessKDP::~ProcessKDP() { Clear(); - // We need to call finalize on the process before destroying ourselves - // to make sure all of the broadcaster cleanup goes as planned. If we - // destruct this class, then Process::~Process() might have problems - // trying to fully destroy the broadcaster. + // We need to call finalize on the process before destroying ourselves to + // make sure all of the broadcaster cleanup goes as planned. If we destruct + // this class, then Process::~Process() might have problems trying to fully + // destroy the broadcaster. Finalize(); } @@ -226,9 +226,9 @@ bool ProcessKDP::GetHostArchitecture(ArchSpec &arch) { Status ProcessKDP::DoConnectRemote(Stream *strm, llvm::StringRef remote_url) { Status error; - // Don't let any JIT happen when doing KDP as we can't allocate - // memory and we don't want to be mucking with threads that might - // already be handling exceptions + // Don't let any JIT happen when doing KDP as we can't allocate memory and we + // don't want to be mucking with threads that might already be handling + // exceptions SetCanJIT(false); if (remote_url.empty()) { @@ -282,16 +282,15 @@ Status ProcessKDP::DoConnectRemote(Stream *strm, llvm::StringRef remote_url) { if (m_comm.RemoteIsEFI()) { // Select an invalid plugin name for the dynamic loader so one - // doesn't get used - // since EFI does its own manual loading via python scripting + // doesn't get used since EFI does its own manual loading via + // python scripting static ConstString g_none_dynamic_loader("none"); m_dyld_plugin_name = g_none_dynamic_loader; if (kernel_uuid.IsValid()) { - // If EFI passed in a UUID= try to lookup UUID - // The slide will not be provided. But the UUID - // lookup will be used to launch EFI debug scripts - // from the dSYM, that can load all of the symbols. + // If EFI passed in a UUID= try to lookup UUID The slide will not + // be provided. But the UUID lookup will be used to launch EFI + // debug scripts from the dSYM, that can load all of the symbols. ModuleSpec module_spec; module_spec.GetUUID() = kernel_uuid; module_spec.GetArchitecture() = target.GetArchitecture(); @@ -386,7 +385,7 @@ ProcessKDP::DoAttachToProcessWithID(lldb::pid_t attach_pid, const ProcessAttachInfo &attach_info) { Status error; error.SetErrorString( - "attach to process by ID is not suppported in kdp remote debugging"); + "attach to process by ID is not supported in kdp remote debugging"); return error; } @@ -395,7 +394,7 @@ ProcessKDP::DoAttachToProcessWithName(const char *process_name, const ProcessAttachInfo &attach_info) { Status error; error.SetErrorString( - "attach to process by name is not suppported in kdp remote debugging"); + "attach to process by name is not supported in kdp remote debugging"); return error; } @@ -443,8 +442,8 @@ Status ProcessKDP::DoResume() { StateAsCString(thread_resume_state)); switch (thread_resume_state) { case eStateSuspended: - // Nothing to do here when a thread will stay suspended - // we just leave the CPU mask bit set to zero for the thread + // Nothing to do here when a thread will stay suspended we just leave the + // CPU mask bit set to zero for the thread if (log) log->Printf("ProcessKDP::DoResume() = suspended???"); break; @@ -535,8 +534,8 @@ bool ProcessKDP::UpdateThreadList(ThreadList &old_thread_list, } void ProcessKDP::RefreshStateAfterStop() { - // Let all threads recover from stopping and do any clean up based - // on the previous thread state (if any). + // Let all threads recover from stopping and do any clean up based on the + // previous thread state (if any). m_thread_list.RefreshStateAfterStop(); } @@ -545,9 +544,9 @@ Status ProcessKDP::DoHalt(bool &caused_stop) { if (m_comm.IsRunning()) { if (m_destroy_in_process) { - // If we are attemping to destroy, we need to not return an error to - // Halt or DoDestroy won't get called. - // We are also currently running, so send a process stopped event + // If we are attempting to destroy, we need to not return an error to Halt + // or DoDestroy won't get called. We are also currently running, so send + // a process stopped event SetPrivateState(eStateStopped); } else { error.SetErrorString("KDP cannot interrupt a running kernel"); @@ -563,8 +562,8 @@ Status ProcessKDP::DoDetach(bool keep_stopped) { log->Printf("ProcessKDP::DoDetach(keep_stopped = %i)", keep_stopped); if (m_comm.IsRunning()) { - // We are running and we can't interrupt a running kernel, so we need - // to just close the connection to the kernel and hope for the best + // We are running and we can't interrupt a running kernel, so we need to + // just close the connection to the kernel and hope for the best } else { // If we are going to keep the target stopped, then don't send the // disconnect message. @@ -647,14 +646,14 @@ size_t ProcessKDP::DoWriteMemory(addr_t addr, const void *buf, size_t size, lldb::addr_t ProcessKDP::DoAllocateMemory(size_t size, uint32_t permissions, Status &error) { error.SetErrorString( - "memory allocation not suppported in kdp remote debugging"); + "memory allocation not supported in kdp remote debugging"); return LLDB_INVALID_ADDRESS; } Status ProcessKDP::DoDeallocateMemory(lldb::addr_t addr) { Status error; error.SetErrorString( - "memory deallocation not suppported in kdp remote debugging"); + "memory deallocation not supported in kdp remote debugging"); return error; } @@ -701,14 +700,14 @@ Status ProcessKDP::DisableBreakpointSite(BreakpointSite *bp_site) { Status ProcessKDP::EnableWatchpoint(Watchpoint *wp, bool notify) { Status error; error.SetErrorString( - "watchpoints are not suppported in kdp remote debugging"); + "watchpoints are not supported in kdp remote debugging"); return error; } Status ProcessKDP::DisableWatchpoint(Watchpoint *wp, bool notify) { Status error; error.SetErrorString( - "watchpoints are not suppported in kdp remote debugging"); + "watchpoints are not supported in kdp remote debugging"); return error; } @@ -717,7 +716,7 @@ void ProcessKDP::Clear() { m_thread_list.Clear(); } Status ProcessKDP::DoSignal(int signo) { Status error; error.SetErrorString( - "sending signals is not suppported in kdp remote debugging"); + "sending signals is not supported in kdp remote debugging"); return error; } diff --git a/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp b/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp index 1902cc492ff4f..7fca0fc24fdbf 100644 --- a/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp +++ b/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp @@ -52,11 +52,11 @@ ThreadKDP::~ThreadKDP() { const char *ThreadKDP::GetName() { if (m_thread_name.empty()) - return NULL; + return nullptr; return m_thread_name.c_str(); } -const char *ThreadKDP::GetQueueName() { return NULL; } +const char *ThreadKDP::GetQueueName() { return nullptr; } void ThreadKDP::RefreshStateAfterStop() { // Invalidate all registers in our register context. We don't set "force" to @@ -65,8 +65,8 @@ void ThreadKDP::RefreshStateAfterStop() { // context by the time this function gets called. The KDPRegisterContext // class has been made smart enough to detect when it needs to invalidate // which registers are valid by putting hooks in the register read and - // register supply functions where they check the process stop ID and do - // the right thing. + // register supply functions where they check the process stop ID and do the + // right thing. const bool force = false; lldb::RegisterContextSP reg_ctx_sp(GetRegisterContext()); if (reg_ctx_sp) @@ -79,8 +79,8 @@ void ThreadKDP::Dump(Log *log, uint32_t index) {} bool ThreadKDP::ShouldStop(bool &step_more) { return true; } lldb::RegisterContextSP ThreadKDP::GetRegisterContext() { - if (m_reg_context_sp.get() == NULL) - m_reg_context_sp = CreateRegisterContextForFrame(NULL); + if (!m_reg_context_sp) + m_reg_context_sp = CreateRegisterContextForFrame(nullptr); return m_reg_context_sp; } @@ -119,7 +119,7 @@ ThreadKDP::CreateRegisterContextForFrame(StackFrame *frame) { } } else { Unwind *unwinder = GetUnwinder(); - if (unwinder) + if (unwinder != nullptr) reg_ctx_sp = unwinder->CreateRegisterContextForFrame(frame); } return reg_ctx_sp; @@ -151,8 +151,8 @@ void ThreadKDP::SetStopInfoFrom_KDP_EXCEPTION( const uint32_t exc_type = exc_reply_packet.GetU32(&offset); const uint32_t exc_code = exc_reply_packet.GetU32(&offset); const uint32_t exc_subcode = exc_reply_packet.GetU32(&offset); - // We have to make a copy of the stop info because the thread list - // will iterate through the threads and clear all stop infos.. + // We have to make a copy of the stop info because the thread list will + // iterate through the threads and clear all stop infos.. // Let the StopInfoMachException::CreateStopReasonWithMachException() // function update the PC if needed as we might hit a software breakpoint |