[Lldb-commits] [lldb] r134878 - in /lldb/trunk: include/lldb/Symbol/Declaration.h include/lldb/Symbol/SymbolContext.h include/lldb/Symbol/Variable.h source/Commands/CommandObjectFrame.cpp source/Commands/CommandObjectTarget.cpp source/Core/ValueObject.cpp source/Symbol/Declaration.cpp source/Symbol/SymbolContext.cpp source/Symbol/Variable.cpp

Greg Clayton gclayton at apple.com
Sun Jul 10 12:21:23 PDT 2011


Author: gclayton
Date: Sun Jul 10 14:21:23 2011
New Revision: 134878

URL: http://llvm.org/viewvc/llvm-project?rev=134878&view=rev
Log:
Allow the built in ValueObject summary providers for C strings
use lldb_private::Target::ReadMemory(...) to allow constant strings
to be displayed in global variables prior on in between process
execution.

Centralized the variable declaration dumping into:

	bool
	Variable::DumpDeclaration (Stream *s, bool show_fullpaths, bool show_module);

Fixed an issue if you used "target variable --regex <regex>" where the
variable name would not be displayed, but the regular expression would.

Fixed an issue when viewing global variables through "target variable"
might not display correctly when doing DWARF in object files.


Modified:
    lldb/trunk/include/lldb/Symbol/Declaration.h
    lldb/trunk/include/lldb/Symbol/SymbolContext.h
    lldb/trunk/include/lldb/Symbol/Variable.h
    lldb/trunk/source/Commands/CommandObjectFrame.cpp
    lldb/trunk/source/Commands/CommandObjectTarget.cpp
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/Symbol/Declaration.cpp
    lldb/trunk/source/Symbol/SymbolContext.cpp
    lldb/trunk/source/Symbol/Variable.cpp

Modified: lldb/trunk/include/lldb/Symbol/Declaration.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Declaration.h?rev=134878&r1=134877&r2=134878&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Declaration.h (original)
+++ lldb/trunk/include/lldb/Symbol/Declaration.h Sun Jul 10 14:21:23 2011
@@ -141,7 +141,7 @@
     void
     Dump (Stream *s, bool show_fullpaths) const;
 
-    void
+    bool
     DumpStopContext (Stream *s, bool show_fullpaths) const;
     //------------------------------------------------------------------
     /// Get accessor for the declaration column number.

Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=134878&r1=134877&r2=134878&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Sun Jul 10 14:21:23 2011
@@ -160,7 +160,7 @@
     /// @param[in] so_addr
     ///     The resolved section offset address.
     //------------------------------------------------------------------
-    void
+    bool
     DumpStopContext (Stream *s,
                      ExecutionContextScope *exe_scope,
                      const Address &so_addr,

Modified: lldb/trunk/include/lldb/Symbol/Variable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Variable.h?rev=134878&r1=134877&r2=134878&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Variable.h (original)
+++ lldb/trunk/include/lldb/Symbol/Variable.h Sun Jul 10 14:21:23 2011
@@ -44,6 +44,11 @@
     void
     Dump(Stream *s, bool show_context) const;
 
+    bool
+    DumpDeclaration (Stream *s, 
+                     bool show_fullpaths, 
+                     bool show_module);
+    
     const Declaration&
     GetDeclaration() const
     {

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=134878&r1=134877&r2=134878&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Sun Jul 10 14:21:23 2011
@@ -479,8 +479,10 @@
                                                 
                                                 if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile())
                                                 {
-                                                    var_sp->GetDeclaration ().DumpStopContext (&s, false);
-                                                    s.PutCString (": ");
+                                                    bool show_fullpaths = false;
+                                                    bool show_module = true;
+                                                    if (var_sp->DumpDeclaration(&s, show_fullpaths, show_module))
+                                                        s.PutCString (": ");
                                                 }
                                                 
                                                 ValueObject::DumpValueObject (result.GetOutputStream(), 

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=134878&r1=134877&r2=134878&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Sun Jul 10 14:21:23 2011
@@ -466,10 +466,12 @@
                 break;
         }
         
-        if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile())
+        if (m_option_variable.show_decl)
         {
-            var_sp->GetDeclaration ().DumpStopContext (&s, false);
-            s.PutCString (": ");
+            bool show_fullpaths = false;
+            bool show_module = true;
+            if (var_sp->DumpDeclaration(&s, show_fullpaths, show_module))
+                s.PutCString (": ");
         }
         
         const Format format = m_option_variable.format;
