[Lldb-commits] [lldb] r141259 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: DWARFCompileUnit.cpp DWARFDebugAranges.cpp DWARFDebugInfo.cpp DWARFDebugLine.cpp DWARFDebugPubnames.cpp LogChannelDWARF.cpp LogChannelDWARF.h SymbolFileDWARF.cpp

Greg Clayton gclayton at apple.com
Wed Oct 5 17:09:08 PDT 2011


Author: gclayton
Date: Wed Oct  5 19:09:08 2011
New Revision: 141259

URL: http://llvm.org/viewvc/llvm-project?rev=141259&view=rev
Log:
Added a new logging channel to the DWARF called "lookups":

(lldb) log enable dwarf lookups

This allows us to see when lookups are being done on functions, addresses,
and types by both name and regular expresssion.


Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=141259&r1=141258&r2=141259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Wed Oct  5 19:09:08 2011
@@ -24,6 +24,7 @@
 #include "NameToDIE.h"
 #include "SymbolFileDWARF.h"
 
+using namespace lldb;
 using namespace lldb_private;
 using namespace std;
 
@@ -353,7 +354,7 @@
     if (m_func_aranges_ap.get() == NULL)
     {
         m_func_aranges_ap.reset (new DWARFDebugAranges());
-        Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES);
+        LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
 
         if (log)
             log->Printf ("DWARFCompileUnit::GetFunctionAranges() for \"%s/%s\" compile unit at 0x%8.8x",

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp?rev=141259&r1=141258&r2=141259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Wed Oct  5 19:09:08 2011
@@ -23,6 +23,7 @@
 #include "DWARFDebugInfo.h"
 #include "DWARFCompileUnit.h"
 
+using namespace lldb;
 using namespace lldb_private;
 
 //----------------------------------------------------------------------
@@ -261,12 +262,12 @@
     Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p",
                        __PRETTY_FUNCTION__, this);
 
-    Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES);
+    LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
     const size_t orig_arange_size = m_aranges.size();
     if (log)
     {
         log->Printf ("DWARFDebugAranges::Sort(minimize = %u, n = %u) with %zu entries", minimize, n, orig_arange_size);
-        Dump (log);
+        Dump (log.get());
     }
 
     // Size of one? If so, no sorting is needed
@@ -331,7 +332,7 @@
         size_t delta = orig_arange_size - m_aranges.size();
         log->Printf ("DWARFDebugAranges::Sort() %zu entries after minimizing (%zu entries combined for %zu bytes saved)", 
                      m_aranges.size(), delta, delta * sizeof(Range));
-        Dump (log);
+        Dump (log.get());
     }
 }
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=141259&r1=141258&r2=141259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Wed Oct  5 19:09:08 2011
@@ -24,6 +24,7 @@
 #include "DWARFFormValue.h"
 #include "LogChannelDWARF.h"
 
+using namespace lldb;
 using namespace lldb_private;
 using namespace std;
 
@@ -53,7 +54,7 @@
 {
     if (m_cu_aranges_ap.get() == NULL && m_dwarf2Data)
     {
-        Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES);
+        LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
 
         m_cu_aranges_ap.reset (new DWARFDebugAranges());
         const DataExtractor &debug_aranges_data = m_dwarf2Data->get_debug_aranges_data();

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp?rev=141259&r1=141258&r2=141259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp Wed Oct  5 19:09:08 2011
@@ -19,6 +19,7 @@
 #include "SymbolFileDWARF.h"
 #include "LogChannelDWARF.h"
 
+using namespace lldb;
 using namespace lldb_private;
 using namespace std;
 
@@ -560,7 +561,7 @@
     void* userData
 )
 {
-    Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_LINE);
+    LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_LINE));
     Prologue::shared_ptr prologue(new Prologue());
 
 
@@ -580,11 +581,11 @@
     }
 
     if (log)
-        prologue->Dump (log);
+        prologue->Dump (log.get());
 
     const dw_offset_t end_offset = debug_line_offset + prologue->total_length + sizeof(prologue->total_length);
 
-    State state(prologue, log, callback, userData);
+    State state(prologue, log.get(), callback, userData);
 
     while (*offset_ptr < end_offset)
     {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp?rev=141259&r1=141258&r2=141259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp Wed Oct  5 19:09:08 2011
@@ -20,6 +20,7 @@
 #include "SymbolFileDWARF.h"
 
 
+using namespace lldb;
 using namespace lldb_private;
 
 DWARFDebugPubnames::DWARFDebugPubnames() :
@@ -33,7 +34,7 @@
     Timer scoped_timer (__PRETTY_FUNCTION__,
                         "DWARFDebugPubnames::Extract (byte_size = %zu)",
                         data.GetByteSize());
-    Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES);
+    LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES));
     if (log)
         log->Printf("DWARFDebugPubnames::Extract (byte_size = %zu)", data.GetByteSize());
 
