summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/API/SBAddress.cpp2
-rw-r--r--lldb/source/API/SBBlock.cpp125
-rw-r--r--lldb/source/API/SBFrame.cpp8
-rw-r--r--lldb/source/API/SBFunction.cpp23
-rw-r--r--lldb/source/API/SBModule.cpp24
-rw-r--r--lldb/source/API/SBSymbolContext.cpp2
-rw-r--r--lldb/source/API/SBSymbolContextList.cpp24
-rw-r--r--lldb/source/API/SBTarget.cpp23
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp26
-rw-r--r--lldb/source/Symbol/SymbolContext.cpp32
-rw-r--r--lldb/source/Symbol/Type.cpp15
11 files changed, 256 insertions, 48 deletions
diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp
index 7397588eaf4..7d7d1d7789e 100644
--- a/lldb/source/API/SBAddress.cpp
+++ b/lldb/source/API/SBAddress.cpp
@@ -352,7 +352,7 @@ SBAddress::GetBlock ()
{
SBBlock sb_block;
if (m_opaque_ap.get())
- sb_block.reset(m_opaque_ap->GetAddress().CalculateSymbolContextBlock());
+ sb_block.SetPtr(m_opaque_ap->GetAddress().CalculateSymbolContextBlock());
return sb_block;
}
diff --git a/lldb/source/API/SBBlock.cpp b/lldb/source/API/SBBlock.cpp
index eeae1d3b02b..8f325f472bc 100644
--- a/lldb/source/API/SBBlock.cpp
+++ b/lldb/source/API/SBBlock.cpp
@@ -10,11 +10,18 @@
#include "lldb/API/SBBlock.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBFrame.h"
#include "lldb/API/SBStream.h"
+#include "lldb/API/SBValue.h"
#include "lldb/Core/AddressRange.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
@@ -157,13 +164,13 @@ SBBlock::GetFirstChild ()
}
lldb_private::Block *
-SBBlock::get ()
+SBBlock::GetPtr ()
{
return m_opaque_ptr;
}
void
-SBBlock::reset (lldb_private::Block *block)
+SBBlock::SetPtr (lldb_private::Block *block)
{
m_opaque_ptr = block;
}
@@ -245,3 +252,117 @@ SBBlock::GetRangeIndexForBlockAddress (lldb::SBAddress block_addr)
return UINT32_MAX;
}
+
+lldb::SBValueList
+SBBlock::GetVariables (lldb::SBFrame& frame,
+ bool arguments,
+ bool locals,
+ bool statics,
+ lldb::DynamicValueType use_dynamic)
+{
+ Block *block = GetPtr();
+ SBValueList value_list;
+ if (block)
+ {
+ StackFrameSP frame_sp(frame.GetFrameSP());
+ VariableListSP variable_list_sp (block->GetBlockVariableList (true));
+
+ if (variable_list_sp)
+ {
+ const size_t num_variables = variable_list_sp->GetSize();
+ if (num_variables)
+ {
+ for (size_t i = 0; i < num_variables; ++i)
+ {
+ VariableSP variable_sp (variable_list_sp->GetVariableAtIndex(i));
+ if (variable_sp)
+ {
+ bool add_variable = false;
+ switch (variable_sp->GetScope())
+ {
+ case eValueTypeVariableGlobal:
+ case eValueTypeVariableStatic:
+ add_variable = statics;
+ break;
+
+ case eValueTypeVariableArgument:
+ add_variable = arguments;
+ break;
+
+ case eValueTypeVariableLocal:
+ add_variable = locals;
+ break;
+
+ default:
+ break;
+ }
+ if (add_variable)
+ {
+ if (frame_sp)
+ value_list.Append (frame_sp->GetValueObjectForFrameVariable (variable_sp, use_dynamic));
+ }
+ }
+ }
+ }
+ }
+ }
+ return value_list;
+}
+
+lldb::SBValueList
+SBBlock::GetVariables (lldb::SBTarget& target,
+ bool arguments,
+ bool locals,
+ bool statics)
+{
+ Block *block = GetPtr();
+
+ SBValueList value_list;
+ if (block)
+ {
+ TargetSP target_sp(target.GetSP());
+
+ VariableListSP variable_list_sp (block->GetBlockVariableList (true));
+
+ if (variable_list_sp)
+ {
+ const size_t num_variables = variable_list_sp->GetSize();
+ if (num_variables)
+ {
+ for (size_t i = 0; i < num_variables; ++i)
+ {
+ VariableSP variable_sp (variable_list_sp->GetVariableAtIndex(i));
+ if (variable_sp)
+ {
+ bool add_variable = false;
+ switch (variable_sp->GetScope())
+ {
+ case eValueTypeVariableGlobal:
+ case eValueTypeVariableStatic:
+ add_variable = statics;
+ break;
+
+ case eValueTypeVariableArgument:
+ add_variable = arguments;
+ break;
+
+ case eValueTypeVariableLocal:
+ add_variable = locals;
+ break;
+
+ default:
+ break;
+ }
+ if (add_variable)
+ {
+ if (target_sp)
+ value_list.Append (ValueObjectVariable::Create (target_sp.get(), variable_sp));
+ }
+ }
+ }
+ }
+ }
+ }
+ return value_list;
+}
+
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index ce57c83520d..fb9957106a1 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -300,12 +300,12 @@ SBFrame::GetBlock () const
if (frame_sp)
{
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
- sb_block.reset (frame_sp->GetSymbolContext (eSymbolContextBlock).block);
+ sb_block.SetPtr (frame_sp->GetSymbolContext (eSymbolContextBlock).block);
}
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)",
- frame_sp.get(), sb_block.get());
+ frame_sp.get(), sb_block.GetPtr());
return sb_block;
}
@@ -317,12 +317,12 @@ SBFrame::GetFrameBlock () const
if (frame_sp)
{
Mutex::Locker api_locker (frame_sp->GetThread().GetProcess().GetTarget().GetAPIMutex());
- sb_block.reset(frame_sp->GetFrameBlock ());
+ sb_block.SetPtr(frame_sp->GetFrameBlock ());
}
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (log)
log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)",
- frame_sp.get(), sb_block.get());
+ frame_sp.get(), sb_block.GetPtr());
return sb_block;
}
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index e3e56a53011..cf80cbf333d 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -192,4 +192,27 @@ SBFunction::GetPrologueByteSize ()
return 0;
}
+SBType
+SBFunction::GetType ()
+{
+ SBType sb_type;
+ if (m_opaque_ptr)
+ {
+ Type *function_type = m_opaque_ptr->GetType();
+ if (function_type)
+ sb_type.ref().SetType (function_type->shared_from_this());
+ }
+ return sb_type;
+}
+
+SBBlock
+SBFunction::GetBlock ()
+{
+ SBBlock sb_block;
+ if (m_opaque_ptr)
+ sb_block.SetPtr (&m_opaque_ptr->GetBlock (true));
+ return sb_block;
+}
+
+
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index d2ef05fde31..1fe51222ac9 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -318,25 +318,23 @@ SBModule::GetSectionAtIndex (size_t idx)
return sb_section;
}
-uint32_t
+lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
- uint32_t name_type_mask,
- bool append,
- lldb::SBSymbolContextList& sc_list)
+ uint32_t name_type_mask)
{
- if (!append)
- sc_list.Clear();
+ lldb::SBSymbolContextList sb_sc_list;
if (name && m_opaque_sp)
{
+ const bool append = true;
const bool symbols_ok = true;
- return m_opaque_sp->FindFunctions (ConstString(name),
- NULL,
- name_type_mask,
- symbols_ok,
- append,
- *sc_list);
+ m_opaque_sp->FindFunctions (ConstString(name),
+ NULL,
+ name_type_mask,
+ symbols_ok,
+ append,
+ *sb_sc_list);
}
- return 0;
+ return sb_sc_list;
}
diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp
index 0f7ce8cf0ac..a310d25565c 100644
--- a/lldb/source/API/SBSymbolContext.cpp
+++ b/lldb/source/API/SBSymbolContext.cpp
@@ -199,7 +199,7 @@ SBSymbolContext::SetFunction (lldb::SBFunction function)
void
SBSymbolContext::SetBlock (lldb::SBBlock block)
{
- ref().block = block.get();
+ ref().block = block.GetPtr();
}
void
diff --git a/lldb/source/API/SBSymbolContextList.cpp b/lldb/source/API/SBSymbolContextList.cpp
index ca6c80ca999..0730096c5f3 100644
--- a/lldb/source/API/SBSymbolContextList.cpp
+++ b/lldb/source/API/SBSymbolContextList.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/API/SBSymbolContextList.h"
+#include "lldb/API/SBStream.h"
#include "lldb/Symbol/SymbolContext.h"
using namespace lldb;
@@ -67,6 +68,20 @@ SBSymbolContextList::Clear()
m_opaque_ap->Clear();
}
+void
+SBSymbolContextList::Append(SBSymbolContext &sc)
+{
+ if (sc.IsValid() && m_opaque_ap.get())
+ m_opaque_ap->Append(*sc);
+}
+
+void
+SBSymbolContextList::Append(SBSymbolContextList &sc_list)
+{
+ if (sc_list.IsValid() && m_opaque_ap.get())
+ m_opaque_ap->Append(*sc_list);
+}
+
bool
SBSymbolContextList::IsValid () const
@@ -90,6 +105,13 @@ SBSymbolContextList::operator*() const
return *m_opaque_ap.get();
}
-
+bool
+SBSymbolContextList::GetDescription (lldb::SBStream &description)
+{
+ Stream &strm = description.ref();
+ if (m_opaque_ap.get())
+ m_opaque_ap->GetDescription (&strm, lldb::eDescriptionLevelFull, NULL);
+ return true;
+}
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index ed667cc52ea..5988887c551 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1252,28 +1252,25 @@ SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel descript
return true;
}
-uint32_t
-SBTarget::FindFunctions (const char *name,
- uint32_t name_type_mask,
- bool append,
- lldb::SBSymbolContextList& sc_list)
+lldb::SBSymbolContextList
+SBTarget::FindFunctions (const char *name, uint32_t name_type_mask)
{
- if (!append)
- sc_list.Clear();
+ lldb::SBSymbolContextList sb_sc_list;
if (name && name[0])
{
TargetSP target_sp(GetSP());
if (target_sp)
{
const bool symbols_ok = true;
- return target_sp->GetImages().FindFunctions (ConstString(name),
- name_type_mask,
- symbols_ok,
- append,
- *sc_list);
+ const bool append = true;
+ target_sp->GetImages().FindFunctions (ConstString(name),
+ name_type_mask,
+ symbols_ok,
+ append,
+ *sb_sc_list);
}
}
- return 0;
+ return sb_sc_list;
}
lldb::SBType
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 9c709bebd6b..55d90aae68a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -4158,21 +4158,21 @@ SymbolFileDWARF::DIEDeclContextsMatch (DWARFCompileUnit* cu1, const DWARFDebugIn
const char *name2 = decl_ctx_die2->GetName(this, cu2);
// If the string was from a DW_FORM_strp, then the pointer will often
// be the same!
- if (name1 != name2)
+ if (name1 == name2)
+ continue;
+
+ // Name pointers are not equal, so only compare the strings
+ // if both are not NULL.
+ if (name1 && name2)
{
- // Name pointers are not equal, so only compare the strings
- // if both are not NULL.
- if (name1 && name2)
- {
- // If the strings don't compare, we are done...
- if (strcmp(name1, name2) != 0)
- return false;
- }
- else if (name1 || name2)
- {
- // One name was NULL while the other wasn't
+ // If the strings don't compare, we are done...
+ if (strcmp(name1, name2) != 0)
return false;
- }
+ }
+ else
+ {
+ // One name was NULL while the other wasn't
+ return false;
}
}
// We made it through all of the checks and the declaration contexts
diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp
index 141ad680690..6be75a27b36 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -905,6 +905,28 @@ SymbolContextList::Append(const SymbolContext& sc)
m_symbol_contexts.push_back(sc);
}
+void
+SymbolContextList::Append (const SymbolContextList& sc_list)
+{
+ collection::const_iterator pos, end = sc_list.m_symbol_contexts.end();
+ for (pos = sc_list.m_symbol_contexts.begin(); pos != end; ++pos)
+ m_symbol_contexts.push_back (*pos);
+}
+
+
+uint32_t
+SymbolContextList::AppendIfUnique (const SymbolContextList& sc_list, bool merge_symbol_into_function)
+{
+ uint32_t unique_sc_add_count = 0;
+ collection::const_iterator pos, end = sc_list.m_symbol_contexts.end();
+ for (pos = sc_list.m_symbol_contexts.begin(); pos != end; ++pos)
+ {
+ if (AppendIfUnique (*pos, merge_symbol_into_function))
+ ++unique_sc_add_count;
+ }
+ return unique_sc_add_count;
+}
+
bool
SymbolContextList::AppendIfUnique (const SymbolContext& sc, bool merge_symbol_into_function)
{
@@ -1013,6 +1035,16 @@ SymbolContextList::NumLineEntriesWithLine (uint32_t line) const
return match_count;
}
+void
+SymbolContextList::GetDescription(Stream *s,
+ lldb::DescriptionLevel level,
+ Target *target) const
+{
+ const uint32_t size = m_symbol_contexts.size();
+ for (uint32_t idx = 0; idx<size; ++idx)
+ m_symbol_contexts[idx].GetDescription (s, level, target);
+}
+
bool
lldb_private::operator== (const SymbolContextList& lhs, const SymbolContextList& rhs)
{
diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp
index 66a13e2f38a..0844a9ecc6c 100644
--- a/lldb/source/Symbol/Type.cpp
+++ b/lldb/source/Symbol/Type.cpp
@@ -770,6 +770,21 @@ TypeImpl::TypeImpl(const lldb::TypeSP& type) :
{
}
+void
+TypeImpl::SetType (const lldb::TypeSP &type_sp)
+{
+ if (type_sp)
+ {
+ m_clang_ast_type.SetClangType (type_sp->GetClangAST(), type_sp->GetClangFullType());
+ m_type_sp = type_sp;
+ }
+ else
+ {
+ m_clang_ast_type.Clear();
+ m_type_sp.reset();
+ }
+}
+
TypeImpl&
TypeImpl::operator = (const TypeImpl& rhs)
{
OpenPOWER on IntegriCloud