@@ -528,6 +530,7 @@
 
                     const char *arg = args.GetArgumentAtIndex(idx);
                     uint32_t matches = 0;
+                    bool use_var_name = false;
                     if (m_option_variable.use_regex)
                     {
                         RegularExpression regex(arg);
@@ -537,6 +540,7 @@
                             result.SetStatus (eReturnStatusFailed);
                             return false;
                         }
+                        use_var_name = true;
                         matches = exe_ctx.target->GetImages().FindGlobalVariables (regex,
                                                                                    true, 
                                                                                    UINT32_MAX, 
@@ -573,10 +577,10 @@
                             {
                                 ValueObjectSP valobj_sp (valobj_list.GetValueObjectAtIndex(global_idx));
                                 if (!valobj_sp)
-                                    valobj_sp = ValueObjectVariable::Create (exe_ctx.target, var_sp);
+                                    valobj_sp = ValueObjectVariable::Create (exe_ctx.GetBestExecutionContextScope(), var_sp);
                                 
                                 if (valobj_sp)
-                                    DumpValueObject (s, var_sp, valobj_sp, arg);
+                                    DumpValueObject (s, var_sp, valobj_sp, use_var_name ? var_sp->GetName().GetCString() : arg);
                             }
                         }
                     }

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=134878&r1=134877&r2=134878&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Sun Jul 10 14:21:23 2011
@@ -563,8 +563,8 @@
                     if (type_flags.AnySet (ClangASTContext::eTypeIsArray | ClangASTContext::eTypeIsPointer) &&
                         ClangASTContext::IsCharType (elem_or_pointee_clang_type))
                     {
-                        Process *process = exe_scope->CalculateProcess();
-                        if (process != NULL)
+                        Target *target = exe_scope->CalculateTarget();
+                        if (target != NULL)
                         {
                             lldb::addr_t cstr_address = LLDB_INVALID_ADDRESS;
                             AddressType cstr_address_type = eAddressTypeInvalid;
@@ -593,15 +593,21 @@
                             }
                             if (cstr_address != LLDB_INVALID_ADDRESS)
                             {
+                                Address cstr_so_addr (NULL, cstr_address);
                                 DataExtractor data;
                                 size_t bytes_read = 0;
                                 std::vector<char> data_buffer;
                                 Error error;
+                                bool prefer_file_cache = false;
                                 if (cstr_len > 0)
                                 {
                                     data_buffer.resize(cstr_len);
                                     data.SetData (&data_buffer.front(), data_buffer.size(), lldb::endian::InlHostByteOrder());
-                                    bytes_read = process->ReadMemory (cstr_address, &data_buffer.front(), cstr_len, error);
+                                    bytes_read = target->ReadMemory (cstr_so_addr, 
+                                                                     prefer_file_cache, 
+                                                                     &data_buffer.front(), 
+                                                                     cstr_len, 
+                                                                     error);
                                     if (bytes_read > 0)
                                     {
                                         sstr << '"';
@@ -629,7 +635,11 @@
                                     sstr << '"';
 
                                     data.SetData (&data_buffer.front(), data_buffer.size(), endian::InlHostByteOrder());
-                                    while ((bytes_read = process->ReadMemory (cstr_address, &data_buffer.front(), k_max_buf_size, error)) > 0)
+                                    while ((bytes_read = target->ReadMemory (cstr_so_addr, 
+                                                                             prefer_file_cache,
+                                                                             &data_buffer.front(), 
+                                                                             k_max_buf_size, 
+                                                                             error)) > 0)
                                     {
                                         size_t len = strlen(&data_buffer.front());
                                         if (len == 0)
@@ -649,7 +659,7 @@
                                         
                                         if (len < k_max_buf_size)
                                             break;
-                                        cstr_address += k_max_buf_size;
+                                        cstr_so_addr.Slide (k_max_buf_size);
                                     }
                                     sstr << '"';
                                 }

Modified: lldb/trunk/source/Symbol/Declaration.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Declaration.cpp?rev=134878&r1=134877&r2=134878&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Declaration.cpp (original)
+++ lldb/trunk/source/Symbol/Declaration.cpp Sun Jul 10 14:21:23 2011
@@ -46,7 +46,7 @@
     }
 }
 
-void
+bool
 Declaration::DumpStopContext (Stream *s, bool show_fullpaths) const
 {
     if (m_file)
@@ -62,15 +62,18 @@
         if (m_column > 0)
             s->Printf(":%u", m_column);
 #endif
+        return true;
     }
-    else
+    else if (m_line > 0)
     {
         s->Printf(" line %u", m_line);
 #ifdef LLDB_ENABLE_DECLARATION_COLUMNS
         if (m_column > 0)
             s->Printf(":%u", m_column);
 #endif
+        return true;
     }
+    return false;
 }
 
 size_t

