[Lldb-commits] [lldb] r113830 - in /lldb/trunk: include/lldb/Symbol/Block.h source/Commands/CommandObjectFrame.cpp source/Symbol/Block.cpp source/Symbol/Variable.cpp
Greg Clayton
gclayton at apple.com
Mon Sep 13 20:16:59 PDT 2010
Author: gclayton
Date: Mon Sep 13 22:16:58 2010
New Revision: 113830
URL: http://llvm.org/viewvc/llvm-project?rev=113830&view=rev
Log:
Fixed the implementation of "bool Block::Contains (const Block *block) const"
to return the correct result.
Fixed "bool Variable::IsInScope (StackFrame *frame)" to return the correct
result when there are no location lists.
Modified the "frame variable" command such that:
- if no arguments are given (dump all frame variables), then we only show
variables that are currently in scope
- if some arguments are given, we show an error if the variable is out of
scope
Modified:
lldb/trunk/include/lldb/Symbol/Block.h
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Symbol/Block.cpp
lldb/trunk/source/Symbol/Variable.cpp
Modified: lldb/trunk/include/lldb/Symbol/Block.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=113830&r1=113829&r2=113830&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Block.h (original)
+++ lldb/trunk/include/lldb/Symbol/Block.h Mon Sep 13 22:16:58 2010
@@ -133,6 +133,17 @@
bool
Contains (const VMRange& range) const;
+ //------------------------------------------------------------------
+ /// Check if this object contains "block" as a child block at any
+ /// depth.
+ ///
+ /// @param[in] block
+ /// A potential child block.
+ ///
+ /// @return
+ /// Returns \b true if \a block is a child of this block, \b
+ /// false otherwise.
+ //------------------------------------------------------------------
bool
Contains (const Block *block) const;
Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=113830&r1=113829&r2=113830&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Sep 13 22:16:58 2010
@@ -316,7 +316,8 @@
uint32_t ptr_depth,
uint32_t curr_depth,
uint32_t max_depth,
- bool use_objc)
+ bool use_objc,
+ bool scope_already_checked)
{
if (valobj)
{
@@ -338,12 +339,18 @@
const char *name_cstr = root_valobj_name ? root_valobj_name : valobj->GetName().AsCString("");
s.Printf ("%s = ", name_cstr);
+ if (!scope_already_checked && !valobj->IsInScope(exe_scope->CalculateStackFrame()))
+ {
+ s.PutCString("error: out of scope");
+ return;
+ }
+
const char *val_cstr = valobj->GetValueAsCString(exe_scope);
const char *err_cstr = valobj->GetError().AsCString();
if (err_cstr)
{
- s.Printf ("error: %s\n", err_cstr);
+ s.Printf ("error: %s", err_cstr);
}
else
{
@@ -395,7 +402,8 @@
is_ptr_or_ref ? ptr_depth - 1 : ptr_depth,
curr_depth + 1,
max_depth,
- false);
+ false,
+ true);
if (idx + 1 < num_children)
s.PutChar(',');
}
@@ -476,13 +484,22 @@
if (valobj_sp)
{
- DumpValueObject (result, exe_ctx.frame, valobj_sp.get(), name_cstr, m_options.ptr_depth, 0, m_options.max_depth, false);
-
if (m_options.show_decl && var_sp->GetDeclaration ().GetFile())
{
- var_sp->GetDeclaration ().Dump (&s);
+ var_sp->GetDeclaration ().DumpStopContext (&s, false);
+ s.PutCString (": ");
}
+ DumpValueObject (result,
+ exe_ctx.frame,
+ valobj_sp.get(),
+ name_cstr,
+ m_options.ptr_depth,
+ 0,
+ m_options.max_depth,
+ m_options.use_objc,
+ false);
+
s.EOL();
}
}
@@ -646,7 +663,8 @@
ptr_depth,
0,
m_options.max_depth,
- m_options.use_objc);
+ m_options.use_objc,
+ false);
s.EOL();
}
@@ -701,7 +719,6 @@
if (dump_variable)
{
- //DumpVariable (result, &exe_ctx, var_sp.get());
// Use the variable object code to make sure we are
// using the same APIs as the the public API will be
@@ -709,22 +726,27 @@
valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp);
if (valobj_sp)
{
-
- if (m_options.show_decl && var_sp->GetDeclaration ().GetFile())
+ // When dumping all variables, don't print any variables
+ // that are not in scope to avoid extra unneeded output
+ if (valobj_sp->IsInScope (exe_ctx.frame))
{
- var_sp->GetDeclaration ().DumpStopContext (&s, false);
- s.PutCString (": ");
- }
- DumpValueObject (result,
- exe_ctx.frame,
- valobj_sp.get(),
- name_cstr,
- m_options.ptr_depth,
- 0,
- m_options.max_depth,
- m_options.use_objc);
+ if (m_options.show_decl && var_sp->GetDeclaration ().GetFile())
+ {
+ var_sp->GetDeclaration ().DumpStopContext (&s, false);
+ s.PutCString (": ");
+ }
+ DumpValueObject (result,
+ exe_ctx.frame,
+ valobj_sp.get(),
+ name_cstr,
+ m_options.ptr_depth,
+ 0,
+ m_options.max_depth,
+ m_options.use_objc,
+ true);
- s.EOL();
+ s.EOL();
+ }
}
}
}
Modified: lldb/trunk/source/Symbol/Block.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=113830&r1=113829&r2=113830&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Block.cpp (original)
+++ lldb/trunk/source/Symbol/Block.cpp Mon Sep 13 22:16:58 2010
@@ -239,17 +239,17 @@
bool
Block::Contains (const Block *block) const
{
- // Block objects can't contain themselves...
if (this == block)
- return false;
+ return false; // This block doesn't contain itself...
+ // Walk the parent chain for "block" and see if any if them match this block
const Block *block_parent;
for (block_parent = block->GetParent();
block_parent != NULL;
block_parent = block_parent->GetParent())
{
- if (block_parent == block)
- return true;
+ if (this == block_parent)
+ return true; // One of the parents of "block" is this object!
}
return false;
}
Modified: lldb/trunk/source/Symbol/Variable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=113830&r1=113829&r2=113830&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Variable.cpp (original)
+++ lldb/trunk/source/Symbol/Variable.cpp Mon Sep 13 22:16:58 2010
@@ -168,15 +168,15 @@
{
// We don't have a location list, we just need to see if the block
// that this variable was defined in is currently
- Block *frame_block = frame->GetFrameBlock();
- if (frame_block)
+ Block *deepest_frame_block = frame->GetSymbolContext(eSymbolContextBlock).block;
+ if (deepest_frame_block)
{
SymbolContext variable_sc;
CalculateSymbolContext (&variable_sc);
- if (frame_block == variable_sc.block)
+ if (variable_sc.block == deepest_frame_block)
return true;
- return frame_block->Contains (variable_sc.block);
+ return variable_sc.block->Contains (deepest_frame_block);
}
}
break;
More information about the lldb-commits
mailing list