[Lldb-commits] [lldb] r113571 - in /lldb/trunk/source: Core/Address.cpp Core/AddressRange.cpp Symbol/Block.cpp Symbol/CompileUnit.cpp Symbol/Function.cpp Symbol/LineEntry.cpp Symbol/Symbol.cpp Symbol/SymbolContext.cpp Symbol/Type.cpp

Greg Clayton gclayton at apple.com
Thu Sep 9 18:30:46 PDT 2010


Author: gclayton
Date: Thu Sep  9 20:30:46 2010
New Revision: 113571

URL: http://llvm.org/viewvc/llvm-project?rev=113571&view=rev
Log:
Cleaned up the output of "image lookup --address <ADDR>" which involved
cleaning up the output of many GetDescription objects that are part of a 
symbol context. This fixes an issue where no ranges were being printed out
for functions, blocks and symbols.


Modified:
    lldb/trunk/source/Core/Address.cpp
    lldb/trunk/source/Core/AddressRange.cpp
    lldb/trunk/source/Symbol/Block.cpp
    lldb/trunk/source/Symbol/CompileUnit.cpp
    lldb/trunk/source/Symbol/Function.cpp
    lldb/trunk/source/Symbol/LineEntry.cpp
    lldb/trunk/source/Symbol/Symbol.cpp
    lldb/trunk/source/Symbol/SymbolContext.cpp
    lldb/trunk/source/Symbol/Type.cpp

Modified: lldb/trunk/source/Core/Address.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=113571&r1=113570&r2=113571&view=diff
==============================================================================
--- lldb/trunk/source/Core/Address.cpp (original)
+++ lldb/trunk/source/Core/Address.cpp Thu Sep  9 20:30:46 2010
@@ -381,7 +381,7 @@
             addr_size = sizeof(addr_t);
     }
 
-    lldb_private::Address so_addr;
+    Address so_addr;
     switch (style)
     {
     case DumpStyleInvalid:
@@ -448,7 +448,7 @@
             }
 
             uint32_t pointer_size = 4;
-            lldb_private::Module *module = GetModule();
+            Module *module = GetModule();
             if (process)
                 pointer_size = process->GetAddressByteSize();
             else if (module)