Modified: lldb/trunk/source/Symbol/SymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=134878&r1=134877&r2=134878&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolContext.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolContext.cpp Sun Jul 10 14:21:23 2011
@@ -110,7 +110,7 @@
     symbol      = NULL;
 }
 
-void
+bool
 SymbolContext::DumpStopContext
 (
     Stream *s,
@@ -121,6 +121,7 @@
     bool show_inlined_frames
 ) const
 {
+    bool dumped_something = false;
     if (show_module && module_sp)
     {
         if (show_fullpaths)
@@ -128,18 +129,25 @@
         else
             *s << module_sp->GetFileSpec().GetFilename();
         s->PutChar('`');
+        dumped_something = true;
     }
 
     if (function != NULL)
     {
         if (function->GetMangled().GetName())
+        {
+            dumped_something = true;
             function->GetMangled().GetName().Dump(s);
+        }
 
         if (addr.IsValid())
         {
             const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset();
             if (function_offset)
-                s->Printf(" + %llu", function_offset);
+            {
+                dumped_something = true;
+                s->Printf(" + %llu", function_offset);                
+            }
         }
 
         if (block != NULL)
@@ -147,11 +155,13 @@
             s->IndentMore();
             block->DumpStopContext (s, this, NULL, show_fullpaths, show_inlined_frames);
             s->IndentLess();
+            dumped_something = true;
         }
         else
         {
             if (line_entry.IsValid())
             {
+                dumped_something = true;
                 s->PutCString(" at ");
                 if (line_entry.DumpStopContext(s, show_fullpaths))
                     return;
@@ -160,19 +170,28 @@
     }
     else if (symbol != NULL)
     {
-        symbol->GetMangled().GetName().Dump(s);
+        if (symbol->GetMangled().GetName())
+        {
+            dumped_something = true;
+            symbol->GetMangled().GetName().Dump(s);
+        }
 
         if (addr.IsValid() && symbol->GetAddressRangePtr())
         {
             const addr_t symbol_offset = addr.GetOffset() - symbol->GetAddressRangePtr()->GetBaseAddress().GetOffset();
             if (symbol_offset)
-                s->Printf(" + %llu", symbol_offset);
+            {
+                dumped_something = true;
+                s->Printf(" + %llu", symbol_offset);                
+            }
         }
     }
     else if (addr.IsValid())
     {
         addr.Dump(s, exe_scope, Address::DumpStyleModuleWithFileAddress);
+        dumped_something = true;
     }
+    return dumped_something;
 }
 
 void

Modified: lldb/trunk/source/Symbol/Variable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=134878&r1=134877&r2=134878&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Variable.cpp (original)
+++ lldb/trunk/source/Symbol/Variable.cpp Sun Jul 10 14:21:23 2011
@@ -142,6 +142,32 @@
     s->EOL();
 }
 
+bool
+Variable::DumpDeclaration (Stream *s, bool show_fullpaths, bool show_module)
+{
+    bool dumped_declaration_info = false;
+    if (m_owner_scope)
+    {
+        SymbolContext sc;
+        m_owner_scope->CalculateSymbolContext(&sc);
+        sc.block = NULL;
+        sc.line_entry.Clear();
+        bool show_inlined_frames = false;
+    
+        dumped_declaration_info = sc.DumpStopContext (s, 
+                                                      NULL, 
+                                                      Address(), 
+                                                      show_fullpaths, 
+                                                      show_module, 
+                                                      show_inlined_frames);
+        
+        if (sc.function)
+            s->PutChar(':');
+    }
+    if (m_declaration.DumpStopContext (s, false))
+        dumped_declaration_info = true;
+    return dumped_declaration_info;
+}
 
 size_t
 Variable::MemorySize() const





More information about the lldb-commits mailing list