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/SBThread.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/SBThread.cpp')
-rw-r--r-- | lldb/source/API/SBThread.cpp | 167 |
1 files changed, 160 insertions, 7 deletions
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index ee6b6874678..a0a00c1ec61 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -41,6 +41,10 @@ using namespace lldb_private; SBThread::SBThread () : m_opaque_sp () { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE); + + if (log) + log->Printf ("SBThread::SBThread () ==> this = %p", this); } //---------------------------------------------------------------------- @@ -49,10 +53,21 @@ SBThread::SBThread () : SBThread::SBThread (const ThreadSP& lldb_object_sp) : m_opaque_sp (lldb_object_sp) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE); + + if (log) + log->Printf ("SBThread::SBThread (const ThreadSP &lldb_object_sp) lldb_object_sp.get() = %p ==> this = %p", + lldb_object_sp.get(), this); } SBThread::SBThread (const SBThread &rhs) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE); + + if (log) + log->Printf ("SBThread::SBThread (const SBThread &rhs) rhs.m_opaque_sp.get() = %p ==> this = %p", + rhs.m_opaque_sp.get(), this); + m_opaque_sp = rhs.m_opaque_sp; } @@ -79,18 +94,33 @@ SBThread::Clear () StopReason SBThread::GetStopReason() { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::GetStopReason ()"); + + StopReason reason = eStopReasonInvalid; if (m_opaque_sp) { StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo (); if (stop_info_sp) - return stop_info_sp->GetStopReason(); + reason = stop_info_sp->GetStopReason(); } - return eStopReasonInvalid; + + if (log) + log->Printf ("SBThread::GetStopReason ==> %s", Thread::StopReasonAsCString (reason)); + + return reason; } size_t SBThread::GetStopDescription (char *dst, size_t dst_len) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::GetStopDescription (char *dst, size_t dst_len)"); + if (m_opaque_sp) { StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo (); @@ -99,6 +129,8 @@ SBThread::GetStopDescription (char *dst, size_t dst_len) const char *stop_desc = stop_info_sp->GetDescription(); if (stop_desc) { + if (log) + log->Printf ("SBThread::GetStopDescription ==> %s", stop_desc); if (dst) return ::snprintf (dst, dst_len, "%s", stop_desc); else @@ -163,6 +195,9 @@ SBThread::GetStopDescription (char *dst, size_t dst_len) if (stop_desc && stop_desc[0]) { + if (log) + log->Printf ("SBThread::GetStopDescription ==> %s", stop_desc); + if (dst) return ::snprintf (dst, dst_len, "%s", stop_desc) + 1; // Include the NULL byte @@ -189,10 +224,19 @@ SBThread::SetThread (const ThreadSP& lldb_object_sp) lldb::tid_t SBThread::GetThreadID () const { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::GetThreadID()"); + + lldb::tid_t id = LLDB_INVALID_THREAD_ID; if (m_opaque_sp) - return m_opaque_sp->GetID(); - else - return LLDB_INVALID_THREAD_ID; + id = m_opaque_sp->GetID(); + + if (log) + log->Printf ("SBThread::GetThreadID ==> %d", id); + + return id; } uint32_t @@ -205,16 +249,42 @@ SBThread::GetIndexID () const const char * SBThread::GetName () const { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::GetName ()"); + if (m_opaque_sp) + { + if (log) + log->Printf ("SBThread::GetName ==> %s", m_opaque_sp->GetName()); return m_opaque_sp->GetName(); + } + + if (log) + log->Printf ("SBThread::GetName ==> NULL"); + return NULL; } const char * SBThread::GetQueueName () const { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::GetQueueName ()"); + if (m_opaque_sp) + { + if (log) + log->Printf ("SBThread::GetQueueName ==> %s", m_opaque_sp->GetQueueName()); return m_opaque_sp->GetQueueName(); + } + + if (log) + log->Printf ("SBThread::GetQueueName ==> NULL"); + return NULL; } @@ -222,6 +292,12 @@ SBThread::GetQueueName () const void SBThread::StepOver (lldb::RunMode stop_other_threads) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::StepOver (lldb::RunMode stop_other_threads) stop_other_threads = %s)", + Thread::RunModeAsCString (stop_other_threads)); + if (m_opaque_sp) { bool abort_other_plans = true; @@ -265,6 +341,12 @@ SBThread::StepOver (lldb::RunMode stop_other_threads) void SBThread::StepInto (lldb::RunMode stop_other_threads) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::StepInto (lldb::RunMode stop_other_threads) stop_other_threads =%s", + Thread::RunModeAsCString (stop_other_threads)); + if (m_opaque_sp) { bool abort_other_plans = true; @@ -306,6 +388,11 @@ SBThread::StepInto (lldb::RunMode stop_other_threads) void SBThread::StepOut () { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::StepOut ()"); + if (m_opaque_sp) { bool abort_other_plans = true; @@ -329,6 +416,11 @@ SBThread::StepOut () void SBThread::StepInstruction (bool step_over) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::StepInstruction (bool step_over) step_over = %s", (step_over ? "true" : "false")); + if (m_opaque_sp) { m_opaque_sp->QueueThreadPlanForStepSingleInstruction (step_over, true, true); @@ -348,6 +440,11 @@ SBThread::StepInstruction (bool step_over) void SBThread::RunToAddress (lldb::addr_t addr) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::RunToAddress (lldb:;addr_t addr) addr = %p", addr); + if (m_opaque_sp) { bool abort_other_plans = true; @@ -373,35 +470,77 @@ SBThread::RunToAddress (lldb::addr_t addr) SBProcess SBThread::GetProcess () { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::GetProcess ()"); + SBProcess process; if (m_opaque_sp) { // Have to go up to the target so we can get a shared pointer to our process... process.SetProcess(m_opaque_sp->GetProcess().GetTarget().GetProcessSP()); } + + if (log) + { + SBStream sstr; + process.GetDescription (sstr); + log->Printf ("SBThread::GetProcess ==> SBProcess (this = %p, '%s')", &process, sstr.GetData()); + } + return process; } uint32_t SBThread::GetNumFrames () { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::GetNumFrames ()"); + + uint32_t num_frames = 0; if (m_opaque_sp) - return m_opaque_sp->GetStackFrameCount(); - return 0; + num_frames = m_opaque_sp->GetStackFrameCount(); + + if (log) + log->Printf ("SBThread::GetNumFrames ==> %d", num_frames); + + return num_frames; } SBFrame SBThread::GetFrameAtIndex (uint32_t idx) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::GetFrameAtIndex (uint32_t idx) idx = %d", idx); + SBFrame sb_frame; if (m_opaque_sp) sb_frame.SetFrame (m_opaque_sp->GetStackFrameAtIndex (idx)); + + if (log) + { + SBStream sstr; + sb_frame.GetDescription (sstr); + log->Printf ("SBThread::GetFrameAtIndex ==> SBFrame (this = %p, '%s')", &sb_frame, sstr.GetData()); + } + return sb_frame; } const lldb::SBThread & SBThread::operator = (const lldb::SBThread &rhs) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + + if (log) + log->Printf ("SBThread::operator= (const lldb::SBThread &rhs) rhs.m_opaque_sp.get() = %p ==> this = %p", + rhs.m_opaque_sp.get(), this); + m_opaque_sp = rhs.m_opaque_sp; return *this; } @@ -461,3 +600,17 @@ SBThread::GetDescription (SBStream &description) return true; } + +bool +SBThread::GetDescription (SBStream &description) const +{ + if (m_opaque_sp) + { + StreamString strm; + description.Printf("SBThread: tid = 0x%4.4x", m_opaque_sp->GetID()); + } + else + description.Printf ("No value"); + + return true; +} |