@@ -53,7 +54,7 @@
                 break;
         }
         if (log)
-            Dump (log);
+            Dump (log.get());
         return true;
     }
     return false;
@@ -67,7 +68,7 @@
                         "DWARFDebugPubnames::GeneratePubnames (data = %p)",
                         dwarf2Data);
 
-    Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES);
+    LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES));
     if (log)
         log->Printf("DWARFDebugPubnames::GeneratePubnames (data = %p)", dwarf2Data);
 
@@ -207,7 +208,7 @@
     if (m_sets.empty())
         return false;
     if (log)
-        Dump (log);
+        Dump (log.get());
     return true;
 }
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp?rev=141259&r1=141258&r2=141259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp Wed Oct  5 19:09:08 2011
@@ -109,6 +109,7 @@
         else if (::strcasecmp (arg, "pubnames")   == 0   ) flag_bits &= ~DWARF_LOG_DEBUG_PUBNAMES;
         else if (::strcasecmp (arg, "pubtypes")   == 0   ) flag_bits &= ~DWARF_LOG_DEBUG_PUBTYPES;
         else if (::strcasecmp (arg, "aranges")    == 0   ) flag_bits &= ~DWARF_LOG_DEBUG_ARANGES;
+        else if (::strcasecmp (arg, "lookups")    == 0   ) flag_bits &= ~DWARF_LOG_LOOKUPS;
         else if (::strcasecmp (arg, "default")    == 0   ) flag_bits &= ~DWARF_LOG_DEFAULT;
         else
         {
@@ -151,6 +152,7 @@
         else if (::strcasecmp (arg, "pubnames")   == 0   ) flag_bits |= DWARF_LOG_DEBUG_PUBNAMES;
         else if (::strcasecmp (arg, "pubtypes")   == 0   ) flag_bits |= DWARF_LOG_DEBUG_PUBTYPES;
         else if (::strcasecmp (arg, "aranges")    == 0   ) flag_bits |= DWARF_LOG_DEBUG_ARANGES;
+        else if (::strcasecmp (arg, "lookups")    == 0   ) flag_bits |= DWARF_LOG_LOOKUPS;
         else if (::strcasecmp (arg, "default")    == 0   ) flag_bits |= DWARF_LOG_DEFAULT;
         else
         {
@@ -177,29 +179,29 @@
                   "  info - log the parsing if .debug_info\n"
                   "  line - log the parsing if .debug_line\n"
                   "  pubnames - log the parsing if .debug_pubnames\n"
-                  "  pubtypes - log the parsing if .debug_pubtypes\n\n",
+                  "  pubtypes - log the parsing if .debug_pubtypes\n"
+                  "  lookups - log any lookups that happen by name, regex, or address\n\n",
                   SymbolFileDWARF::GetPluginNameStatic());
 }
 
-Log *
+LogSP
 LogChannelDWARF::GetLog ()
 {
     if (g_log_channel)
-        return g_log_channel->m_log_sp.get();
-    else
-        return NULL;
+        return g_log_channel->m_log_sp;
+
+    return LogSP();
 }
 
-Log *
+LogSP
 LogChannelDWARF::GetLogIfAll (uint32_t mask)
 {
-    Log *log = GetLog();
-    if (log)
+    if (g_log_channel && g_log_channel->m_log_sp)
     {
-        if (log->GetMask().AllSet(mask))
-            return log;
+        if (g_log_channel->m_log_sp->GetMask().AllSet(mask))
+            return g_log_channel->m_log_sp;
     }
-    return NULL;
+    return LogSP();
 }
 
 

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h?rev=141259&r1=141258&r2=141259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h Wed Oct  5 19:09:08 2011
@@ -23,6 +23,7 @@
 #define DWARF_LOG_DEBUG_PUBNAMES    (1u << 3)
 #define DWARF_LOG_DEBUG_PUBTYPES    (1u << 4)
 #define DWARF_LOG_DEBUG_ARANGES     (1u << 5)
+#define DWARF_LOG_LOOKUPS           (1u << 6)
 #define DWARF_LOG_ALL               (UINT32_MAX)
 #define DWARF_LOG_DEFAULT           (DWARF_LOG_DEBUG_INFO)
 
@@ -73,10 +74,10 @@
     virtual void
     ListCategories (lldb_private::Stream *strm);
 
