diff options
-rw-r--r-- | lldb/include/lldb/Symbol/Block.h | 11 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectFrame.cpp | 66 | ||||
-rw-r--r-- | lldb/source/Symbol/Block.cpp | 8 | ||||
-rw-r--r-- | lldb/source/Symbol/Variable.cpp | 8 |
4 files changed, 63 insertions, 30 deletions
diff --git a/lldb/include/lldb/Symbol/Block.h b/lldb/include/lldb/Symbol/Block.h index 7eba15b03cf..21a78614f6f 100644 --- a/lldb/include/lldb/Symbol/Block.h +++ b/lldb/include/lldb/Symbol/Block.h @@ -133,6 +133,17 @@ public: 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; diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index e79937bfbf4..1593488f4c1 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -316,7 +316,8 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: ptr_depth, 0, m_options.max_depth, - m_options.use_objc); + m_options.use_objc, + false); s.EOL(); } @@ -701,7 +719,6 @@ public: 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 @@ public: 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 (": "); + 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(); } - DumpValueObject (result, - exe_ctx.frame, - valobj_sp.get(), - name_cstr, - m_options.ptr_depth, - 0, - m_options.max_depth, - m_options.use_objc); - - s.EOL(); } } } diff --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp index a6e7f8f7e9a..8ad775f4fed 100644 --- a/lldb/source/Symbol/Block.cpp +++ b/lldb/source/Symbol/Block.cpp @@ -239,17 +239,17 @@ Block::Contains (addr_t range_offset) const 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; } diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index 3aafa2bd919..4ab9fa30bec 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -168,15 +168,15 @@ Variable::IsInScope (StackFrame *frame) { // 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; |