@@ -488,7 +488,7 @@
                         {
                             if (target && so_addr.IsSectionOffset())
                             {
-                                lldb_private::SymbolContext func_sc;
+                                SymbolContext func_sc;
                                 target->GetImages().ResolveSymbolContextForAddress (so_addr,
                                                                                     eSymbolContextEverything,
                                                                                     func_sc);
@@ -577,7 +577,7 @@
                             showed_info = true;
                             if (so_addr.IsSectionOffset())
                             {
-                                lldb_private::SymbolContext pointer_sc;
+                                SymbolContext pointer_sc;
                                 if (target)
                                 {
                                     target->GetImages().ResolveSymbolContextForAddress (so_addr,
@@ -603,7 +603,7 @@
             {
                 if (module)
                 {
-                    lldb_private::SymbolContext sc;
+                    SymbolContext sc;
                     module->ResolveSymbolContextForAddress(*this, eSymbolContextEverything, sc);
                     if (sc.function || sc.symbol)
                     {
@@ -656,18 +656,10 @@
     case DumpStyleDetailedSymbolContext:
         if (IsSectionOffset())
         {
-            lldb::AddressType addr_type = eAddressTypeLoad;
-            addr_t addr = GetLoadAddress (process);
-            if (addr == LLDB_INVALID_ADDRESS)
-            {
-                addr = GetFileAddress();
-                addr_type = eAddressTypeFile;
-            }
-
-            lldb_private::Module *module = GetModule();
+            Module *module = GetModule();
             if (module)
             {
-                lldb_private::SymbolContext sc;
+                SymbolContext sc;
                 module->ResolveSymbolContextForAddress(*this, eSymbolContextEverything, sc);
                 if (sc.symbol)
                 {

Modified: lldb/trunk/source/Core/AddressRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/AddressRange.cpp?rev=113571&r1=113570&r2=113571&view=diff
==============================================================================
--- lldb/trunk/source/Core/AddressRange.cpp (original)
+++ lldb/trunk/source/Core/AddressRange.cpp Thu Sep  9 20:30:46 2010
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/Core/AddressRange.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Target/Process.h"
 
@@ -144,11 +145,11 @@
     if (process)
       addr_size = process->GetAddressByteSize ();
 
+    bool show_module = false;
     switch (style)
     {
     default:
         break;
-
     case Address::DumpStyleSectionNameOffset:
     case Address::DumpStyleSectionPointerOffset:
         s->PutChar ('[');
@@ -159,6 +160,9 @@
         return true;
         break;
 
+    case Address::DumpStyleModuleWithFileAddress:
+        show_module = true;
+        // fall through
     case Address::DumpStyleFileAddress:
         vmaddr = m_base_addr.GetFileAddress();
         break;
@@ -170,9 +174,19 @@
 
     if (vmaddr != LLDB_INVALID_ADDRESS)
     {
+        if (show_module)
+        {
+            Module *module = GetBaseAddress().GetModule();
+            if (module)
+                s->Printf("%s", module->GetFileSpec().GetFilename().AsCString());
+        }
         s->AddressRange(vmaddr, vmaddr + GetByteSize(), addr_size);
         return true;
     }
+    else if (fallback_style != Address::DumpStyleInvalid)
+    {
+        return Dump(s, process, fallback_style, Address::DumpStyleInvalid);
+    }
 
     return false;
 }

Modified: lldb/trunk/source/Symbol/Block.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=113571&r1=113570&r2=113571&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Block.cpp (original)
+++ lldb/trunk/source/Symbol/Block.cpp Thu Sep  9 20:30:46 2010
@@ -38,6 +38,8 @@
 void
 Block::GetDescription(Stream *s, Function *function, lldb::DescriptionLevel level, Process *process) const
 {
+    *s << "id = " << ((const UserID&)*this);
+
     size_t num_ranges = m_ranges.size();
     if (num_ranges)
     {
@@ -48,12 +50,11 @@
         if (base_addr == LLDB_INVALID_ADDRESS)
             base_addr = function->GetAddressRange().GetBaseAddress().GetFileAddress();
 
-        s->Printf("range%s = ", num_ranges > 1 ? "s" : "");
+        s->Printf(", range%s = ", num_ranges > 1 ? "s" : "");
         std::vector<VMRange>::const_iterator pos, end = m_ranges.end();
         for (pos = m_ranges.begin(); pos != end; ++pos)
             pos->Dump(s, base_addr, 4);
     }
-    *s << ", id = " << ((const UserID&)*this);
 
     if (m_inlineInfoSP.get() != NULL)
         m_inlineInfoSP->Dump(s);

Modified: lldb/trunk/source/Symbol/CompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompileUnit.cpp?rev=113571&r1=113570&r2=113571&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/CompileUnit.cpp (original)
+++ lldb/trunk/source/Symbol/CompileUnit.cpp Thu Sep  9 20:30:46 2010
@@ -68,8 +68,7 @@
 void
 CompileUnit::GetDescription(Stream *s, lldb::DescriptionLevel level) const
 {
-    *s << '"' << (const FileSpec&)*this << "\", id = " << (const UserID&)*this
-        << ", language = " << (const Language&)*this;
+    *s << "id = " << (const UserID&)*this << ", file = \"" << (const FileSpec&)*this << "\", language = \"" << (const Language&)*this << '"';
 }
 
 
@@ -85,8 +84,8 @@
     s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
     s->Indent();
     *s << "CompileUnit" << (const UserID&)*this
-        << ", language = " << (const Language&)*this
-        << ", file='" << (const FileSpec&)*this << "'\n";
+        << ", language = \"" << (const Language&)*this
+        << "\", file = '" << (const FileSpec&)*this << "'\n";
 
 //  m_types.Dump(s);
 

Modified: lldb/trunk/source/Symbol/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=113571&r1=113570&r2=113571&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Function.cpp (original)
+++ lldb/trunk/source/Symbol/Function.cpp Thu Sep  9 20:30:46 2010
@@ -18,6 +18,7 @@
 #include "clang/AST/Type.h"
 #include "clang/AST/CanonicalType.h"
 
+using namespace lldb;
 using namespace lldb_private;
 
 //----------------------------------------------------------------------
@@ -328,9 +329,14 @@
 Function::GetDescription(Stream *s, lldb::DescriptionLevel level, Process *process)
 {
     Type* func_type = GetType();
-    *s << '"' << func_type->GetName() << "\", id = " << (const UserID&)*this;
-    *s << ", range = ";
-    GetAddressRange().Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
+    *s << "id = " << (const UserID&)*this << ", name = \"" << func_type->GetName() << "\", range = ";
+    
+    Address::DumpStyle fallback_style;
+    if (level == eDescriptionLevelVerbose)
+        fallback_style = Address::DumpStyleModuleWithFileAddress;
+    else
+        fallback_style = Address::DumpStyleFileAddress;
+    GetAddressRange().Dump(s, process, Address::DumpStyleLoadAddress, fallback_style);
 }
 
 void

Modified: lldb/trunk/source/Symbol/LineEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineEntry.cpp?rev=113571&r1=113570&r2=113571&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/LineEntry.cpp (original)
+++ lldb/trunk/source/Symbol/LineEntry.cpp Thu Sep  9 20:30:46 2010
@@ -151,20 +151,16 @@
 
     if (level == lldb::eDescriptionLevelBrief || level == lldb::eDescriptionLevelFull)
     {
-        // Show address only
         if (show_address_only)
         {
-            s->PutCString ("address = ");
             range.GetBaseAddress().Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
         }
         else
         {
-            s->PutCString ("range = ");
             range.Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
         }
 
-        if (file)
-            *s << ' ' << file;
+        *s << ": " << file;
 
         if (line)
         {
@@ -173,6 +169,7 @@
                 s->Printf(":%u", column);
         }
 
+
         if (level == lldb::eDescriptionLevelFull)
         {
             if (is_start_of_statement)

Modified: lldb/trunk/source/Symbol/Symbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=113571&r1=113570&r2=113571&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symbol.cpp (original)
+++ lldb/trunk/source/Symbol/Symbol.cpp Thu Sep  9 20:30:46 2010
@@ -175,19 +175,29 @@
 void
 Symbol::GetDescription (Stream *s, lldb::DescriptionLevel level, Process *process) const
 {
-    *s << '"' << m_mangled.GetName() << "\", id = " << (const UserID&)*this;
+    *s << "id = " << (const UserID&)*this << ", name = \"" << m_mangled.GetName() << '"';
     const Section *section = m_addr_range.GetBaseAddress().GetSection();
     if (section != NULL)
     {
-        if (m_addr_range.GetByteSize() > 0)
+        if (m_addr_range.GetBaseAddress().IsSectionOffset())
         {
-            s->PutCString(", range = ");
-            m_addr_range.Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
+            if (m_addr_range.GetByteSize() > 0)
+            {
+                s->PutCString (", range = ");
+                m_addr_range.Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
+            }
+            else 
+            {
+                s->PutCString (", address = ");
+                m_addr_range.GetBaseAddress().Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress);
+            }
         }
         else
         {
-            s->PutCString(", address = ");
-            m_addr_range.GetBaseAddress().Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress);
+            if (m_size_is_sibling)                
+                s->Printf (", sibling = %5llu", m_addr_range.GetBaseAddress().GetOffset());
+            else
+                s->Printf (", value = 0x%16.16llx", m_addr_range.GetBaseAddress().GetOffset());
         }
     }
 }

Modified: lldb/trunk/source/Symbol/SymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=113571&r1=113570&r2=113571&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolContext.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolContext.cpp Thu Sep  9 20:30:46 2010
@@ -198,9 +198,11 @@
 {
     if (module_sp)
     {
-        s->Indent("     Module: \"");
+        s->Indent("     Module: file = \"");
         module_sp->GetFileSpec().Dump(s);
-        s->PutChar('"');
+        *s << '"';
+        if (module_sp->GetArchitecture().IsValid())
+            s->Printf (", arch = \"%s\"", module_sp->GetArchitecture().AsCString());
         s->EOL();
     }
 

Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=113571&r1=113570&r2=113571&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Thu Sep  9 20:30:46 2010
@@ -85,14 +85,11 @@
 void
 lldb_private::Type::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_name)
 {
-    if (show_name)
-    {
-        if (m_name)
-            *s << '\"' << m_name << "\", ";
-    }
-
     *s << "id = " << (const UserID&)*this;
 
+    if (show_name && m_name)
+        *s << ", name = \"" << m_name << '"';
+
     if (m_byte_size != 0)
         s->Printf(", byte-size = %zu", m_byte_size);
 
@@ -100,9 +97,9 @@
 
     if (m_clang_qual_type)
     {
-        *s << ", clang_type = " << m_clang_qual_type << ' ';
-
+        *s << ", clang_type = \"";
         ClangASTType::DumpTypeDescription (GetClangAST(), m_clang_qual_type, s);
+        *s << '"';
     }
     else if (m_encoding_uid != LLDB_INVALID_UID)
     {
@@ -118,7 +115,7 @@
         case eLValueReferenceToTypeWithUID: s->PutCString(" (unresolved L value reference)"); break;
         case eRValueReferenceToTypeWithUID: s->PutCString(" (unresolved R value reference)"); break;
         }
-    }
+    }    
 }
 
 





More information about the lldb-commits mailing list