-    static lldb_private::Log *
+    static lldb::LogSP
     GetLog ();
 
-    static lldb_private::Log *
+    static lldb::LogSP
     GetLogIfAll (uint32_t mask);
 
     static void

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=141259&r1=141258&r2=141259&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Oct  5 19:09:08 2011
@@ -1943,6 +1943,15 @@
 uint32_t
 SymbolFileDWARF::FindGlobalVariables (const ConstString &name, bool append, uint32_t max_matches, VariableList& variables)
 {
+    LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
+
+    if (log)
+    {
+        log->Printf ("SymbolFileDWARF::FindGlobalVariables (file=\"%s/%s\", name=\"%s\", append=%u, max_matches=%u, variables)", 
+                     m_obj_file->GetFileSpec().GetDirectory().GetCString(),
+                     m_obj_file->GetFileSpec().GetFilename().GetCString(),
+                     name.GetCString(), append, max_matches);
+    }
     DWARFDebugInfo* info = DebugInfo();
     if (info == NULL)
         return 0;
@@ -2007,6 +2016,16 @@
 uint32_t
 SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables)
 {
+    LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
+    
+    if (log)
+    {
+        log->Printf ("SymbolFileDWARF::FindGlobalVariables (file=\"%s/%s\", regex=\"%s\", append=%u, max_matches=%u, variables)", 
+                     m_obj_file->GetFileSpec().GetDirectory().GetCString(),
+                     m_obj_file->GetFileSpec().GetFilename().GetCString(),
+                     regex.GetText(), append, max_matches);
+    }
+
     DWARFDebugInfo* info = DebugInfo();
     if (info == NULL)
         return 0;
@@ -2267,6 +2286,16 @@
                         "SymbolFileDWARF::FindFunctions (name = '%s')",
                         name.AsCString());
 
+    LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
+    
+    if (log)
+    {
+        log->Printf ("SymbolFileDWARF::FindFunctions (file=\"%s/%s\", name=\"%s\", name_type_mask=0x%x, append=%u, sc_list)", 
+                     m_obj_file->GetFileSpec().GetDirectory().GetCString(),
+                     m_obj_file->GetFileSpec().GetFilename().GetCString(),
+                     name.GetCString(), name_type_mask, append);
+    }
+
     // If we aren't appending the results to this list, then clear the list
     if (!append)
         sc_list.Clear();
@@ -2315,6 +2344,17 @@
                         "SymbolFileDWARF::FindFunctions (regex = '%s')",
                         regex.GetText());
 
+    LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
+    
+    if (log)
+    {
+        log->Printf ("SymbolFileDWARF::FindFunctions (file=\"%s/%s\", regex=\"%s\"append=%u, sc_list)", 
+                     m_obj_file->GetFileSpec().GetDirectory().GetCString(),
+                     m_obj_file->GetFileSpec().GetFilename().GetCString(),
+                     regex.GetText(), append);
+    }
+    
+
     // If we aren't appending the results to this list, then clear the list
     if (!append)
         sc_list.Clear();
@@ -2383,6 +2423,16 @@
     if (info == NULL)
         return 0;
 
+    LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
+    
+    if (log)
+    {
+        log->Printf ("SymbolFileDWARF::FindFunctions (file=\"%s/%s\", sc, name=\"%s\", append=%u, max_matches=%u, type_list)", 
+                     m_obj_file->GetFileSpec().GetDirectory().GetCString(),
+                     m_obj_file->GetFileSpec().GetFilename().GetCString(),
+                     name.GetCString(), append, max_matches);
+    }
+
     // If we aren't appending the results to this list, then clear the list
     if (!append)
         types.Clear();
@@ -2447,6 +2497,16 @@
 SymbolFileDWARF::FindNamespace (const SymbolContext& sc, 
                                 const ConstString &name)
 {
+    LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
+    
+    if (log)
+    {
+        log->Printf ("SymbolFileDWARF::FindNamespace (file=\"%s/%s\", sc, name=\"%s\")", 
+                     m_obj_file->GetFileSpec().GetDirectory().GetCString(),
+                     m_obj_file->GetFileSpec().GetFilename().GetCString(),
+                     name.GetCString());
+    }
+
     ClangNamespaceDecl namespace_decl;
     DWARFDebugInfo* info = DebugInfo();
     if (info)
@@ -3206,7 +3266,7 @@
     AccessType accessibility = eAccessNone;
     if (die != NULL)
     {
-        Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+        LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
         if (log && dwarf_cu)
         {
             StreamString s;





More information about the lldb-commits mailing list