diff options
author | Greg Clayton <gclayton@apple.com> | 2012-02-06 01:44:54 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-02-06 01:44:54 +0000 |
commit | 5569e64ea7853aa6ef08dbfbe847647e35ee94fa (patch) | |
tree | 9341331c9c0e5bc00e038615853fc9a8c7c39d7d /lldb/source | |
parent | 746c62bf88a05a0fee011cc24da7b0ddebd1bdbf (diff) | |
download | bcm5719-llvm-5569e64ea7853aa6ef08dbfbe847647e35ee94fa.tar.gz bcm5719-llvm-5569e64ea7853aa6ef08dbfbe847647e35ee94fa.zip |
Removed all of the "#ifndef SWIG" from the SB header files since we are using
interface (.i) files for each class.
Changed the FindFunction class from:
uint32_t
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
uint32_t
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask,
bool append,
lldb::SBSymbolContextList& sc_list)
To:
lldb::SBSymbolContextList
SBTarget::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
lldb::SBSymbolContextList
SBModule::FindFunctions (const char *name,
uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
This makes the API easier to use from python. Also added the ability to
append a SBSymbolContext or a SBSymbolContextList to a SBSymbolContextList.
Exposed properties for lldb.SBSymbolContextList in python:
lldb.SBSymbolContextList.modules => list() or all lldb.SBModule objects in the list
lldb.SBSymbolContextList.compile_units => list() or all lldb.SBCompileUnits objects in the list
lldb.SBSymbolContextList.functions => list() or all lldb.SBFunction objects in the list
lldb.SBSymbolContextList.blocks => list() or all lldb.SBBlock objects in the list
lldb.SBSymbolContextList.line_entries => list() or all lldb.SBLineEntry objects in the list
lldb.SBSymbolContextList.symbols => list() or all lldb.SBSymbol objects in the list
This allows a call to the SBTarget::FindFunctions(...) and SBModule::FindFunctions(...)
and then the result can be used to extract the desired information:
sc_list = lldb.target.FindFunctions("erase")
for function in sc_list.functions:
print function
for symbol in sc_list.symbols:
print symbol
Exposed properties for the lldb.SBSymbolContext objects in python:
lldb.SBSymbolContext.module => lldb.SBModule
lldb.SBSymbolContext.compile_unit => lldb.SBCompileUnit
lldb.SBSymbolContext.function => lldb.SBFunction
lldb.SBSymbolContext.block => lldb.SBBlock
lldb.SBSymbolContext.line_entry => lldb.SBLineEntry
lldb.SBSymbolContext.symbol => lldb.SBSymbol
Exposed properties for the lldb.SBBlock objects in python:
lldb.SBBlock.parent => lldb.SBBlock for the parent block that contains
lldb.SBBlock.sibling => lldb.SBBlock for the sibling block to the current block
lldb.SBBlock.first_child => lldb.SBBlock for the first child block to the current block
lldb.SBBlock.call_site => for inline functions, return a lldb.declaration object that gives the call site file, line and column
lldb.SBBlock.name => for inline functions this is the name of the inline function that this block represents
lldb.SBBlock.inlined_block => returns the inlined function block that contains this block (might return itself if the current block is an inlined block)
lldb.SBBlock.range[int] => access the address ranges for a block by index, a list() with start and end address is returned
lldb.SBBlock.ranges => an array or all address ranges for this block
lldb.SBBlock.num_ranges => the number of address ranges for this blcok
SBFunction objects can now get the SBType and the SBBlock that represents the
top scope of the function.
SBBlock objects can now get the variable list from the current block. The value
list returned allows varaibles to be viewed prior with no process if code
wants to check the variables in a function. There are two ways to get a variable
list from a SBBlock:
lldb::SBValueList
SBBlock::GetVariables (lldb::SBFrame& frame,
bool arguments,
bool locals,
bool statics,
lldb::DynamicValueType use_dynamic);
lldb::SBValueList
SBBlock::GetVariables (lldb::SBTarget& target,
bool arguments,
bool locals,
bool statics);
When a SBFrame is used, the values returned will be locked down to the frame
and the values will be evaluated in the context of that frame.
When a SBTarget is used, global an static variables can be viewed without a
running process.
llvm-svn: 149853
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/API/SBAddress.cpp | 2 | ||||
-rw-r--r-- | lldb/source/API/SBBlock.cpp | 125 | ||||
-rw-r--r-- | lldb/source/API/SBFrame.cpp | 8 | ||||
-rw-r--r-- | lldb/source/API/SBFunction.cpp | 23 | ||||
-rw-r--r-- | lldb/source/API/SBModule.cpp | 24 | ||||
-rw-r--r-- | lldb/source/API/SBSymbolContext.cpp | 2 | ||||
-rw-r--r-- | lldb/source/API/SBSymbolContextList.cpp | 24 | ||||
-rw-r--r-- | lldb/source/API/SBTarget.cpp | 23 | ||||
-rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 26 | ||||
-rw-r--r-- | lldb/source/Symbol/SymbolContext.cpp | 32 | ||||
-rw-r--r-- | lldb/source/Symbol/Type.cpp | 15 |
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) { |