[Lldb-commits] [lldb] r155404 - in /lldb/trunk: include/lldb/Core/Module.h source/Core/Module.cpp source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Greg Clayton gclayton at apple.com
Mon Apr 23 15:55:20 PDT 2012


Author: gclayton
Date: Mon Apr 23 17:55:20 2012
New Revision: 155404

URL: http://llvm.org/viewvc/llvm-project?rev=155404&view=rev
Log:
Added the ability to log a message with a backtrace when verbose logging is enabled to the Module class. Used this new function in the DWARF parser.


Modified:
    lldb/trunk/include/lldb/Core/Module.h
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=155404&r1=155403&r2=155404&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Mon Apr 23 17:55:20 2012
@@ -1016,6 +1016,9 @@
     void                    
     LogMessage (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
 
+    void                    
+    LogMessageVerboseBacktrace (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
+    
     void
     ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
 

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=155404&r1=155403&r2=155404&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Mon Apr 23 17:55:20 2012
@@ -879,6 +879,24 @@
     }
 }
 
+void
+Module::LogMessageVerboseBacktrace (Log *log, const char *format, ...)
+{
+    if (log)
+    {
+        StreamString log_message;
+        GetDescription(&log_message, lldb::eDescriptionLevelFull);
+        log_message.PutCString (": ");
+        va_list args;
+        va_start (args, format);
+        log_message.PrintfVarArg (format, args);
+        va_end (args);
+        if (log->GetVerbose())
+            Host::Backtrace (log_message, 1024);
+        log->PutCString(log_message.GetString().c_str());
+    }
+}
+
 bool
 Module::GetModified (bool use_cached_only)
 {

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=155404&r1=155403&r2=155404&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Mon Apr 23 17:55:20 2012
@@ -172,9 +172,9 @@
         LogSP log (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO | DWARF_LOG_LOOKUPS));
         if (log)
         {
-            m_dwarf2Data->GetObjectFile()->GetModule()->LogMessage (log.get(), 
-                                                                    "DWARFCompileUnit::ExtractDIEsIfNeeded () for compile unit at .debug_info[0x%8.8x]", 
-                                                                    GetOffset());
+            m_dwarf2Data->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log.get(),
+                                                                                    "DWARFCompileUnit::ExtractDIEsIfNeeded () for compile unit at .debug_info[0x%8.8x]",
+                                                                                    GetOffset());
         }
     }
 

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=155404&r1=155403&r2=155404&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Apr 23 17:55:20 2012
@@ -1995,19 +1995,12 @@
     LogSP log (LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO|DWARF_LOG_TYPE_COMPLETION));
     if (log)
     {
-        GetObjectFile()->GetModule()->LogMessage (log.get(),
-                                                  "0x%8.8llx: %s '%s' resolving forward declaration...", 
-                                                  MakeUserID(die->GetOffset()), 
-                                                  DW_TAG_value_to_name(tag), 
-                                                  type->GetName().AsCString());
-    
-        if (log->GetVerbose())
-        {
-            StreamString strm;
-            Host::Backtrace (strm, 1024);
-            if (strm.GetData())
-                log->PutCString(strm.GetData());
-        }
+        GetObjectFile()->GetModule()->LogMessageVerboseBacktrace (log.get(),
+                                                                  "0x%8.8llx: %s '%s' resolving forward declaration...",
+                                                                  MakeUserID(die->GetOffset()),
+                                                                  DW_TAG_value_to_name(tag),
+                                                                  type->GetName().AsCString());
+    
     }
     assert (clang_type);
     DWARFDebugInfoEntry::Attributes attributes;





More information about the lldb-commits mailing list