summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-09-07 04:20:48 +0000
committerGreg Clayton <gclayton@apple.com>2010-09-07 04:20:48 +0000
commit95897c6a3a7e7b9a8ee085948e019df14edb6be6 (patch)
tree7a1fcf9577ef3aff52d5e73841044a506c5f3853
parent71972d45dc31f59bc79af53489a873a8f721a539 (diff)
downloadbcm5719-llvm-95897c6a3a7e7b9a8ee085948e019df14edb6be6.tar.gz
bcm5719-llvm-95897c6a3a7e7b9a8ee085948e019df14edb6be6.zip
Added more API to lldb::SBBlock to allow getting the block
parent, sibling and first child block, and access to the inline function information. Added an accessor the StackFrame: Block * lldb_private::StackFrame::GetFrameBlock(); LLDB represents inline functions as lexical blocks that have inlined function information in them. The function above allows us to easily get the top most lexical block that defines a stack frame. When there are no inline functions in function, the block returned ends up being the top most block for the function. When the PC is in an inlined funciton for a frame, this will return the first parent block that has inlined function information. The other accessor: StackFrame::GetBlock() will return the deepest block that matches the frame's PC value. Since most debuggers want to display all variables in the current frame, the Block returned by StackFrame::GetFrameBlock can be used to retrieve all variables for the current frame. Fixed the lldb_private::Block::DumpStopContext(...) to properly display inline frames a block should display all of its inlined functions. Prior to this fix, one of the call sites was being skipped. This is a separate code path from the current default where inlined functions get their own frames. Fixed an issue where a block would always grab variables for any child inline function blocks. llvm-svn: 113195
-rw-r--r--lldb/include/lldb/API/SBBlock.h31
-rw-r--r--lldb/include/lldb/API/SBFileSpec.h3
-rw-r--r--lldb/include/lldb/API/SBFrame.h16
-rw-r--r--lldb/include/lldb/Symbol/Block.h17
-rw-r--r--lldb/include/lldb/Target/StackFrame.h3
-rw-r--r--lldb/lldb.xcodeproj/project.pbxproj1
-rw-r--r--lldb/source/API/SBBlock.cpp87
-rw-r--r--lldb/source/API/SBFrame.cpp7
-rw-r--r--lldb/source/Symbol/Block.cpp99
-rw-r--r--lldb/source/Symbol/SymbolContext.cpp6
-rw-r--r--lldb/source/Target/StackFrame.cpp101
-rw-r--r--lldb/source/Target/StackFrameList.cpp2
12 files changed, 287 insertions, 86 deletions
diff --git a/lldb/include/lldb/API/SBBlock.h b/lldb/include/lldb/API/SBBlock.h
index b6ef1882abf..efab6429561 100644
--- a/lldb/include/lldb/API/SBBlock.h
+++ b/lldb/include/lldb/API/SBBlock.h
@@ -23,17 +23,44 @@ public:
~SBBlock ();
bool
+ IsInlined () const;
+
+ bool
IsValid () const;
- void
- AppendVariables (bool can_create, bool get_parent_variables, lldb_private::VariableList *var_list);
+ const char *
+ GetInlinedName () const;
+
+ lldb::SBFileSpec
+ GetInlinedCallSiteFile () const;
+
+ uint32_t
+ GetInlinedCallSiteLine () const;
+
+ uint32_t
+ GetInlinedCallSiteColumn () const;
+
+ lldb::SBBlock
+ GetParent ();
+
+ lldb::SBBlock
+ GetSibling ();
+
+ lldb::SBBlock
+ GetFirstChild ();
private:
friend class SBFrame;
friend class SBSymbolContext;
+#ifndef SWIG
+
SBBlock (lldb_private::Block *lldb_object_ptr);
+ void
+ AppendVariables (bool can_create, bool get_parent_variables, lldb_private::VariableList *var_list);
+
+#endif
lldb_private::Block *m_opaque_ptr;
};
diff --git a/lldb/include/lldb/API/SBFileSpec.h b/lldb/include/lldb/API/SBFileSpec.h
index 12644b784f2..95eeb1544bb 100644
--- a/lldb/include/lldb/API/SBFileSpec.h
+++ b/lldb/include/lldb/API/SBFileSpec.h
@@ -49,9 +49,10 @@ public:
ResolvePath (const char *src_path, char *dst_path, size_t dst_len);
private:
- friend class SBLineEntry;
+ friend class SBBlock;
friend class SBCompileUnit;
friend class SBHostOS;
+ friend class SBLineEntry;
friend class SBModule;
friend class SBSourceManager;
friend class SBThread;
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h
index f5898d7b242..edafcfb97f8 100644
--- a/lldb/include/lldb/API/SBFrame.h
+++ b/lldb/include/lldb/API/SBFrame.h
@@ -57,9 +57,25 @@ public:
lldb::SBFunction
GetFunction () const;
+ // Gets the deepest block that contains the frame PC
lldb::SBBlock
GetBlock () const;
+ // Gets the lexical block that defines the stack frame. Another way to think
+ // of this is it will return the block that contains all of the variables
+ // for a stack frame. Inlined functions are represented as SBBlock objects
+ // that have inlined function information: the name of the inlined function,
+ // where it was called from. The block that is returned will be the first
+ // block at or above the block for the PC (SBFrame::GetBlock()) that defines
+ // the scope of the frame. When a function contains no inlined functions,
+ // this will be the top most lexical block that defines the function.
+ // When a function has inlined functions and the PC is currently
+ // in one of those inlined functions, this method will return the inlined
+ // block that defines this frame. If the PC isn't currently in an inlined
+ // function, the lexical block that defines the function is returned.
+ lldb::SBBlock
+ GetFrameBlock () const;
+
lldb::SBLineEntry
GetLineEntry () const;
diff --git a/lldb/include/lldb/Symbol/Block.h b/lldb/include/lldb/Symbol/Block.h
index f7a474b7322..7eba15b03cf 100644
--- a/lldb/include/lldb/Symbol/Block.h
+++ b/lldb/include/lldb/Symbol/Block.h
@@ -159,7 +159,11 @@ public:
Dump (Stream *s, lldb::addr_t base_addr, int32_t depth, bool show_context) const;
void
- DumpStopContext (Stream *s, const SymbolContext *sc, bool show_fullpaths);
+ DumpStopContext (Stream *s,
+ const SymbolContext *sc,
+ const Declaration *child_inline_call_site,
+ bool show_fullpaths,
+ bool show_inline_blocks);
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
@@ -251,12 +255,19 @@ public:
/// to see the current state of what has been parsed up to this
/// point.
///
+ /// @param[in] add_inline_child_block_variables
+ /// If this is \b false, no child variables of child blocks
+ /// that are inlined functions will be gotten. If \b true then
+ /// all child variables will be added regardless of wether they
+ /// come from inlined functions or not.
+ ///
/// @return
/// A variable list shared pointer that contains all variables
/// for this block.
//------------------------------------------------------------------
lldb::VariableListSP
- GetVariableList (bool get_child_variables, bool can_create);
+ GetVariableList (bool get_child_variables,
+ bool can_create);
//------------------------------------------------------------------
@@ -301,7 +312,7 @@ public:
/// if this is a regular block.
//------------------------------------------------------------------
const InlineFunctionInfo*
- InlinedFunctionInfo () const
+ GetInlinedFunctionInfo () const
{
return m_inlineInfoSP.get();
}
diff --git a/lldb/include/lldb/Target/StackFrame.h b/lldb/include/lldb/Target/StackFrame.h
index ae31cedbbfb..66a2c1d5de2 100644
--- a/lldb/include/lldb/Target/StackFrame.h
+++ b/lldb/include/lldb/Target/StackFrame.h
@@ -81,6 +81,9 @@ public:
bool
GetFrameBaseValue(Scalar &value, Error *error_ptr);
+ Block *
+ GetFrameBlock ();
+
RegisterContext *
GetRegisterContext ();
diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj
index e04a0c47f05..2b7caa2f129 100644
--- a/lldb/lldb.xcodeproj/project.pbxproj
+++ b/lldb/lldb.xcodeproj/project.pbxproj
@@ -2282,7 +2282,6 @@
isa = PBXProject;
buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
compatibilityVersion = "Xcode 3.1";
- developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
diff --git a/lldb/source/API/SBBlock.cpp b/lldb/source/API/SBBlock.cpp
index e7485cc1d4e..961e8d84663 100644
--- a/lldb/source/API/SBBlock.cpp
+++ b/lldb/source/API/SBBlock.cpp
@@ -8,9 +8,12 @@
//===----------------------------------------------------------------------===//
#include "lldb/API/SBBlock.h"
+#include "lldb/API/SBFileSpec.h"
#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/Function.h"
using namespace lldb;
+using namespace lldb_private;
SBBlock::SBBlock () :
@@ -34,6 +37,63 @@ SBBlock::IsValid () const
return m_opaque_ptr != NULL;
}
+bool
+SBBlock::IsInlined () const
+{
+ if (m_opaque_ptr)
+ return m_opaque_ptr->GetInlinedFunctionInfo () != NULL;
+ return false;
+}
+
+const char *
+SBBlock::GetInlinedName () const
+{
+ if (m_opaque_ptr)
+ {
+ const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo ();
+ if (inlined_info)
+ return inlined_info->GetName().AsCString (NULL);
+ }
+ return NULL;
+}
+
+SBFileSpec
+SBBlock::GetInlinedCallSiteFile () const
+{
+ SBFileSpec sb_file;
+ if (m_opaque_ptr)
+ {
+ const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo ();
+ if (inlined_info)
+ sb_file.SetFileSpec (inlined_info->GetCallSite().GetFile());
+ }
+ return sb_file;
+}
+
+uint32_t
+SBBlock::GetInlinedCallSiteLine () const
+{
+ if (m_opaque_ptr)
+ {
+ const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo ();
+ if (inlined_info)
+ return inlined_info->GetCallSite().GetLine();
+ }
+ return 0;
+}
+
+uint32_t
+SBBlock::GetInlinedCallSiteColumn () const
+{
+ if (m_opaque_ptr)
+ {
+ const InlineFunctionInfo* inlined_info = m_opaque_ptr->GetInlinedFunctionInfo ();
+ if (inlined_info)
+ return inlined_info->GetCallSite().GetColumn();
+ }
+ return 0;
+}
+
void
SBBlock::AppendVariables (bool can_create, bool get_parent_variables, lldb_private::VariableList *var_list)
{
@@ -44,5 +104,32 @@ SBBlock::AppendVariables (bool can_create, bool get_parent_variables, lldb_priva
}
}
+SBBlock
+SBBlock::GetParent ()
+{
+ SBBlock sb_block;
+ if (m_opaque_ptr)
+ sb_block.m_opaque_ptr = m_opaque_ptr->GetParent();
+ return sb_block;
+}
+
+SBBlock
+SBBlock::GetSibling ()
+{
+ SBBlock sb_block;
+ if (m_opaque_ptr)
+ sb_block.m_opaque_ptr = m_opaque_ptr->GetSibling();
+ return sb_block;
+}
+
+SBBlock
+SBBlock::GetFirstChild ()
+{
+ SBBlock sb_block;
+ if (m_opaque_ptr)
+ sb_block.m_opaque_ptr = m_opaque_ptr->GetFirstChild();
+ return sb_block;
+}
+
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index ce294cafa7b..65846e57f49 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -105,6 +105,13 @@ SBFrame::GetBlock () const
return sb_block;
}
+SBBlock
+SBFrame::GetFrameBlock () const
+{
+ SBBlock sb_block(m_opaque_sp->GetFrameBlock ());
+ return sb_block;
+}
+
SBLineEntry
SBFrame::GetLineEntry () const
{
diff --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp
index 67b44901744..a1de78a1f30 100644
--- a/lldb/source/Symbol/Block.cpp
+++ b/lldb/source/Symbol/Block.cpp
@@ -145,48 +145,77 @@ Block::CalculateSymbolContext (SymbolContext* sc)
}
void
-Block::DumpStopContext (Stream *s, const SymbolContext *sc, bool show_fullpaths)
+Block::DumpStopContext
+(
+ Stream *s,
+ const SymbolContext *sc_ptr,
+ const Declaration *child_inline_call_site,
+ bool show_fullpaths,
+ bool show_inline_blocks)
{
Block* parent_block = GetParent();
- const InlineFunctionInfo* inline_info = InlinedFunctionInfo ();
+ const InlineFunctionInfo* inline_info = GetInlinedFunctionInfo ();
+ const Declaration *inline_call_site = child_inline_call_site;
if (inline_info)
{
- const Declaration &call_site = inline_info->GetCallSite();
- if (sc)
+ inline_call_site = &inline_info->GetCallSite();
+ if (sc_ptr)
{
- // First frame, dump the first inline call site
-// if (call_site.IsValid())
-// {
-// s->PutCString(" at ");
-// call_site.DumpStopContext (s);
-// }
+ // First frame in a frame with inlined functions
s->PutCString (" [inlined]");
}
- s->EOL();
- inline_info->DumpStopContext (s);
- if (sc == NULL)
+ if (show_inline_blocks)
+ s->EOL();
+ else
+ s->PutChar(' ');
+
+ s->PutCString(inline_info->GetName ().AsCString());
+
+ if (child_inline_call_site && child_inline_call_site->IsValid())
{
- if (call_site.IsValid())
- {
- s->PutCString(" at ");
- call_site.DumpStopContext (s, show_fullpaths);
- }
+ s->PutCString(" at ");
+ child_inline_call_site->DumpStopContext (s, show_fullpaths);
}
}
- if (sc)
+ if (sc_ptr)
{
// If we have any inlined functions, this will be the deepest most
// inlined location
- if (sc->line_entry.IsValid())
+ if (sc_ptr->line_entry.IsValid())
{
s->PutCString(" at ");
- sc->line_entry.DumpStopContext (s, show_fullpaths);
+ sc_ptr->line_entry.DumpStopContext (s, show_fullpaths);
+ }
+ }
+
+ if (show_inline_blocks)
+ {
+ if (parent_block)
+ {
+ parent_block->Block::DumpStopContext (s,
+ NULL,
+ inline_call_site,
+ show_fullpaths,
+ show_inline_blocks);
+ }
+ else if (child_inline_call_site)
+ {
+ SymbolContext sc;
+ CalculateSymbolContext(&sc);
+ if (sc.function)
+ {
+ s->EOL();
+ s->Indent (sc.function->GetMangled().GetName().AsCString());
+ if (child_inline_call_site && child_inline_call_site->IsValid())
+ {
+ s->PutCString(" at ");
+ child_inline_call_site->DumpStopContext (s, show_fullpaths);
+ }
+ }
}
}
- if (parent_block)
- parent_block->Block::DumpStopContext (s, NULL, show_fullpaths);
}
@@ -246,7 +275,7 @@ Block::GetParent () const
Block *
Block::GetContainingInlinedBlock ()
{
- if (InlinedFunctionInfo())
+ if (GetInlinedFunctionInfo())
return this;
return GetInlinedParent ();
}
@@ -257,7 +286,7 @@ Block::GetInlinedParent ()
Block *parent_block = GetParent ();
if (parent_block)
{
- if (parent_block->InlinedFunctionInfo())
+ if (parent_block->GetInlinedFunctionInfo())
return parent_block;
else
return parent_block->GetInlinedParent();
@@ -381,13 +410,17 @@ Block::GetVariableList (bool get_child_variables, bool can_create)
if (get_child_variables)
{
- Block *child_block = GetFirstChild();
- while (child_block)
- {
- VariableListSP child_block_variable_list(child_block->GetVariableList(get_child_variables, can_create));
- if (child_block_variable_list.get())
- variable_list_sp->AddVariables(child_block_variable_list.get());
- child_block = child_block->GetSibling();
+ for (Block *child_block = GetFirstChild();
+ child_block != NULL;
+ child_block = child_block->GetSibling())
+ {
+ if (child_block->GetInlinedFunctionInfo() == NULL)
+ {
+ VariableListSP child_block_variable_list(child_block->GetVariableList(get_child_variables, can_create));
+ if (child_block_variable_list.get())
+ variable_list_sp->AddVariables(child_block_variable_list.get());
+ }
+
}
}
}
@@ -407,7 +440,7 @@ Block::AppendVariables
uint32_t num_variables_added = 0;
VariableListSP variable_list_sp(GetVariableList(false, can_create));
- bool is_inlined_function = InlinedFunctionInfo() != NULL;
+ bool is_inlined_function = GetInlinedFunctionInfo() != NULL;
if (variable_list_sp.get())
{
num_variables_added = variable_list_sp->GetSize();
diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp
index f54d85681e3..51178fc38ec 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -135,12 +135,12 @@ SymbolContext::DumpStopContext
if (show_inlined_frames && block)
{
- const InlineFunctionInfo *inline_info = block->InlinedFunctionInfo();
+ const InlineFunctionInfo *inline_info = block->GetInlinedFunctionInfo();
if (inline_info == NULL)
{
const Block *parent_inline_block = block->GetInlinedParent();
if (parent_inline_block)
- inline_info = parent_inline_block->InlinedFunctionInfo();
+ inline_info = parent_inline_block->GetInlinedFunctionInfo();
}
if (inline_info)
@@ -163,7 +163,7 @@ SymbolContext::DumpStopContext
if (block != NULL)
{
s->IndentMore();
- block->DumpStopContext(s, this, show_fullpaths);
+ block->DumpStopContext (s, this, NULL, show_fullpaths, show_inlined_frames);
s->IndentLess();
}
else
diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index 5237bbe63be..6d2699d58b1 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -165,40 +165,27 @@ StackFrame::GetStackID()
{
if (m_id.GetSymbolContextScope ())
{
+ // We already have a symbol context scope, we just don't have our
+ // flag bit set.
m_flags.Set (RESOLVED_FRAME_ID_SYMBOL_SCOPE);
}
else
{
- GetSymbolContext (eSymbolContextFunction | eSymbolContextBlock);
-
- if (m_sc.block)
- {
- Block *inline_block = m_sc.block->GetContainingInlinedBlock();
- if (inline_block)
- {
- // Use the block with the inlined function info
- // as the symbol context since we want this frame
- // to have only the variables for the inlined function
- SetSymbolContextScope (inline_block);
- }
- else
- {
- // This block is not inlined with means it has no
- // inlined parents either, so we want to use the top
- // most function block.
- SetSymbolContextScope (&m_sc.function->GetBlock(false));
- }
- }
- else
+ // Calculate the frame block and use this for the stack ID symbol
+ // context scope if we have one.
+ SymbolContextScope *scope = GetFrameBlock ();
+ if (scope == NULL)
{
- // The current stack frame doesn't have a block. Check to see
- // if it has a symbol. If it does we will use this as the
- // symbol scope. It is ok if "m_sc.symbol" is NULL below as
- // it will set the symbol context to NULL and set the
- // RESOLVED_FRAME_ID_SYMBOL_SCOPE flag bit.
- GetSymbolContext (eSymbolContextSymbol);
- SetSymbolContextScope (m_sc.symbol);
+ // We don't have a block, so use the symbol
+ if (m_flags.IsClear (eSymbolContextSymbol))
+ GetSymbolContext (eSymbolContextSymbol);
+
+ // It is ok if m_sc.symbol is NULL here
+ scope = m_sc.symbol;
}
+ // Set the symbol context scope (the accessor will set the
+ // RESOLVED_FRAME_ID_SYMBOL_SCOPE bit in m_flags).
+ SetSymbolContextScope (scope);
}
}
return m_id;
@@ -270,6 +257,32 @@ StackFrame::Disassemble ()
return m_disassembly.GetData();
}
+Block *
+StackFrame::GetFrameBlock ()
+{
+ if (m_sc.block == NULL && m_flags.IsClear (eSymbolContextBlock))
+ GetSymbolContext (eSymbolContextBlock);
+
+ if (m_sc.block)
+ {
+ Block *inline_block = m_sc.block->GetContainingInlinedBlock();
+ if (inline_block)
+ {
+ // Use the block with the inlined function info
+ // as the frame block we want this frame to have only the variables
+ // for the inlined function and its non-inlined block child blocks.
+ return inline_block;
+ }
+ else
+ {
+ // This block is not contained withing any inlined function blocks
+ // with so we want to use the top most function block.
+ return &m_sc.function->GetBlock (false);
+ }
+ }
+ return NULL;
+}
+
//----------------------------------------------------------------------
// Get the symbol context if we already haven't done so by resolving the
// PC address as much as possible. This way when we pass around a
@@ -427,24 +440,28 @@ StackFrame::GetVariableList (bool get_file_globals)
{
m_flags.Set(RESOLVED_VARIABLES);
- GetSymbolContext (eSymbolContextCompUnit |
- eSymbolContextFunction |
- eSymbolContextBlock);
-
- if (m_sc.block)
+ Block *frame_block = GetFrameBlock();
+
+ if (frame_block)
{
- bool get_child_variables = true;
- bool can_create = true;
- m_variable_list_sp = m_sc.function->GetBlock (can_create).GetVariableList (get_child_variables, can_create);
+ const bool get_child_variables = true;
+ const bool can_create = true;
+ m_variable_list_sp = frame_block->GetVariableList (get_child_variables, can_create);
}
- if (get_file_globals && m_sc.comp_unit)
+ if (get_file_globals)
{
- VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
- if (m_variable_list_sp)
- m_variable_list_sp->AddVariables (global_variable_list_sp.get());
- else
- m_variable_list_sp = global_variable_list_sp;
+ if (m_flags.IsClear (eSymbolContextCompUnit))
+ GetSymbolContext (eSymbolContextCompUnit);
+
+ if (m_sc.comp_unit)
+ {
+ VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
+ if (m_variable_list_sp)
+ m_variable_list_sp->AddVariables (global_variable_list_sp.get());
+ else
+ m_variable_list_sp = global_variable_list_sp;
+ }
}
}
return m_variable_list_sp.get();
diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp
index d2c9c594b04..2e76d339a5e 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -135,7 +135,7 @@ StackFrameList::GetNumFrames (bool can_create)
AddressRange range;
inlined_block->GetRangeContainingAddress (previous_frame_lookup_addr, range);
- const InlineFunctionInfo* inline_info = inlined_block->InlinedFunctionInfo();
+ const InlineFunctionInfo* inline_info = inlined_block->GetInlinedFunctionInfo();
assert (inline_info);
inline_sc.line_entry.range.GetBaseAddress() = m_frames.back()->GetFrameCodeAddress();
inline_sc.line_entry.file = inline_info->GetCallSite().GetFile();
OpenPOWER on IntegriCloud