diff options
author | Caroline Tice <ctice@apple.com> | 2010-10-26 03:11:13 +0000 |
---|---|---|
committer | Caroline Tice <ctice@apple.com> | 2010-10-26 03:11:13 +0000 |
commit | ceb6b1393d05e3f5a7a235fd34bcf5d74ecc1f8d (patch) | |
tree | d49e665f965c7acfc1d122c6c5e1b128a7ef9d5a /lldb/source/API/SBCommunication.cpp | |
parent | e96b8d7ab66051f9fcbac5dfffd8dff7544a2909 (diff) | |
download | bcm5719-llvm-ceb6b1393d05e3f5a7a235fd34bcf5d74ecc1f8d.tar.gz bcm5719-llvm-ceb6b1393d05e3f5a7a235fd34bcf5d74ecc1f8d.zip |
First pass at adding logging capabilities for the API functions. At the moment
it logs the function calls, their arguments and the return values. This is not
complete or polished, but I am committing it now, at the request of someone who
really wants to use it, even though it's not really done. It currently does not
attempt to log all the functions, just the most important ones. I will be
making further adjustments to the API logging code over the next few days/weeks.
(Suggestions for improvements are welcome).
Update the Python build scripts to re-build the swig C++ file whenever
the python-extensions.swig file is modified.
Correct the help for 'log enable' command (give it the correct number & type of
arguments).
llvm-svn: 117349
Diffstat (limited to 'lldb/source/API/SBCommunication.cpp')
-rw-r--r-- | lldb/source/API/SBCommunication.cpp | 83 |
1 files changed, 76 insertions, 7 deletions
diff --git a/lldb/source/API/SBCommunication.cpp b/lldb/source/API/SBCommunication.cpp index b1ae37b3315..b6ca30d54e3 100644 --- a/lldb/source/API/SBCommunication.cpp +++ b/lldb/source/API/SBCommunication.cpp @@ -11,6 +11,7 @@ #include "lldb/API/SBBroadcaster.h" #include "lldb/Core/Communication.h" #include "lldb/Core/ConnectionFileDescriptor.h" +#include "lldb/Core/Log.h" using namespace lldb; using namespace lldb_private; @@ -21,12 +22,21 @@ SBCommunication::SBCommunication() : m_opaque (NULL), m_opaque_owned (false) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE); + + if (log) + log->Printf ("SBCommunication::SBCommunication () ==> this = %p", this); } SBCommunication::SBCommunication(const char * broadcaster_name) : m_opaque (new Communication (broadcaster_name)), m_opaque_owned (true) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE); + + if (log) + log->Printf ("SBCommunication::SBCommunication (const char *broadcaster_name) broadcaster_name = '%s' ==> " + "this = %p (m_opaque = %p)", broadcaster_name, this, m_opaque); } SBCommunication::~SBCommunication() @@ -76,19 +86,36 @@ SBCommunication::Connect (const char *url) ConnectionStatus SBCommunication::AdoptFileDesriptor (int fd, bool owns_fd) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBCommunication::AdoptFileDescriptor (%d, %s)", fd, (owns_fd ? "true" : "false")); + if (m_opaque) { if (m_opaque->HasConnection ()) { if (m_opaque->IsConnected()) - m_opaque->Disconnect (); + m_opaque->Disconnect(); } m_opaque->SetConnection (new ConnectionFileDescriptor (fd, owns_fd)); if (m_opaque->IsConnected()) + { + if (log) + log->Printf ("SBCommunication::AdoptFileDescriptor ==> eConnectionStatusSuccess"); return eConnectionStatusSuccess; + } else + { + if (log) + log->Printf ("SBCommunication::AdoptFileDescriptor ==> eConnectionStatusLostConnection"); return eConnectionStatusLostConnection; + } } + + if (log) + log->Printf ("SBCommunication::AdoptFileDescriptor ==> eConnectionStatusNoConnection"); + return eConnectionStatusNoConnection; } @@ -96,9 +123,19 @@ SBCommunication::AdoptFileDesriptor (int fd, bool owns_fd) ConnectionStatus SBCommunication::Disconnect () { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBCommunication::Disconnect ()"); + + ConnectionStatus status= eConnectionStatusNoConnection; if (m_opaque) - return m_opaque->Disconnect (); - return eConnectionStatusNoConnection; + status = m_opaque->Disconnect (); + + if (log) + log->Printf ("SBCommunication::Disconnect ==> %s", Communication::ConnectionStatusAsCString (status)); + + return status; } bool @@ -131,18 +168,38 @@ SBCommunication::Write (const void *src, size_t src_len, ConnectionStatus &statu bool SBCommunication::ReadThreadStart () { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBCommunication::ReadThreadStart ()"); + + bool success = false; if (m_opaque) - return m_opaque->StartReadThread (); - return false; + success = m_opaque->StartReadThread (); + + if (log) + log->Printf ("SBCommunication::ReadThreadStart ==> %s", (success ? "true" : "false")); + + return success; } bool SBCommunication::ReadThreadStop () { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBCommunication::ReadThreadStop ()"); + + bool success = false; if (m_opaque) - return m_opaque->StopReadThread (); - return false; + success = m_opaque->StopReadThread (); + + if (log) + log->Printf ("SBCommunication::ReadThreadStop ==> %s", (success ? "true" : "false")); + + return success; } bool @@ -160,11 +217,23 @@ SBCommunication::SetReadThreadBytesReceivedCallback void *callback_baton ) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBCommunication::SetReadThreadBytesReceivedCallback (callback, baton)"); + // CAROLINE: Fixme: Fix the arguments printed out in the log message above + if (m_opaque) { m_opaque->SetReadThreadBytesReceivedCallback (callback, callback_baton); + if (log) + log->Printf ("SBCommunication::SetReaDThreadBytesReceivedCallback ==> true"); return true; } + + if (log) + log->Printf ("SBCommunication::SetReaDThreadBytesReceivedCallback ==> false"); + return false; } |