diff options
Diffstat (limited to 'lldb/source/API')
23 files changed, 470 insertions, 489 deletions
diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp index 86d7fcb752a..618a2f54905 100644 --- a/lldb/source/API/SBAddress.cpp +++ b/lldb/source/API/SBAddress.cpp @@ -25,31 +25,15 @@ SBAddress::SBAddress () : SBAddress::SBAddress (const lldb_private::Address *lldb_object_ptr) : m_opaque_ap () { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - if (lldb_object_ptr) m_opaque_ap.reset (new lldb_private::Address(*lldb_object_ptr)); - - if (log) - { - SBStream sstr; - GetDescription (sstr); - log->Printf ("SBAddress::SBAddress (lldb_object_ptr=%p) " - "=> this.ap = %p (%s)", lldb_object_ptr, m_opaque_ap.get(), sstr.GetData()); - } } SBAddress::SBAddress (const SBAddress &rhs) : m_opaque_ap () { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - if (rhs.IsValid()) m_opaque_ap.reset (new lldb_private::Address(*rhs.m_opaque_ap.get())); - - if (log) - log->Printf ("SBAddress::SBAddress (rhs.m_opaque_ap = %p) => this.ap = %p", - (rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL), m_opaque_ap.get()); } SBAddress::~SBAddress () @@ -59,17 +43,8 @@ SBAddress::~SBAddress () const SBAddress & SBAddress::operator = (const SBAddress &rhs) { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - if (this != &rhs) - { - if (rhs.IsValid()) - m_opaque_ap.reset (new lldb_private::Address(*rhs.m_opaque_ap.get())); - } - if (log) - log->Printf ("SBAddress::operator= (rhs.ap = %p) => this.ap = %p", - (rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL), m_opaque_ap.get()); - + if (this != &rhs && rhs.IsValid()) + m_opaque_ap.reset (new lldb_private::Address(*rhs.m_opaque_ap.get())); return *this; } @@ -113,21 +88,18 @@ lldb::addr_t SBAddress::GetLoadAddress (const SBTarget &target) const { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - //if (log) - // log->Printf ("SBAddress::GetLoadAddress"); if (m_opaque_ap.get()) { lldb::addr_t addr = m_opaque_ap->GetLoadAddress (target.get()); if (log) - log->Printf ("SBAddress::GetLoadAddress (target.sp=%p) => %p", target.get(), addr); + log->Printf ("SBAddress::GetLoadAddress (SBTarget(%p)) => 0x%llx", target.get(), addr); return addr; } else { if (log) - log->Printf ("SBAddress::GetLoadAddress (target.sp=%p) => LLDB_INVALID_ADDRESS", target.get()); + log->Printf ("SBAddress::GetLoadAddress (SBTarget(%p)) => LLDB_INVALID_ADDRESS", target.get()); return LLDB_INVALID_ADDRESS; } } @@ -183,11 +155,11 @@ SBAddress::get () bool SBAddress::GetDescription (SBStream &description) { + // Call "ref()" on the stream to make sure it creates a backing stream in + // case there isn't one already... description.ref(); if (m_opaque_ap.get()) - { - m_opaque_ap->DumpDebug (description.get()); - } + m_opaque_ap->Dump (description.get(), NULL, Address::DumpStyleModuleWithFileAddress, Address::DumpStyleInvalid, 4); else description.Printf ("No value"); diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp index d14865902b0..cb936241efa 100644 --- a/lldb/source/API/SBBreakpointLocation.cpp +++ b/lldb/source/API/SBBreakpointLocation.cpp @@ -242,7 +242,7 @@ SBBreakpointLocation::GetBreakpoint () { SBStream sstr; sb_bp.GetDescription (sstr); - log->Printf ("SBBreakpointLocation::GetBreakpoint (this.sp=%p) => SBBreakpoint: m_opaque_sp=%p, '%s'", + log->Printf ("SBBreakpointLocation(%p)::GetBreakpoint () => SBBreakpoint(%p) %s", m_opaque_sp.get(), sb_bp.get(), sstr.GetData()); } return sb_bp; diff --git a/lldb/source/API/SBBroadcaster.cpp b/lldb/source/API/SBBroadcaster.cpp index ba6bc2f591f..348b710bdd8 100644 --- a/lldb/source/API/SBBroadcaster.cpp +++ b/lldb/source/API/SBBroadcaster.cpp @@ -37,7 +37,7 @@ SBBroadcaster::SBBroadcaster (const char *name) : Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE); if (log) - log->Printf ("SBBroadcaster::SBBroadcaster (name='%s') => SBBroadcaster(%p)", + log->Printf ("SBBroadcaster::SBBroadcaster (name=\"%s\") => SBBroadcaster(%p)", name, m_opaque); } @@ -111,10 +111,10 @@ SBBroadcaster::AddListener (const SBListener &listener, uint32_t event_mask) } const char * -SBBroadcaster::GetName () +SBBroadcaster::GetName () const { if (m_opaque) - return m_opaque->GetBroadcasterName().AsCString(); + return m_opaque->GetBroadcasterName().GetCString(); return NULL; } diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 0c30ac93672..d5ccd20e417 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -73,8 +73,8 @@ SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnOb Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBCommandInterpreter(%p)::HandleCommand (command_line='%s', result=%p, add_to_history=%i)", - m_opaque_ptr, command_line, &result, add_to_history); + log->Printf ("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", SBCommandReturnObject(%p), add_to_history=%i)", + m_opaque_ptr, command_line, result.get(), add_to_history); result.Clear(); if (m_opaque_ptr) @@ -93,8 +93,8 @@ SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnOb { SBStream sstr; result.GetDescription (sstr); - log->Printf ("SBCommandInterpreter(%p)::HandleCommand (\"%s\") => SBCommandReturnObject(%p): '%s'", - m_opaque_ptr, command_line, result.get(), sstr.GetData()); + log->Printf ("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", SBCommandReturnObject(%p): %s, add_to_history=%i) => %i", + m_opaque_ptr, command_line, result.get(), sstr.GetData(), add_to_history, result.GetStatus()); } return result.GetStatus(); diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index d4091ce49bf..778ecb0e4c3 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -19,10 +19,6 @@ using namespace lldb_private; SBCommandReturnObject::SBCommandReturnObject () : m_opaque_ap (new CommandReturnObject ()) { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - if (log) - log->Printf ("SBCommandReturnObject::SBCommandReturnObject () => this.ap = %p", m_opaque_ap.get()); } SBCommandReturnObject::~SBCommandReturnObject () @@ -42,20 +38,17 @@ SBCommandReturnObject::GetOutput () { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - //if (log) - // log->Printf ("SBCommandReturnObject::GetOutput ()"); - if (m_opaque_ap.get()) { if (log) - log->Printf ("SBCommandReturnObject::GetOutput (this.ap=%p) => '%s'", m_opaque_ap.get(), + log->Printf ("SBCommandReturnObject(%p)::GetOutput () => \"%s\"", m_opaque_ap.get(), m_opaque_ap->GetOutputStream().GetData()); return m_opaque_ap->GetOutputStream().GetData(); } if (log) - log->Printf ("SBCommandReturnObject::GetOutput (this.ap=%p) => 'NULL'", m_opaque_ap.get()); + log->Printf ("SBCommandReturnObject(%p)::GetOutput () => NULL", m_opaque_ap.get()); return NULL; } @@ -65,20 +58,17 @@ SBCommandReturnObject::GetError () { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - //if (log) - // log->Printf ("SBCommandReturnObject::GetError ()"); - if (m_opaque_ap.get()) { if (log) - log->Printf ("SBCommandReturnObject::GetError (this.ap=%p) => '%s'", m_opaque_ap.get(), + log->Printf ("SBCommandReturnObject(%p)::GetError () => \"%s\"", m_opaque_ap.get(), m_opaque_ap->GetErrorStream().GetData()); return m_opaque_ap->GetErrorStream().GetData(); } if (log) - log->Printf ("SBCommandReturnObject::GetError (this.ap=%p) => 'NULL'", m_opaque_ap.get()); + log->Printf ("SBCommandReturnObject(%p)::GetError () => NULL", m_opaque_ap.get()); return NULL; } diff --git a/lldb/source/API/SBCommunication.cpp b/lldb/source/API/SBCommunication.cpp index e628e228b85..fca4882f523 100644 --- a/lldb/source/API/SBCommunication.cpp +++ b/lldb/source/API/SBCommunication.cpp @@ -31,8 +31,8 @@ SBCommunication::SBCommunication(const char * broadcaster_name) : Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBCommunication::SBCommunication (broadcaster_name='%s') => " - "SBCommunication(%p): owned = 1", broadcaster_name, m_opaque); + log->Printf ("SBCommunication::SBCommunication (broadcaster_name=\"%s\") => " + "SBCommunication(%p)", broadcaster_name, m_opaque); } SBCommunication::~SBCommunication() diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp index f93e0121ab8..39505075847 100644 --- a/lldb/source/API/SBCompileUnit.cpp +++ b/lldb/source/API/SBCompileUnit.cpp @@ -27,15 +27,6 @@ SBCompileUnit::SBCompileUnit () : SBCompileUnit::SBCompileUnit (lldb_private::CompileUnit *lldb_object_ptr) : m_opaque_ptr (lldb_object_ptr) { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - if (log) - { - SBStream sstr; - GetDescription (sstr); - log->Printf ("SBCompileUnit::SBCompileUnit (lldb_private::CompileUnit *lldb_object_ptr=%p)" - " => this.obj = %p (%s)", lldb_object_ptr, m_opaque_ptr, sstr.GetData()); - } } SBCompileUnit::~SBCompileUnit () @@ -69,9 +60,6 @@ SBCompileUnit::GetLineEntryAtIndex (uint32_t idx) const { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - //if (log) - // log->Printf ("SBCompileUnit::GetLineEntryAtIndex (this.obj=%p, idx=%d)", m_opaque_ptr, idx); - SBLineEntry sb_line_entry; if (m_opaque_ptr) { @@ -88,8 +76,8 @@ SBCompileUnit::GetLineEntryAtIndex (uint32_t idx) const { SBStream sstr; sb_line_entry.GetDescription (sstr); - log->Printf ("SBCompileUnit::GetLineEntryAtIndex (this.obj=%p, idx=%d) => SBLineEntry: '%s'", m_opaque_ptr, - idx, sstr.GetData()); + log->Printf ("SBCompileUnit(%p)::GetLineEntryAtIndex (idx=%u) => SBLineEntry(%p): '%s'", + m_opaque_ptr, idx, sb_line_entry.get(), sstr.GetData()); } return sb_line_entry; @@ -100,14 +88,7 @@ SBCompileUnit::FindLineEntryIndex (uint32_t start_idx, uint32_t line, SBFileSpec { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - //if (log) - //{ - // SBStream sstr; - // inline_file_spec->GetDescription (sstr); - // log->Printf ("SBCompileUnit::FindLineEntryIndex (this.obj=%p, start_idx=%d, line=%d, inline_file_spec='%s')", - // m_opaque_ptr, start_idx, line, sstr.GetData()); - //} - + uint32_t index = UINT32_MAX; if (m_opaque_ptr) { FileSpec file_spec; @@ -117,30 +98,28 @@ SBCompileUnit::FindLineEntryIndex (uint32_t start_idx, uint32_t line, SBFileSpec file_spec = *m_opaque_ptr; - uint32_t ret_value = m_opaque_ptr->FindLineEntry (start_idx, - line, - inline_file_spec ? inline_file_spec->get() : NULL, - NULL); - if (log) - { - SBStream sstr; - inline_file_spec->GetDescription (sstr); - log->Printf ("SBCompileUnit::FindLineEntryIndex(this.obj=%p, start_idx=%d, line=%d, inline_file_spec='%s')" - "=> '%d'", m_opaque_ptr, start_idx, line, sstr.GetData(), ret_value); - } - - return ret_value; + index = m_opaque_ptr->FindLineEntry (start_idx, + line, + inline_file_spec ? inline_file_spec->get() : NULL, + NULL); } if (log) { SBStream sstr; - inline_file_spec->GetDescription (sstr); - log->Printf ("SBCompileUnit::FindLineEntryIndex (this.obj=%p, start_idx=%d, line=%d, inline_file_spec='%s')" - " => '%d'", m_opaque_ptr, start_idx, line, sstr.GetData(), UINT32_MAX); + if (index == UINT32_MAX) + { + log->Printf ("SBCompileUnit(%p)::FindLineEntryIndex (start_idx=%u, line=%u, SBFileSpec(%p)) => NOT FOUND", + m_opaque_ptr, start_idx, line, inline_file_spec ? inline_file_spec->get() : NULL); + } + else + { + log->Printf ("SBCompileUnit(%p)::FindLineEntryIndex (start_idx=%u, line=%u, SBFileSpec(%p)) => %u", + m_opaque_ptr, start_idx, line, inline_file_spec ? inline_file_spec->get() : NULL, index); + } } - return UINT32_MAX; + return index; } bool diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index a0aa1257571..cf49d754da7 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -118,8 +118,8 @@ SBDebugger::SetInputFileHandle (FILE *fh, bool transfer_ownership) Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBDebugger(%p)::SetInputFileHandle (fh=%p, transfer_ownership='%s')", m_opaque_sp.get(), - fh, (transfer_ownership ? "true" : "false")); + log->Printf ("SBDebugger(%p)::SetInputFileHandle (fh=%p, transfer_ownership=%i)", m_opaque_sp.get(), + fh, transfer_ownership); if (m_opaque_sp) m_opaque_sp->SetInputFileHandle (fh, transfer_ownership); @@ -132,8 +132,8 @@ SBDebugger::SetOutputFileHandle (FILE *fh, bool transfer_ownership) if (log) - log->Printf ("SBDebugger(%p)::SetOutputFileHandle (fh=%p, transfer_ownership='%s')", m_opaque_sp.get(), - fh, (transfer_ownership ? "true" : "false")); + log->Printf ("SBDebugger(%p)::SetOutputFileHandle (fh=%p, transfer_ownership=%i)", m_opaque_sp.get(), + fh, transfer_ownership); if (m_opaque_sp) m_opaque_sp->SetOutputFileHandle (fh, transfer_ownership); @@ -146,8 +146,8 @@ SBDebugger::SetErrorFileHandle (FILE *fh, bool transfer_ownership) if (log) - log->Printf ("SBDebugger(%p)::SetErrorFileHandle (fh=%p, transfer_ownership='%s')", m_opaque_sp.get(), - fh, (transfer_ownership ? "true" : "false")); + log->Printf ("SBDebugger(%p)::SetErrorFileHandle (fh=%p, transfer_ownership=%i)", m_opaque_sp.get(), + fh, transfer_ownership); if (m_opaque_sp) m_opaque_sp->SetErrorFileHandle (fh, transfer_ownership); @@ -459,7 +459,7 @@ SBDebugger::CreateTargetWithFileAndTargetTriple (const char *filename, Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) { - log->Printf ("SBDebugger(%p)::CreateTargetWithFileAndTargetTriple (filename='%s', tiple = %s) => SBTarget(%p)", + log->Printf ("SBDebugger(%p)::CreateTargetWithFileAndTargetTriple (filename=\"%s\", triple=%s) => SBTarget(%p)", m_opaque_sp.get(), filename, target_triple, target.get()); } @@ -511,7 +511,7 @@ SBDebugger::CreateTargetWithFileAndArch (const char *filename, const char *archn if (log) { - log->Printf ("SBDebugger(%p)::CreateTargetWithFileAndArch (filename='%s', arch = %s) => SBTarget(%p)", + log->Printf ("SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", arch=%s) => SBTarget(%p)", m_opaque_sp.get(), filename, archname, target.get()); } @@ -553,7 +553,7 @@ SBDebugger::CreateTarget (const char *filename) Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) { - log->Printf ("SBDebugger(%p)::CreateTarget (filename='%s') => SBTarget(%p)", + log->Printf ("SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)", m_opaque_sp.get(), filename, target.get()); } return target; @@ -636,8 +636,8 @@ SBDebugger::DispatchInput (void *baton, const void *data, size_t data_len) Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBDebugger(%p)::DispatchInput (baton=%p, data='%s', size_t=%d)", m_opaque_sp.get(), - baton, (const char *) data, (uint32_t) data_len); + log->Printf ("SBDebugger(%p)::DispatchInput (baton=%p, data=\"%.*s\", size_t=%zu)", m_opaque_sp.get(), + baton, (int) data_len, (const char *) data, data_len); if (m_opaque_sp) m_opaque_sp->DispatchInput ((const char *) data, data_len); @@ -756,7 +756,7 @@ SBDebugger::GetPrompt() const Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBDebugger(%p)::GetPrompt () => '%s'", m_opaque_sp.get(), + log->Printf ("SBDebugger(%p)::GetPrompt () => \"%s\"", m_opaque_sp.get(), (m_opaque_sp ? m_opaque_sp->GetPrompt() : "")); if (m_opaque_sp) @@ -815,7 +815,7 @@ SBDebugger::GetDescription (SBStream &description) { const char *name = m_opaque_sp->GetInstanceName().AsCString(); lldb::user_id_t id = m_opaque_sp->GetID(); - description.Printf ("Debugger (instance: '%s', id: %d)", name, id); + description.Printf ("Debugger (instance: \"%s\", id: %d)", name, id); } else description.Printf ("No value"); diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp index 229b894e799..935a869e57b 100644 --- a/lldb/source/API/SBError.cpp +++ b/lldb/source/API/SBError.cpp @@ -26,18 +26,8 @@ SBError::SBError () : SBError::SBError (const SBError &rhs) : m_opaque_ap () { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - if (rhs.IsValid()) m_opaque_ap.reset (new Error(*rhs)); - - if (log) - { - SBStream sstr; - GetDescription (sstr); - log->Printf ("SBError::SBError (const SBError rhs.ap=%p) => SBError(%p): %s", - rhs.m_opaque_ap.get(), m_opaque_ap.get(), sstr.GetData()); - } } @@ -48,8 +38,6 @@ SBError::~SBError() const SBError & SBError::operator = (const SBError &rhs) { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - void *old_error = m_opaque_ap.get(); if (rhs.IsValid()) { if (m_opaque_ap.get()) @@ -58,17 +46,7 @@ SBError::operator = (const SBError &rhs) m_opaque_ap.reset (new Error(*rhs)); } else - { m_opaque_ap.reset(); - } - - if (log) - { - SBStream sstr; - GetDescription (sstr); - log->Printf ("SBError(%p)::operator= (SBError(%p)) => SBError(%s)", - old_error, rhs.m_opaque_ap.get(), sstr.GetData()); - } return *this; } diff --git a/lldb/source/API/SBEvent.cpp b/lldb/source/API/SBEvent.cpp index d5653dfb7e0..a976c42037a 100644 --- a/lldb/source/API/SBEvent.cpp +++ b/lldb/source/API/SBEvent.cpp @@ -33,26 +33,12 @@ SBEvent::SBEvent (uint32_t event_type, const char *cstr, uint32_t cstr_len) : m_event_sp (new Event (event_type, new EventDataBytes (cstr, cstr_len))), m_opaque (m_event_sp.get()) { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - if (log) - { - log->Printf ("SBEvent::SBEvent (event_type=0x%8.8x, cstr='%s', cstr_len=%d) => SBEvent(%p)", - event_type, - cstr, - cstr_len, - m_opaque); - } } SBEvent::SBEvent (EventSP &event_sp) : m_event_sp (event_sp), m_opaque (event_sp.get()) { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - if (log) - log->Printf ("SBEvent::SBEvent (event_sp=%p) => SBEvent(%p)", event_sp.get(), m_opaque); } SBEvent::~SBEvent() @@ -79,7 +65,14 @@ SBEvent::GetType () const event_type = lldb_event->GetType(); if (log) - log->Printf ("SBEvent(%p)::GetType () => 0x%8.8x", get(), event_type); + { + StreamString sstr; + if (lldb_event && lldb_event->GetBroadcaster() && lldb_event->GetBroadcaster()->GetEventNames(sstr, event_type, true)) + log->Printf ("SBEvent(%p)::GetType () => 0x%8.8x (%s)", get(), event_type, sstr.GetData()); + else + log->Printf ("SBEvent(%p)::GetType () => 0x%8.8x", get(), event_type); + + } return event_type; } @@ -98,28 +91,26 @@ bool SBEvent::BroadcasterMatchesPtr (const SBBroadcaster *broadcaster) { if (broadcaster) - { - Event *lldb_event = get(); - if (lldb_event) - return lldb_event->BroadcasterIs (broadcaster->get()); - } + return BroadcasterMatchesRef (*broadcaster); return false; } bool SBEvent::BroadcasterMatchesRef (const SBBroadcaster &broadcaster) { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); Event *lldb_event = get(); bool success = false; if (lldb_event) success = lldb_event->BroadcasterIs (broadcaster.get()); + // For logging, this gets a little chatty so only enable this when verbose logging is on + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API | LIBLLDB_LOG_VERBOSE); if (log) - log->Printf ("SBEvent(%p)::BroadcasterMatchesRef (SBBroadcaster(%p)) => %i", + log->Printf ("SBEvent(%p)::BroadcasterMatchesRef (SBBroadcaster(%p): %s) => %i", get(), broadcaster.get(), + broadcaster.GetName(), success); return success; @@ -181,7 +172,7 @@ SBEvent::GetCStringFromEvent (const SBEvent &event) Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBEvent(%p)::GetCStringFromEvent () => '%s'", + log->Printf ("SBEvent(%p)::GetCStringFromEvent () => \"%s\"", event.get(), reinterpret_cast<const char *>(EventDataBytes::GetBytesFromEvent (event.get()))); diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp index 9aa3f8ace8f..fc223405eb5 100644 --- a/lldb/source/API/SBFileSpec.cpp +++ b/lldb/source/API/SBFileSpec.cpp @@ -34,7 +34,7 @@ SBFileSpec::SBFileSpec (const SBFileSpec &rhs) : { SBStream sstr; GetDescription (sstr); - log->Printf ("SBFileSpec::SBFileSpec (const SBFileSpec rhs.ap=%p) => SBFileSpec(%p) ('%s')", + log->Printf ("SBFileSpec::SBFileSpec (const SBFileSpec rhs.ap=%p) => SBFileSpec(%p): %s", rhs.m_opaque_ap.get(), m_opaque_ap.get(), sstr.GetData()); } } @@ -51,7 +51,7 @@ SBFileSpec::SBFileSpec (const char *path, bool resolve) : Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBFileSpec::SBFileSpec (path='%s', resolve=%i) => SBFileSpec(%p)", path, + log->Printf ("SBFileSpec::SBFileSpec (path=\"%s\", resolve=%i) => SBFileSpec(%p)", path, resolve, m_opaque_ap.get()); } @@ -114,7 +114,12 @@ SBFileSpec::GetFilename() const Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBFileSpec(%p)::GetFilename () => \"%s\"", m_opaque_ap.get(), s ? s : ""); + { + if (s) + log->Printf ("SBFileSpec(%p)::GetFilename () => \"%s\"", m_opaque_ap.get(), s); + else + log->Printf ("SBFileSpec(%p)::GetFilename () => NULL", m_opaque_ap.get()); + } return s; } @@ -127,7 +132,12 @@ SBFileSpec::GetDirectory() const s = m_opaque_ap->GetDirectory().AsCString(); Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBFileSpec(%p)::GetDirectory () => \"%s\"", m_opaque_ap.get(), s ? s : ""); + { + if (s) + log->Printf ("SBFileSpec(%p)::GetDirectory () => \"%s\"", m_opaque_ap.get(), s); + else + log->Printf ("SBFileSpec(%p)::GetDirectory () => NULL", m_opaque_ap.get()); + } return s; } @@ -136,22 +146,17 @@ SBFileSpec::GetPath (char *dst_path, size_t dst_len) const { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - uint32_t result; + uint32_t result = 0; if (m_opaque_ap.get()) - { result = m_opaque_ap->GetPath (dst_path, dst_len); - if (log) - log->Printf ("SBFileSpec(%p)::GetPath (dst_path, dst_len) => dst_path='%s', dst_len='%d', " - "result='%d'", m_opaque_ap.get(), dst_path, (uint32_t) dst_len, result); - return result; - } if (log) - log->Printf ("SBFileSpec(%p)::GetPath (dst_path, dst_len) => NULL (0)", m_opaque_ap.get()); + log->Printf ("SBFileSpec(%p)::GetPath (dst_path=\"%.*s\", dst_len=%zu) => %u", + m_opaque_ap.get(), result, dst_path, dst_len, result); - if (dst_path && dst_len) + if (result == 0 && dst_path && dst_len > 0) *dst_path = '\0'; - return 0; + return result; } @@ -195,14 +200,9 @@ SBFileSpec::GetDescription (SBStream &description) const { if (m_opaque_ap.get()) { - const char *filename = GetFilename(); - const char *dir_name = GetDirectory(); - if (!filename && !dir_name) - description.Printf ("No value"); - else if (!dir_name) - description.Printf ("%s", filename); - else - description.Printf ("%s/%s", dir_name, filename); + char path[PATH_MAX]; + if (m_opaque_ap->GetPath(path, sizeof(path))) + description.Printf ("%s", path); } else description.Printf ("No value"); diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index cb03d69d119..1d9080825d1 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -210,7 +210,7 @@ SBFrame::GetPC () const Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBFrame(%p)::GetPC () => %0xllx", m_opaque_sp.get(), addr); + log->Printf ("SBFrame(%p)::GetPC () => 0x%llx", m_opaque_sp.get(), addr); return addr; } @@ -239,7 +239,7 @@ SBFrame::GetSP () const addr = m_opaque_sp->GetRegisterContext()->GetSP(); Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBFrame(%p)::GetSP () => %0xllx", m_opaque_sp.get(), addr); + log->Printf ("SBFrame(%p)::GetSP () => 0x%llx", m_opaque_sp.get(), addr); return addr; } @@ -254,7 +254,7 @@ SBFrame::GetFP () const Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBFrame(%p)::GetFP () => %0xllx", m_opaque_sp.get(), addr); + log->Printf ("SBFrame(%p)::GetFP () => 0x%llx", m_opaque_sp.get(), addr); return addr; } @@ -536,11 +536,8 @@ SBFrame::GetDescription (SBStream &description) { if (m_opaque_sp) { - SBLineEntry line_entry = GetLineEntry (); - SBFileSpec file_spec = line_entry.GetFileSpec (); - uint32_t line = line_entry.GetLine (); - description.Printf("SBFrame: idx = %u ('%s', %s, line %d)", m_opaque_sp->GetFrameIndex(), - GetFunction().GetName(), file_spec.GetFilename(), line); + Stream &s = description.ref(); + m_opaque_sp->DumpUsingSettingsFormat (&s); } else description.Printf ("No value"); @@ -553,7 +550,7 @@ SBFrame::EvaluateExpression (const char *expr) { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - lldb::SBValue expr_result_value; + lldb::SBValue expr_result; if (log) log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\")...", m_opaque_sp.get(), expr); @@ -567,11 +564,11 @@ SBFrame::EvaluateExpression (const char *expr) if (exe_ctx.target) prefix = exe_ctx.target->GetExpressionPrefixContentsAsCString(); - *expr_result_value = ClangUserExpression::Evaluate (exe_ctx, expr, prefix); + *expr_result = ClangUserExpression::Evaluate (exe_ctx, expr, prefix); } if (log) - log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p)", m_opaque_sp.get(), expr_result_value.get()); + log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p)", m_opaque_sp.get(), expr, expr_result.get()); - return expr_result_value; + return expr_result; } diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp index 2efd37c31ba..34f879af709 100644 --- a/lldb/source/API/SBFunction.cpp +++ b/lldb/source/API/SBFunction.cpp @@ -30,16 +30,6 @@ SBFunction::SBFunction () : SBFunction::SBFunction (lldb_private::Function *lldb_object_ptr) : m_opaque_ptr (lldb_object_ptr) { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - if (log) - { - SBStream sstr; - GetDescription (sstr); - log->Printf ("SBFunction::SBFunction (lldb_object_ptr=%p) => this.obj = %p ('%s')", lldb_object_ptr, - m_opaque_ptr, sstr.GetData()); - - } } SBFunction::~SBFunction () @@ -56,30 +46,36 @@ SBFunction::IsValid () const const char * SBFunction::GetName() const { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - //if (log) - // log->Printf ("SBFunction::GetName ()"); - + const char *cstr = NULL; if (m_opaque_ptr) - { - if (log) - log->Printf ("SBFunction::GetName (this.obj=%p) => '%s'", m_opaque_ptr, - m_opaque_ptr->GetMangled().GetName().AsCString()); - return m_opaque_ptr->GetMangled().GetName().AsCString(); - } + cstr = m_opaque_ptr->GetMangled().GetName().AsCString(); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBFunction::GetName (this.obj=%p) => NULL", m_opaque_ptr); - return NULL; + { + if (cstr) + log->Printf ("SBFunction(%p)::GetName () => \"%s\"", m_opaque_ptr, cstr); + else + log->Printf ("SBFunction(%p)::GetName () => NULL", m_opaque_ptr); + } + return cstr; } const char * SBFunction::GetMangledName () const { + const char *cstr = NULL; if (m_opaque_ptr) - return m_opaque_ptr->GetMangled().GetMangledName().AsCString(); - return NULL; + cstr = m_opaque_ptr->GetMangled().GetMangledName().AsCString(); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + { + if (cstr) + log->Printf ("SBFunction(%p)::GetMangledName () => \"%s\"", m_opaque_ptr, cstr); + else + log->Printf ("SBFunction(%p)::GetMangledName () => NULL", m_opaque_ptr); + } + return cstr; } bool diff --git a/lldb/source/API/SBHostOS.cpp b/lldb/source/API/SBHostOS.cpp index 7efb8f77ac9..86cb66cccdb 100644 --- a/lldb/source/API/SBHostOS.cpp +++ b/lldb/source/API/SBHostOS.cpp @@ -38,7 +38,7 @@ SBHostOS::ThreadCreate Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBHostOS::ThreadCreate (name='%s', thread_function=%p, thread_arg=%p, error_ptr=%p)", name, + log->Printf ("SBHostOS::ThreadCreate (name=\"%s\", thread_function=%p, thread_arg=%p, error_ptr=%p)", name, thread_function, thread_arg, error_ptr); // CAROLINE: FIXME: You need to log a return value? diff --git a/lldb/source/API/SBInputReader.cpp b/lldb/source/API/SBInputReader.cpp index 616638b6717..98b03c1c0d0 100644 --- a/lldb/source/API/SBInputReader.cpp +++ b/lldb/source/API/SBInputReader.cpp @@ -88,7 +88,7 @@ SBInputReader::Initialize if (log) log->Printf("SBInputReader(%p)::Initialize (SBDebugger(%p), callback_function=%p, callback_baton=%p, " - "granularity='%s', end_token='%s', prompt='%s', echo=%i)", + "granularity=%s, end_token=\"%s\", prompt=\"%s\", echo=%i)", m_opaque_sp.get(), debugger.get(), callback_function, diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp index b79761fac8b..80bf84e6a3e 100644 --- a/lldb/source/API/SBLineEntry.cpp +++ b/lldb/source/API/SBLineEntry.cpp @@ -9,8 +9,9 @@ #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBStream.h" -#include "lldb/Symbol/LineEntry.h" +#include "lldb/Core/StreamString.h" #include "lldb/Core/Log.h" +#include "lldb/Symbol/LineEntry.h" using namespace lldb; using namespace lldb_private; @@ -24,17 +25,8 @@ SBLineEntry::SBLineEntry () : SBLineEntry::SBLineEntry (const SBLineEntry &rhs) : m_opaque_ap () { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - if (rhs.IsValid()) - { m_opaque_ap.reset (new lldb_private::LineEntry (*rhs)); - } - - if (log) - log->Printf ("SBLineEntry::SBLineEntry (rhs.ap=%p) => this.ap = %p ", - (rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL), m_opaque_ap.get()); - } @@ -42,24 +34,15 @@ SBLineEntry::SBLineEntry (const SBLineEntry &rhs) : SBLineEntry::SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr) : m_opaque_ap () { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - if (lldb_object_ptr) m_opaque_ap.reset (new lldb_private::LineEntry(*lldb_object_ptr)); - - if (log) - log->Printf ("SBLineEntry::SBLineEntry (lldb_object_ptr=%p) => this.ap = %p", - lldb_object_ptr, m_opaque_ap.get()); } const SBLineEntry & SBLineEntry::operator = (const SBLineEntry &rhs) { - if (this != &rhs) - { - if (rhs.IsValid()) - m_opaque_ap.reset (new lldb_private::LineEntry(*rhs)); - } + if (this != &rhs && rhs.IsValid()) + m_opaque_ap.reset (new lldb_private::LineEntry(*rhs)); return *this; } @@ -81,21 +64,19 @@ SBLineEntry::~SBLineEntry () SBAddress SBLineEntry::GetStartAddress () const { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - //if (log) - // log->Printf ("SBLineEntry::GetStartAddress ()"); SBAddress sb_address; if (m_opaque_ap.get()) sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress()); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) { - SBStream sstr; - sb_address.GetDescription (sstr); - log->Printf ("SBLineEntry::GetStartAddress (this.ap=%p) => SBAddress (this.ap = %p, (%s)", m_opaque_ap.get(), - sb_address.get(), sstr.GetData()); + StreamString sstr; + if (sb_address.get()) + sb_address->Dump (&sstr, NULL, Address::DumpStyleModuleWithFileAddress, Address::DumpStyleInvalid, 4); + log->Printf ("SBLineEntry(%p)::GetStartAddress () => SBAddress (%p): %s", + m_opaque_ap.get(), sb_address.get(), sstr.GetData()); } return sb_address; @@ -110,6 +91,15 @@ SBLineEntry::GetEndAddress () const sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress()); sb_address.OffsetAddress(m_opaque_ap->range.GetByteSize()); } + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + { + StreamString sstr; + if (sb_address.get()) + sb_address->Dump (&sstr, NULL, Address::DumpStyleModuleWithFileAddress, Address::DumpStyleInvalid, 4); + log->Printf ("SBLineEntry(%p)::GetEndAddress () => SBAddress (%p): %s", + m_opaque_ap.get(), sb_address.get(), sstr.GetData()); + } return sb_address; } @@ -125,9 +115,6 @@ SBLineEntry::GetFileSpec () const { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - //if (log) - // log->Printf ("SBLineEntry::GetFileSpec ()"); - SBFileSpec sb_file_spec; if (m_opaque_ap.get() && m_opaque_ap->file) sb_file_spec.SetFileSpec(m_opaque_ap->file); @@ -136,7 +123,7 @@ SBLineEntry::GetFileSpec () const { SBStream sstr; sb_file_spec.GetDescription (sstr); - log->Printf ("SBLineEntry::GetFileSpec (this.ap=%p) => SBFileSpec : this.ap = %p, '%s'", m_opaque_ap.get(), + log->Printf ("SBLineEntry(%p)::GetFileSpec () => SBFileSpec(%p): %s", m_opaque_ap.get(), sb_file_spec.get(), sstr.GetData()); } @@ -148,15 +135,12 @@ SBLineEntry::GetLine () const { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - //if (log) - // log->Printf ("SBLineEntry::GetLine ()"); - uint32_t line = 0; if (m_opaque_ap.get()) line = m_opaque_ap->line; if (log) - log->Printf ("SBLineEntry::GetLine (this.ap=%p) => %d", m_opaque_ap.get(), line); + log->Printf ("SBLineEntry(%p)::GetLine () => %u", m_opaque_ap.get(), line); return line; } @@ -211,14 +195,11 @@ SBLineEntry::GetDescription (SBStream &description) { if (m_opaque_ap.get()) { - // Line entry: File, line x {, column y}: Addresses: <start_addr> - <end_addr> char file_path[PATH_MAX*2]; m_opaque_ap->file.GetPath (file_path, sizeof (file_path)); - description.Printf ("Line entry: %s, line %d", file_path, GetLine()); + description.Printf ("%s:%u", file_path, GetLine()); if (GetColumn() > 0) - description.Printf (", column %d", GetColumn()); - description.Printf (": Addresses: 0x%p - 0x%p", GetStartAddress().GetFileAddress() , - GetEndAddress().GetFileAddress()); + description.Printf (":%u", GetColumn()); } else description.Printf ("No value"); diff --git a/lldb/source/API/SBListener.cpp b/lldb/source/API/SBListener.cpp index d291ac1cf3a..b6fbcf6dba7 100644 --- a/lldb/source/API/SBListener.cpp +++ b/lldb/source/API/SBListener.cpp @@ -7,15 +7,16 @@ // //===----------------------------------------------------------------------===// +#include "lldb/API/SBListener.h" +#include "lldb/API/SBBroadcaster.h" +#include "lldb/API/SBEvent.h" +#include "lldb/API/SBStream.h" +#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Listener.h" #include "lldb/Core/Log.h" -#include "lldb/lldb-forward-rtti.h" +#include "lldb/Core/StreamString.h" #include "lldb/Host/TimeValue.h" -#include "lldb/API/SBListener.h" -#include "lldb/API/SBEvent.h" -#include "lldb/API/SBBroadcaster.h" -#include "lldb/API/SBStream.h" using namespace lldb; using namespace lldb_private; @@ -34,7 +35,7 @@ SBListener::SBListener (const char *name) : Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBListener::SBListener (name='%s') => this.obj = %p", + log->Printf ("SBListener::SBListener (name=\"%s\") => SBListener(%p)", name, m_opaque_ptr); } @@ -42,11 +43,6 @@ SBListener::SBListener (Listener &listener) : m_opaque_ptr (&listener), m_opaque_ptr_owned (false) { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - if (log) - log->Printf ("SBListener::SBListener (listener=%p) => this.obj = %p", - &listener, m_opaque_ptr); } SBListener::~SBListener () @@ -87,18 +83,48 @@ SBListener::StartListeningForEvents (const SBBroadcaster& broadcaster, uint32_t { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - uint32_t aquired_event_mask = 0; + uint32_t acquired_event_mask = 0; if (m_opaque_ptr && broadcaster.IsValid()) { - aquired_event_mask = m_opaque_ptr->StartListeningForEvents (broadcaster.get(), event_mask); + acquired_event_mask = m_opaque_ptr->StartListeningForEvents (broadcaster.get(), event_mask); } log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBListener(%p)::StartListeneingForEvents (SBBroadcaster(%p), event_mask=0x%8.8x) => 0x%8.8x", - m_opaque_ptr, broadcaster.get(), event_mask, aquired_event_mask); + { + StreamString sstr_requested; + StreamString sstr_acquired; + + Broadcaster *lldb_broadcaster = broadcaster.get(); + if (lldb_broadcaster) + { + const bool got_requested_names = lldb_broadcaster->GetEventNames (sstr_requested, event_mask, false); + const bool got_acquired_names = lldb_broadcaster->GetEventNames (sstr_acquired, acquired_event_mask, false); + log->Printf ("SBListener(%p)::StartListeneingForEvents (SBBroadcaster(%p): %s, event_mask=0x%8.8x%s%s%s) => 0x%8.8x%s%s%s", + m_opaque_ptr, + lldb_broadcaster, + lldb_broadcaster->GetBroadcasterName().GetCString(), + event_mask, + got_requested_names ? " (" : "", + sstr_requested.GetData(), + got_requested_names ? ")" : "", + acquired_event_mask, + got_acquired_names ? " (" : "", + sstr_acquired.GetData(), + got_acquired_names ? ")" : ""); + } + else + { + log->Printf ("SBListener(%p)::StartListeneingForEvents (SBBroadcaster(%p), event_mask=0x%8.8x) => 0x%8.8x", + m_opaque_ptr, + lldb_broadcaster, + event_mask, + acquired_event_mask); + + } + } - return aquired_event_mask; + return acquired_event_mask; } bool @@ -112,44 +138,57 @@ SBListener::StopListeningForEvents (const SBBroadcaster& broadcaster, uint32_t e } bool -SBListener::WaitForEvent (uint32_t num_seconds, SBEvent &event) +SBListener::WaitForEvent (uint32_t timeout_secs, SBEvent &event) { - - //if (log) - //{ - // SBStream sstr; - // event.GetDescription (sstr); - // log->Printf ("SBListener::WaitForEvent (%d, %s)", num_seconds, sstr.GetData()); - //} + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + { + if (timeout_secs == UINT32_MAX) + { + log->Printf ("SBListener(%p)::WaitForEvent (timeout_secs=INFINITE, SBEvent(%p))...", + m_opaque_ptr, event.get()); + } + else + { + log->Printf ("SBListener(%p)::WaitForEvent (timeout_secs=%d, SBEvent(%p))...", + m_opaque_ptr, timeout_secs, event.get()); + } + } + bool success = false; if (m_opaque_ptr) { TimeValue time_value; - if (num_seconds != UINT32_MAX) + if (timeout_secs != UINT32_MAX) { - assert (num_seconds != 0); // Take this out after all calls with timeout set to zero have been removed.... + assert (timeout_secs != 0); // Take this out after all calls with timeout set to zero have been removed.... time_value = TimeValue::Now(); - time_value.OffsetWithSeconds (num_seconds); + time_value.OffsetWithSeconds (timeout_secs); } EventSP event_sp; if (m_opaque_ptr->WaitForEvent (time_value.IsValid() ? &time_value : NULL, event_sp)) { event.reset (event_sp); - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - if (log) - log->Printf ("SBListener(%p)::WaitForEvent (num_seconds=%d, SBEvent(%p)) => 1", - m_opaque_ptr, num_seconds, event.get()); - return true; + success = true; } } - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBListener(%p)::WaitForEvent (num_seconds=%d, SBEvent(%p)) => 0", - m_opaque_ptr, num_seconds, event.get()); - - event.reset (NULL); - return false; + { + if (timeout_secs == UINT32_MAX) + { + log->Printf ("SBListener(%p)::WaitForEvent (timeout_secs=INFINITE, SBEvent(%p)) => %i", + m_opaque_ptr, event.get(), success); + } + else + { + log->Printf ("SBListener(%p)::WaitForEvent (timeout_secs=%d, SBEvent(%p)) => %i", + m_opaque_ptr, timeout_secs, event.get(), success); + } + } + if (!success) + event.reset (NULL); + return success; } bool diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 55e691bb583..58ff07ddcb5 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -51,10 +51,8 @@ SBModule::GetFileSpec () const if (log) { - SBStream sstr; - file_spec.GetDescription (sstr); - log->Printf ("SBModule(%p)::GetFileSpec () => SBFileSpec(%p): %s", m_opaque_sp.get(), - file_spec.get(), sstr.GetData()); + log->Printf ("SBModule(%p)::GetFileSpec () => SBFileSpec(%p)", + m_opaque_sp.get(), file_spec.get()); } return file_spec; diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 23152aa43d5..9ea9f754abc 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -152,7 +152,7 @@ SBProcess::PutSTDIN (const char *src, size_t src_len) } if (log) - log->Printf ("SBProcess(%p)::PutSTDIN (src='%s', src_len=%d) => %d", + log->Printf ("SBProcess(%p)::PutSTDIN (src=\"%s\", src_len=%d) => %d", m_opaque_sp.get(), src, (uint32_t) src_len, @@ -164,47 +164,37 @@ SBProcess::PutSTDIN (const char *src, size_t src_len) size_t SBProcess::GetSTDOUT (char *dst, size_t dst_len) const { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - size_t ret_val = 0; + size_t bytes_read = 0; if (m_opaque_sp != NULL) { Error error; - ret_val = m_opaque_sp->GetSTDOUT (dst, dst_len, error); + bytes_read = m_opaque_sp->GetSTDOUT (dst, dst_len, error); } + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBProcess(%p)::GetSTDOUT (dst='%.*s', dst_len=%d) => %d", - m_opaque_sp.get(), - (uint32_t) dst_len, - dst, - (uint32_t) dst_len, - (uint32_t) ret_val); + log->Printf ("SBProcess(%p)::GetSTDOUT (dst=\"%.*s\", dst_len=%zu) => %zu", + m_opaque_sp.get(), (int) bytes_read, dst, dst_len, bytes_read); - return ret_val; + return bytes_read; } size_t SBProcess::GetSTDERR (char *dst, size_t dst_len) const { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - size_t ret_val = 0; + size_t bytes_read = 0; if (m_opaque_sp != NULL) { Error error; - ret_val = m_opaque_sp->GetSTDERR (dst, dst_len, error); + bytes_read = m_opaque_sp->GetSTDERR (dst, dst_len, error); } + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBProcess(%p)::GetSTDERR (dst='%.*s', dst_len=%d) => %d", - m_opaque_sp.get(), - (uint32_t) dst_len, - dst, - (uint32_t) dst_len, - (uint32_t) ret_val); + log->Printf ("SBProcess(%p)::GetSTDERR (dst=\"%.*s\", dst_len=%zu) => %zu", + m_opaque_sp.get(), (int) bytes_read, dst, dst_len, bytes_read); - return ret_val; + return bytes_read; } void @@ -263,7 +253,7 @@ SBProcess::SetSelectedThreadByID (uint32_t tid) ret_val = m_opaque_sp->GetThreadList().SetSelectedThreadByID (tid); if (log) - log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=%d) => '%s'", + log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%4.4x) => %s", m_opaque_sp.get(), tid, (ret_val ? "true" : "false")); return ret_val; @@ -297,7 +287,7 @@ SBProcess::GetState () Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) - log->Printf ("SBProcess(%p)::GetState () => '%s'", + log->Printf ("SBProcess(%p)::GetState () => %s", m_opaque_sp.get(), lldb_private::StateAsCString (ret_val)); @@ -557,7 +547,7 @@ SBProcess::GetStateFromEvent (const SBEvent &event) StateType ret_val = Process::ProcessEventData::GetStateFromEvent (event.get()); if (log) - log->Printf ("SBProcess::GetStateFromEvent (event.sp=%p) => '%s'", event.get(), + log->Printf ("SBProcess::GetStateFromEvent (event.sp=%p) => %s", event.get(), lldb_private::StateAsCString (ret_val)); return ret_val; diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp index 3b0b5fc0e61..9d97f545d9a 100644 --- a/lldb/source/API/SBSymbolContext.cpp +++ b/lldb/source/API/SBSymbolContext.cpp @@ -9,8 +9,10 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/API/SBStream.h" -#include "lldb/Symbol/SymbolContext.h" #include "lldb/Core/Log.h" +#include "lldb/Symbol/Function.h" +#include "lldb/Symbol/Symbol.h" +#include "lldb/Symbol/SymbolContext.h" using namespace lldb; using namespace lldb_private; @@ -112,13 +114,18 @@ SBSymbolContext::GetFunction () { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - SBFunction ret_function (m_opaque_ap.get() ? m_opaque_ap->function : NULL); + Function *function = NULL; + + if (m_opaque_ap.get()) + function = m_opaque_ap->function; + + SBFunction sb_function (function); if (log) - log->Printf ("SBSymbolContext(%p)::GetFunction () => SBFunction(%p): %s", - m_opaque_ap.get(), ret_function.get(), ret_function.GetName()); + log->Printf ("SBSymbolContext(%p)::GetFunction () => SBFunction(%p)", + m_opaque_ap.get(), function); - return ret_function; + return sb_function; } SBBlock @@ -138,11 +145,8 @@ SBSymbolContext::GetLineEntry () if (log) { - SBStream sstr; - sb_line_entry.GetDescription (sstr); - log->Printf ("SBSymbolContext(%p)::GetLineEntry () => SBLineEntry(%p): %s", - m_opaque_ap.get(), - sb_line_entry.get(), sstr.GetData()); + log->Printf ("SBSymbolContext(%p)::GetLineEntry () => SBLineEntry(%p)", + m_opaque_ap.get(), sb_line_entry.get()); } return sb_line_entry; @@ -153,17 +157,20 @@ SBSymbolContext::GetSymbol () { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - SBSymbol ret_symbol (m_opaque_ap.get() ? m_opaque_ap->symbol : NULL); + Symbol *symbol = NULL; + + if (m_opaque_ap.get()) + symbol = m_opaque_ap->symbol; + + SBSymbol sb_symbol (symbol); if (log) { - SBStream sstr; - ret_symbol.GetDescription (sstr); - log->Printf ("SBSymbolContext(%p)::GetSymbol () => SBSymbol(%p): %s", m_opaque_ap.get(), - ret_symbol.get(), sstr.GetData()); + log->Printf ("SBSymbolContext(%p)::GetSymbol () => SBSymbol(%p)", + m_opaque_ap.get(), symbol); } - return ret_symbol; + return sb_symbol; } lldb_private::SymbolContext* diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index d31ad562ddb..72aef3fd2fe 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -57,29 +57,11 @@ SBTarget::SBTarget () SBTarget::SBTarget (const SBTarget& rhs) : m_opaque_sp (rhs.m_opaque_sp) { -// Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); -// -// if (log) -// { -// SBStream sstr; -// GetDescription (sstr, lldb::eDescriptionLevelBrief); -// log->Printf ("SBTarget::SBTarget (rhs.sp=%p) => SBTarget(%p): %s", -// rhs.m_opaque_sp.get(), m_opaque_sp.get(), sstr.GetData()); -// } } SBTarget::SBTarget(const TargetSP& target_sp) : m_opaque_sp (target_sp) { -// Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); -// -// if (log) -// { -// SBStream sstr; -// GetDescription (sstr, lldb::eDescriptionLevelBrief); -// log->Printf ("SBTarget::SBTarget (target_sp=%p) => SBTarget(%p): %s", -// target_sp.get(), m_opaque_sp.get(), sstr.GetData()); -// } } //---------------------------------------------------------------------- @@ -106,10 +88,8 @@ SBTarget::GetProcess () Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) { - SBStream sstr; - sb_process.GetDescription (sstr); - log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p): %s", m_opaque_sp.get(), - sb_process.get(), sstr.GetData()); + log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p)", + m_opaque_sp.get(), sb_process.get()); } return sb_process; @@ -138,10 +118,8 @@ SBTarget::CreateProcess () Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) { - SBStream sstr; - sb_process.GetDescription (sstr); - log->Printf ("SBTarget(%p)::CreateProcess () => SBProcess(%p): %s", m_opaque_sp.get(), - sb_process.get(), sstr.GetData()); + log->Printf ("SBTarget(%p)::CreateProcess () => SBProcess(%p)", + m_opaque_sp.get(), sb_process.get()); } return sb_process; @@ -170,10 +148,8 @@ SBTarget::LaunchProcess log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) { - SBStream sstr; - sb_process.GetDescription (sstr); - log->Printf ("SBTarget(%p)::LaunchProcess (...) => SBProcess(%p): %s", - m_opaque_sp.get(), sb_process.get(), sstr.GetData()); + log->Printf ("SBTarget(%p)::LaunchProcess (...) => SBProcess(%p)", + m_opaque_sp.get(), sb_process.get()); } return sb_process; @@ -250,10 +226,8 @@ SBTarget::Launch log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) { - SBStream sstr; - sb_process.GetDescription (sstr); - log->Printf ("SBTarget(%p)::Launch (...) => SBProceess(%p): %s", - m_opaque_sp.get(), sb_process.get(), sstr.GetData()); + log->Printf ("SBTarget(%p)::Launch (...) => SBProceess(%p)", + m_opaque_sp.get(), sb_process.get()); } return sb_process; @@ -342,7 +316,6 @@ SBTarget::AttachToProcessWithName SBFileSpec SBTarget::GetExecutable () { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); SBFileSpec exe_file_spec; if (m_opaque_sp) @@ -352,18 +325,11 @@ SBTarget::GetExecutable () exe_file_spec.SetFileSpec (exe_module_sp->GetFileSpec()); } + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) { - if (exe_file_spec.Exists()) - { - SBStream sstr; - exe_file_spec.GetDescription (sstr); - log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p): %s", m_opaque_sp.get(), - exe_file_spec.get(), sstr.GetData()); - } - else - log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec (%p): Unable to find valid file", - m_opaque_sp.get(), exe_file_spec.get()); + log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)", + m_opaque_sp.get(), exe_file_spec.get()); } return exe_file_spec; @@ -428,13 +394,13 @@ SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t l { SBStream sstr; sb_bp.GetDescription (sstr); - const char *dir = sb_file_spec.GetDirectory(); - const char *file = sb_file_spec.GetFilename(); - log->Printf ("SBTarget(%p)::BreakpointCreateByLocation ( %s%s%s:%u ) => SBBreakpoint(%p): %s", + char path[PATH_MAX]; + sb_file_spec->GetPath (path, sizeof(path)); + log->Printf ("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => SBBreakpoint(%p): %s", m_opaque_sp.get(), - dir ? dir : "", dir ? "/" : "", file ? file : "", + path, line, - sb_bp.get(), + sb_bp.get(), sstr.GetData()); } @@ -462,11 +428,8 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_na if (log) { - SBStream sstr; - sb_bp.GetDescription (sstr); - log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", module=\"%s\") => " - "SBBreakpoint(%p): %s", m_opaque_sp.get(), symbol_name, module_name, sb_bp.get(), - sstr.GetData()); + log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", module=\"%s\") => SBBreakpoint(%p)", + m_opaque_sp.get(), symbol_name, module_name, sb_bp.get()); } return sb_bp; @@ -496,11 +459,8 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *mo if (log) { - SBStream sstr; - sb_bp.GetDescription (sstr); - log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\", module_name=\"%s\") " - "=> SBBreakpoint(%p): %s", m_opaque_sp.get(), symbol_name_regex, module_name, - sb_bp.get(), sstr.GetData()); + log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)", + m_opaque_sp.get(), symbol_name_regex, module_name, sb_bp.get()); } return sb_bp; @@ -519,10 +479,7 @@ SBTarget::BreakpointCreateByAddress (addr_t address) if (log) { - SBStream sstr; - sb_bp.GetDescription (sstr); - log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (%p, address=%p) => " - "SBBreakpoint(%p): %s", m_opaque_sp.get(), address, sb_bp.get(), sstr.GetData()); + log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (%p, address=%p) => SBBreakpoint(%p)", m_opaque_sp.get(), address, sb_bp.get()); } return sb_bp; @@ -539,10 +496,8 @@ SBTarget::FindBreakpointByID (break_id_t bp_id) if (log) { - SBStream sstr; - sb_breakpoint.GetDescription (sstr); - log->Printf ("SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p): %s", - m_opaque_sp.get(), (uint32_t) bp_id, sb_breakpoint.get(), sstr.GetData()); + log->Printf ("SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)", + m_opaque_sp.get(), (uint32_t) bp_id, sb_breakpoint.get()); } return sb_breakpoint; @@ -663,10 +618,8 @@ SBTarget::GetModuleAtIndex (uint32_t idx) if (log) { - SBStream sstr; - sb_module.GetDescription (sstr); - log->Printf ("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p): %s", - m_opaque_sp.get(), idx, sb_module.get(), sstr.GetData()); + log->Printf ("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)", + m_opaque_sp.get(), idx, sb_module.get()); } return sb_module; diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index fc13631b137..ca356244d78 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -38,14 +38,14 @@ using namespace lldb; using namespace lldb_private; +//---------------------------------------------------------------------- +// Constructors +//---------------------------------------------------------------------- SBThread::SBThread () : m_opaque_sp () { } -//---------------------------------------------------------------------- -// Thread constructor -//---------------------------------------------------------------------- SBThread::SBThread (const ThreadSP& lldb_object_sp) : m_opaque_sp (lldb_object_sp) { @@ -57,6 +57,18 @@ SBThread::SBThread (const SBThread &rhs) : } //---------------------------------------------------------------------- +// Assignment operator +//---------------------------------------------------------------------- + +const lldb::SBThread & +SBThread::operator = (const SBThread &rhs) +{ + if (this != &rhs) + m_opaque_sp = rhs.m_opaque_sp; + return *this; +} + +//---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- SBThread::~SBThread() @@ -490,14 +502,6 @@ SBThread::GetFrameAtIndex (uint32_t idx) return sb_frame; } -const lldb::SBThread & -SBThread::operator = (const SBThread &rhs) -{ - if (this != &rhs) - m_opaque_sp = rhs.m_opaque_sp; - return *this; -} - bool SBThread::operator == (const SBThread &rhs) const { diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index e5476ff277c..54f822ee574 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -42,14 +42,6 @@ SBValue::SBValue () : SBValue::SBValue (const lldb::ValueObjectSP &value_sp) : m_opaque_sp (value_sp) { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - - if (log) - { - SBStream sstr; - GetDescription (sstr); - log->Printf ("SBValue::SBValue (%p) => (%s)", m_opaque_sp.get(), sstr.GetData()); - } } SBValue::~SBValue() @@ -59,7 +51,10 @@ SBValue::~SBValue() bool SBValue::IsValid () const { - return (m_opaque_sp.get() != NULL); + // If this function ever changes to anything that does more than just + // check if the opaque shared pointer is non NULL, then we need to update + // all "if (m_opaque_sp)" code in this file. + return m_opaque_sp.get() != NULL; } SBError @@ -76,26 +71,39 @@ SBValue::GetError() const char * SBValue::GetName() { - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); - if (log) - log->Printf ("SBValue::GetName () ptr=%p => '%s'", - m_opaque_sp.get(), - m_opaque_sp ? m_opaque_sp->GetName().AsCString() : "<invalid>"); + const char *name = NULL; + if (m_opaque_sp) + name = m_opaque_sp->GetName().GetCString(); - if (IsValid()) - return m_opaque_sp->GetName().GetCString(); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + { + if (name) + log->Printf ("SBValue(%p)::GetName () => \"%s\"", m_opaque_sp.get(), name); + else + log->Printf ("SBValue(%p)::GetName () => NULL", m_opaque_sp.get(), name); + } - return NULL; + return name; } const char * SBValue::GetTypeName () { - if (IsValid()) - return m_opaque_sp->GetTypeName().AsCString(); - else - return NULL; + const char *name = NULL; + if (m_opaque_sp) + name = m_opaque_sp->GetTypeName().GetCString(); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + { + if (name) + log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"", m_opaque_sp.get(), name); + else + log->Printf ("SBValue(%p)::GetTypeName () => NULL", m_opaque_sp.get()); + } + + return name; } size_t @@ -103,9 +111,13 @@ SBValue::GetByteSize () { size_t result = 0; - if (IsValid()) + if (m_opaque_sp) result = m_opaque_sp->GetByteSize(); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + log->Printf ("SBValue(%p)::GetByteSize () => %zu", m_opaque_sp.get(), result); + return result; } @@ -114,69 +126,128 @@ SBValue::IsInScope (const SBFrame &frame) { bool result = false; - if (IsValid()) + if (m_opaque_sp) result = m_opaque_sp->IsInScope (frame.get()); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + log->Printf ("SBValue(%p)::IsInScope () => %i", m_opaque_sp.get(), result); + return result; } const char * SBValue::GetValue (const SBFrame &frame) { - const char *value_string = NULL; + const char *cstr = NULL; if ( m_opaque_sp) - value_string = m_opaque_sp->GetValueAsCString (frame.get()); - return value_string; + cstr = m_opaque_sp->GetValueAsCString (frame.get()); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + { + if (cstr) + log->Printf ("SBValue(%p)::GetValue (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), frame.get(), cstr); + else + log->Printf ("SBValue(%p)::GetValue (SBFrame(%p)) => NULL", m_opaque_sp.get(), frame.get()); + } + + return cstr; } ValueType SBValue::GetValueType () { + ValueType result = eValueTypeInvalid; if (m_opaque_sp) - return m_opaque_sp->GetValueType(); - return eValueTypeInvalid; + result = m_opaque_sp->GetValueType(); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + { + switch (result) + { + case eValueTypeInvalid: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeInvalid", m_opaque_sp.get()); break; + case eValueTypeVariableGlobal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal", m_opaque_sp.get()); break; + case eValueTypeVariableStatic: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableStatic", m_opaque_sp.get()); break; + case eValueTypeVariableArgument:log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableArgument", m_opaque_sp.get()); break; + case eValueTypeVariableLocal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableLocal", m_opaque_sp.get()); break; + case eValueTypeRegister: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegister", m_opaque_sp.get()); break; + case eValueTypeRegisterSet: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegisterSet", m_opaque_sp.get()); break; + case eValueTypeConstResult: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeConstResult", m_opaque_sp.get()); break; + default: log->Printf ("SBValue(%p)::GetValueType () => %i ???", m_opaque_sp.get(), result); break; + } + } + return result; } const char * SBValue::GetObjectDescription (const SBFrame &frame) { - const char *value_string = NULL; + const char *cstr = NULL; if ( m_opaque_sp) - value_string = m_opaque_sp->GetObjectDescription (frame.get()); - return value_string; + cstr = m_opaque_sp->GetObjectDescription (frame.get()); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + { + if (cstr) + log->Printf ("SBValue(%p)::GetObjectDescription (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), frame.get(), cstr); + else + log->Printf ("SBValue(%p)::GetObjectDescription (SBFrame(%p)) => NULL", m_opaque_sp.get(), frame.get()); + } + return cstr; } bool SBValue::GetValueDidChange (const SBFrame &frame) { - if (IsValid()) - return m_opaque_sp->GetValueDidChange (frame.get()); - return false; + bool result = false; + if (m_opaque_sp) + result = m_opaque_sp->GetValueDidChange (frame.get()); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + log->Printf ("SBValue(%p)::GetValueDidChange (SBFrame(%p)) => %i", m_opaque_sp.get(), frame.get(), result); + + return result; } const char * SBValue::GetSummary (const SBFrame &frame) { - const char *value_string = NULL; - if ( m_opaque_sp) - value_string = m_opaque_sp->GetSummaryAsCString(frame.get()); - return value_string; + const char *cstr = NULL; + if (m_opaque_sp) + cstr = m_opaque_sp->GetSummaryAsCString(frame.get()); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + { + if (cstr) + log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), frame.get(), cstr); + else + log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => NULL", m_opaque_sp.get(), frame.get()); + } + return cstr; } const char * SBValue::GetLocation (const SBFrame &frame) { - const char *value_string = NULL; - if (IsValid()) - value_string = m_opaque_sp->GetLocationAsCString(frame.get()); - return value_string; + const char *cstr = NULL; + if (m_opaque_sp) + cstr = m_opaque_sp->GetLocationAsCString(frame.get()); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + { + if (cstr) + log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), frame.get(), cstr); + else + log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => NULL", m_opaque_sp.get(), frame.get()); + } + return cstr; } bool SBValue::SetValueFromCString (const SBFrame &frame, const char *value_str) { bool success = false; - if (IsValid()) + if (m_opaque_sp) success = m_opaque_sp->SetValueFromCString (frame.get(), value_str); return success; } @@ -186,21 +257,34 @@ SBValue::GetChildAtIndex (uint32_t idx) { lldb::ValueObjectSP child_sp; - if (IsValid()) + if (m_opaque_sp) { child_sp = m_opaque_sp->GetChildAtIndex (idx, true); } SBValue sb_value (child_sp); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)", m_opaque_sp.get(), idx, sb_value.get()); + return sb_value; } uint32_t SBValue::GetIndexOfChildWithName (const char *name) { - if (IsValid()) - return m_opaque_sp->GetIndexOfChildWithName (ConstString(name)); - return UINT32_MAX; + uint32_t idx = UINT32_MAX; + if (m_opaque_sp) + idx = m_opaque_sp->GetIndexOfChildWithName (ConstString(name)); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + { + if (idx == UINT32_MAX) + log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND", m_opaque_sp.get(), name, idx); + else + log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u", m_opaque_sp.get(), name, idx); + } + return idx; } SBValue @@ -209,12 +293,17 @@ SBValue::GetChildMemberWithName (const char *name) lldb::ValueObjectSP child_sp; const ConstString str_name (name); - if (IsValid()) + if (m_opaque_sp) { child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true); } SBValue sb_value (child_sp); + + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)", m_opaque_sp.get(), name, sb_value.get()); + return sb_value; } @@ -224,10 +313,12 @@ SBValue::GetNumChildren () { uint32_t num_children = 0; - if (IsValid()) - { + if (m_opaque_sp) num_children = m_opaque_sp->GetNumChildren(); - } + + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + log->Printf ("SBValue(%p)::GetNumChildren () => %u", m_opaque_sp.get(), num_children); return num_children; } @@ -237,10 +328,8 @@ SBValue::ValueIsStale () { bool result = true; - if (IsValid()) - { + if (m_opaque_sp) result = m_opaque_sp->GetValueIsValid(); - } return result; } @@ -249,25 +338,31 @@ SBValue::ValueIsStale () SBValue SBValue::Dereference () { - if (IsValid()) + SBValue sb_value; + if (m_opaque_sp) { if (m_opaque_sp->IsPointerType()) - { - return GetChildAtIndex(0); - } + sb_value = GetChildAtIndex(0); } - return *this; + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)", m_opaque_sp.get(), sb_value.get()); + + return sb_value; } bool -SBValue::TypeIsPtrType () +SBValue::TypeIsPointerType () { bool is_ptr_type = false; - if (IsValid()) - { + if (m_opaque_sp) is_ptr_type = m_opaque_sp->IsPointerType(); - } + + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); + if (log) + log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", m_opaque_sp.get(), is_ptr_type); + return is_ptr_type; } @@ -306,6 +401,17 @@ SBValue::operator*() const } bool +SBValue::GetExpressionPath (SBStream &description) +{ + if (m_opaque_sp) + { + m_opaque_sp->GetExpressionPath (description.ref()); + return true; + } + return false; +} + +bool SBValue::GetDescription (SBStream &description) { if (m_opaque_sp) |