diff options
author | Greg Clayton <gclayton@apple.com> | 2012-04-13 21:24:18 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-04-13 21:24:18 +0000 |
commit | d451c1a8432f038c42697ae8ed80a4a16d7489d9 (patch) | |
tree | 6844012bb7ad30ec4bb5caa39b98ac97579121cb /lldb/source/Plugins/Process | |
parent | f4db4b2cb4a639f0906abb8602cec49f1dc46de6 (diff) | |
download | bcm5719-llvm-d451c1a8432f038c42697ae8ed80a4a16d7489d9.tar.gz bcm5719-llvm-d451c1a8432f038c42697ae8ed80a4a16d7489d9.zip |
Added the thread ID (tid) to each packet history item and the packet history now always dumps to a lldb_private::Stream.
Enable logging the packet history when registers fail to read due to not getting the sequence mutex if "--verbose" is enabled on the log channel for the "gdb-remote" log category.
This will help us track down some issues.
llvm-svn: 154704
Diffstat (limited to 'lldb/source/Plugins/Process')
4 files changed, 95 insertions, 42 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 0d39e98f428..a6d2d114da9 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -46,6 +46,41 @@ GDBRemoteCommunication::History::~History () } void +GDBRemoteCommunication::History::AddPacket (char packet_char, + PacketType type, + uint32_t bytes_transmitted) +{ + const size_t size = m_packets.size(); + if (size > 0) + { + const uint32_t idx = GetNextIndex(); + m_packets[idx].packet.assign (1, packet_char); + m_packets[idx].type = type; + m_packets[idx].bytes_transmitted = bytes_transmitted; + m_packets[idx].packet_idx = m_total_packet_count; + m_packets[idx].tid = Host::GetCurrentThreadID(); + } +} + +void +GDBRemoteCommunication::History::AddPacket (const std::string &src, + uint32_t src_len, + PacketType type, + uint32_t bytes_transmitted) +{ + const size_t size = m_packets.size(); + if (size > 0) + { + const uint32_t idx = GetNextIndex(); + m_packets[idx].packet.assign (src, 0, src_len); + m_packets[idx].type = type; + m_packets[idx].bytes_transmitted = bytes_transmitted; + m_packets[idx].packet_idx = m_total_packet_count; + m_packets[idx].tid = Host::GetCurrentThreadID(); + } +} + +void GDBRemoteCommunication::History::Dump (lldb_private::Stream &strm) const { const uint32_t size = GetNumPacketsInHistory (); @@ -57,8 +92,9 @@ GDBRemoteCommunication::History::Dump (lldb_private::Stream &strm) const const Entry &entry = m_packets[idx]; if (entry.type == ePacketTypeInvalid || entry.packet.empty()) break; - strm.Printf ("history[%u] <%4u> %s packet: %s\n", + strm.Printf ("history[%u] tid=0x%4.4llx <%4u> %s packet: %s\n", entry.packet_idx, + entry.tid, entry.bytes_transmitted, (entry.type == ePacketTypeSend) ? "send" : "read", entry.packet.c_str()); @@ -80,8 +116,9 @@ GDBRemoteCommunication::History::Dump (lldb_private::Log *log) const const Entry &entry = m_packets[idx]; if (entry.type == ePacketTypeInvalid || entry.packet.empty()) break; - log->Printf ("history[%u] <%4u> %s packet: %s", + log->Printf ("history[%u] tid=0x%4.4llx <%4u> %s packet: %s", entry.packet_idx, + entry.tid, entry.bytes_transmitted, (entry.type == ePacketTypeSend) ? "send" : "read", entry.packet.c_str()); @@ -598,12 +635,7 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *debugserver_url, } void -GDBRemoteCommunication::DumpHistory(const char *path) +GDBRemoteCommunication::DumpHistory(Stream &strm) { - StreamFile strm; - Error error (strm.GetFile().Open(path, File::eOpenOptionWrite | File::eOpenOptionCanCreate)); - if (error.Success()) - m_history.Dump (strm); - else - fprintf (stderr, "error: unable to open '%s' -- %s\n", path, error.AsCString()); + m_history.Dump (strm); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h index 83bbfd59b8d..b3bad7ede5c 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h @@ -114,7 +114,7 @@ public: lldb_private::ProcessLaunchInfo &launch_info); void - DumpHistory(const char *path); + DumpHistory(lldb_private::Stream &strm); protected: @@ -134,7 +134,8 @@ protected: packet(), type (ePacketTypeInvalid), bytes_transmitted (0), - packet_idx (0) + packet_idx (0), + tid (LLDB_INVALID_THREAD_ID) { } @@ -145,12 +146,13 @@ protected: type = ePacketTypeInvalid; bytes_transmitted = 0; packet_idx = 0; - + tid = LLDB_INVALID_THREAD_ID; } std::string packet; PacketType type; uint32_t bytes_transmitted; uint32_t packet_idx; + lldb::tid_t tid; }; History (uint32_t size); @@ -161,35 +163,12 @@ protected: void AddPacket (char packet_char, PacketType type, - uint32_t bytes_transmitted) - { - const size_t size = m_packets.size(); - if (size > 0) - { - const uint32_t idx = GetNextIndex(); - m_packets[idx].packet.assign (1, packet_char); - m_packets[idx].type = type; - m_packets[idx].bytes_transmitted = bytes_transmitted; - m_packets[idx].packet_idx = m_total_packet_count; - } - } - + uint32_t bytes_transmitted); void AddPacket (const std::string &src, uint32_t src_len, PacketType type, - uint32_t bytes_transmitted) - { - const size_t size = m_packets.size(); - if (size > 0) - { - const uint32_t idx = GetNextIndex(); - m_packets[idx].packet.assign (src, 0, src_len); - m_packets[idx].type = type; - m_packets[idx].bytes_transmitted = bytes_transmitted; - m_packets[idx].packet_idx = m_total_packet_count; - } - } + uint32_t bytes_transmitted); void Dump (lldb_private::Stream &strm) const; diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp index ec2cfd88489..7ace1ebe477 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -246,7 +246,18 @@ GDBRemoteRegisterContext::ReadRegisterBytes (const RegisterInfo *reg_info, DataE { LogSP log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); if (log) - log->Printf("error: failed to get packet sequence mutex, not sending read register for \"%s\"", reg_info->name); + { + if (log->GetVerbose()) + { + StreamString strm; + gdb_comm.DumpHistory(strm); + log->Printf("error: failed to get packet sequence mutex, not sending read register for \"%s\":\n%s", reg_info->name, strm.GetData()); + } + else + { + log->Printf("error: failed to get packet sequence mutex, not sending read register for \"%s\"", reg_info->name); + } + } } // Make sure we got a valid register value after reading it @@ -431,7 +442,16 @@ GDBRemoteRegisterContext::WriteRegisterBytes (const lldb_private::RegisterInfo * { LogSP log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); if (log) - log->Printf("error: failed to get packet sequence mutex, not sending write register for \"%s\"", reg_info->name); + { + if (log->GetVerbose()) + { + StreamString strm; + gdb_comm.DumpHistory(strm); + log->Printf("error: failed to get packet sequence mutex, not sending write register for \"%s\":\n%s", reg_info->name, strm.GetData()); + } + else + log->Printf("error: failed to get packet sequence mutex, not sending write register for \"%s\"", reg_info->name); + } } } return false; @@ -492,7 +512,16 @@ GDBRemoteRegisterContext::ReadAllRegisterValues (lldb::DataBufferSP &data_sp) { LogSP log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); if (log) - log->Printf("error: failed to get packet sequence mutex, not sending read all registers"); + { + if (log->GetVerbose()) + { + StreamString strm; + gdb_comm.DumpHistory(strm); + log->Printf("error: failed to get packet sequence mutex, not sending read all registers:\n%s", strm.GetData()); + } + else + log->Printf("error: failed to get packet sequence mutex, not sending read all registers"); + } } data_sp.reset(); @@ -616,7 +645,16 @@ GDBRemoteRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data { LogSP log (ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet (GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); if (log) - log->Printf("error: failed to get packet sequence mutex, not sending write all registers"); + { + if (log->GetVerbose()) + { + StreamString strm; + gdb_comm.DumpHistory(strm); + log->Printf("error: failed to get packet sequence mutex, not sending write all registers:\n%s", strm.GetData()); + } + else + log->Printf("error: failed to get packet sequence mutex, not sending write all registers"); + } } return false; } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 77981efc446..ffb165d279c 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -32,6 +32,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/State.h" +#include "lldb/Core/StreamFile.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" #include "lldb/Core/Value.h" @@ -64,7 +65,10 @@ namespace lldb void DumpProcessGDBRemotePacketHistory (void *p, const char *path) { - ((ProcessGDBRemote *)p)->GetGDBRemote().DumpHistory (path); + lldb_private::StreamFile strm; + lldb_private::Error error (strm.GetFile().Open(path, lldb_private::File::eOpenOptionWrite | lldb_private::File::eOpenOptionCanCreate)); + if (error.Success()) + ((ProcessGDBRemote *)p)->GetGDBRemote().DumpHistory (strm); } }; |