CommandObjectProcess was recently changed to automatically use the platform
to launch a process for debugging. Since this isn't supported on all platforms,
we need to do what we used to do if this isn't supported. I added:

    bool
    Platform::CanDebugProcess ();
    
This will get checked before trying to launch a process for debugging and then
fall back to launching the process through the current host debugger. This
should solve the issue for linux and keep the platform code clean.

Centralized logging code for logging errors, warnings and logs when reporting
things for modules or symbol files. Both lldb_private::Module and 
lldb_private::SymbolFile now have the following member functions:

    void                    
    LogMessage (Log *log, const char *format, ...);

    void
    ReportWarning (const char *format, ...);

    void
    ReportError (const char *format, ...);

These will all output the module name and object (if any) such as:

    "error: lldb.so ...."
    "warning: my_archive.a(foo.o) ...."
    
This will keep the output consistent and stop a lot of logging calls from 
having to try and output all of the information that uniquely identifies
a module or symbol file. Many places in the code were grabbing the path to the
object file manually and if the module represented a .o file in an archive, we
would see log messages like:

    error: foo.a - some error happened



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@145219 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index 16f4b9e..0400dfb 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -257,11 +257,23 @@
             if (!m_options.launch_info.GetArchitecture().IsValid())
                 m_options.launch_info.GetArchitecture() = target->GetArchitecture();
 
-            process = target->GetPlatform()->DebugProcess (m_options.launch_info, 
-                                                           debugger,
-                                                           target,
-                                                           debugger.GetListener(),
-                                                           error).get();
+            PlatformSP platform_sp (target->GetPlatform());
+            
+            if (platform_sp && platform_sp->CanDebugProcess ())
+            {
+                process = target->GetPlatform()->DebugProcess (m_options.launch_info, 
+                                                               debugger,
+                                                               target,
+                                                               debugger.GetListener(),
+                                                               error).get();
+            }
+            else
+            {
+                const char *plugin_name = m_options.launch_info.GetProcessPluginName();
+                process = target->CreateProcess (debugger.GetListener(), plugin_name).get();
+                if (process)
+                    error = process->Launch (m_options.launch_info);
+            }
 
             if (process == NULL)
             {
diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp
index 64677e0..cfe61ef 100644
--- a/source/Core/Module.cpp
+++ b/source/Core/Module.cpp
@@ -11,6 +11,7 @@
 #include "lldb/Core/Log.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/StreamString.h"
 #include "lldb/Core/Timer.h"
 #include "lldb/lldb-private-log.h"
 #include "lldb/Symbol/ObjectFile.h"
@@ -578,16 +579,28 @@
 }
 
 void
-Module::GetDescription (Stream *s)
+Module::GetDescription (Stream *s, lldb::DescriptionLevel level)
 {
     Mutex::Locker locker (m_mutex);
 
-    if (m_arch.IsValid())
-        s->Printf("(%s) ", m_arch.GetArchitectureName());
+    if (level >= eDescriptionLevelFull)
+    {
+        if (m_arch.IsValid())
+            s->Printf("(%s) ", m_arch.GetArchitectureName());
+    }
 
-    char path[PATH_MAX];
-    if (m_file.GetPath(path, sizeof(path)))
-        s->PutCString(path);
+    if (level == eDescriptionLevelBrief)
+    {
+        const char *filename = m_file.GetFilename().GetCString();
+        if (filename)
+            s->PutCString (filename);
+    }
+    else
+    {
+        char path[PATH_MAX];
+        if (m_file.GetPath(path, sizeof(path)))
+            s->PutCString(path);
+    }
 
     const char *object_name = m_object_name.GetCString();
     if (object_name)
@@ -595,6 +608,48 @@
 }
 
 void
+Module::ReportError (const char *format, ...)
+{
+    StreamString module_description;
+    GetDescription(&module_description, lldb::eDescriptionLevelBrief);
+    ::fprintf (stderr, "error: %s ", module_description.GetString().c_str());
+    
+    va_list args;
+    va_start (args, format);
+    vfprintf (stderr, format, args);
+    va_end (args);
+}
+
+void
+Module::ReportWarning (const char *format, ...)
+{
+    StreamString module_description;
+    GetDescription(&module_description, lldb::eDescriptionLevelBrief);
+    ::fprintf (stderr, "warning: %s ", module_description.GetString().c_str());
+    
+    va_list args;
+    va_start (args, format);
+    vfprintf (stderr, format, args);
+    va_end (args);
+}
+
+void
+Module::LogMessage (Log *log, const char *format, ...)
+{
+    if (log)
+    {
+        StreamString log_message;
+        GetDescription(&log_message, lldb::eDescriptionLevelBrief);
+        log_message.PutCString (": ");
+        va_list args;
+        va_start (args, format);
+        log_message.PrintfVarArg (format, args);
+        va_end (args);
+        log->PutCString(log_message.GetString().c_str());
+    }
+}
+
+void
 Module::Dump(Stream *s)
 {
     Mutex::Locker locker (m_mutex);
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index 096710c..e8b0e6b 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -10,6 +10,7 @@
 #include "DWARFCompileUnit.h"
 
 #include "lldb/Core/Mangled.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/Stream.h"
 #include "lldb/Core/Timer.h"
 #include "lldb/Symbol/ObjectFile.h"
@@ -164,14 +165,16 @@
 
     DWARFDebugInfoEntry die;
         // Keep a flat array of the DIE for binary lookup by DIE offset
-//    Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
-//        if (log)
-//            log->Printf("0x%8.8x: Compile Unit: length = 0x%8.8x, version = 0x%4.4x, abbr_offset = 0x%8.8x, addr_size = 0x%2.2x",
-//                        cu->GetOffset(),
-//                        cu->GetLength(),
-//                        cu->GetVersion(),
-//                        cu->GetAbbrevOffset(),
-//                        cu->GetAddressByteSize());
+    if (!cu_die_only)
+    {
+        LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
+        if (log)
+        {
+            m_dwarf2Data->LogMessage (log.get(), 
+                                      "DWARFCompileUnit::ExtractDIEsIfNeeded () for compile unit at .debug_info[0x%8.8x]", 
+                                      GetOffset());
+        }
+    }
 
     uint32_t depth = 0;
     // We are in our compile unit, parse starting at the offset
@@ -263,13 +266,9 @@
     // unit header).
     if (offset > next_cu_offset)
     {
-        char path[PATH_MAX];
-        ObjectFile *objfile = m_dwarf2Data->GetObjectFile();
-        if (objfile)
-        {
-            objfile->GetFileSpec().GetPath(path, sizeof(path));
-        }
-        fprintf (stderr, "warning: DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x in '%s'\n", GetOffset(), offset, path);
+        m_dwarf2Data->ReportWarning ("DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x\n", 
+                                     GetOffset(), 
+                                     offset);
     }
 
     // Since std::vector objects will double their size, we really need to
@@ -282,7 +281,7 @@
         DWARFDebugInfoEntry::collection exact_size_die_array (m_die_array.begin(), m_die_array.end());
         exact_size_die_array.swap (m_die_array);
     }
-    LogSP log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_DEBUG_INFO));
+    LogSP log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_DEBUG_INFO | DWARF_LOG_VERBOSE));
     if (log)
     {
         StreamString strm;
@@ -404,10 +403,11 @@
         LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
 
         if (log)
-            log->Printf ("DWARFCompileUnit::GetFunctionAranges() for \"%s/%s\" compile unit at 0x%8.8x",
-                         m_dwarf2Data->GetObjectFile()->GetFileSpec().GetDirectory().GetCString(),
-                         m_dwarf2Data->GetObjectFile()->GetFileSpec().GetFilename().GetCString(),
-                         m_offset);
+        {
+            m_dwarf2Data->LogMessage (log.get(), 
+                                      "DWARFCompileUnit::GetFunctionAranges() for compile unit at .debug_info[0x%8.8x]",
+                                      GetOffset());
+        }
         DIE()->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get());
         const bool minimize = false;
         m_func_aranges_ap->Sort(minimize);
@@ -573,6 +573,15 @@
 
     const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize());
 
+    LogSP log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_LOOKUPS));
+    
+    if (log)
+    {
+        m_dwarf2Data->LogMessage (log.get(), 
+                                  "DWARFCompileUnit::Index() for compile unit at .debug_info[0x%8.8x]",
+                                  GetOffset());
+    }
+
     DWARFDebugInfoEntry::const_iterator pos;
     DWARFDebugInfoEntry::const_iterator begin = m_die_array.begin();
     DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 20bac6b..7f4a17e 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -92,6 +92,15 @@
 }
 
 uint64_t
+DWARFDebugInfoEntry::Attributes::FormValueAsUnsigned (SymbolFileDWARF* dwarf2Data, dw_attr_t attr, uint64_t fail_value) const
+{
+    const uint32_t attr_idx = FindAttributeIndex (attr);
+    if (attr_idx != UINT32_MAX)
+        return FormValueAsUnsignedAtIndex (dwarf2Data, attr_idx, fail_value);
+    return fail_value;
+}
+
+uint64_t
 DWARFDebugInfoEntry::Attributes::FormValueAsUnsignedAtIndex(SymbolFileDWARF* dwarf2Data, uint32_t i, uint64_t fail_value) const
 {
     DWARFFormValue form_value;
@@ -1713,6 +1722,152 @@
 }
 
 
+const DWARFDebugInfoEntry *
+DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, 
+											  DWARFCompileUnit* cu) const
+{
+	DWARFDebugInfoEntry::Attributes attributes;
+	GetAttributes(dwarf2Data, cu, NULL, attributes);
+	return GetParentDeclContextDIE (dwarf2Data, cu, attributes);
+}
+
+const DWARFDebugInfoEntry *
+DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, 
+											  DWARFCompileUnit* cu,
+											  const DWARFDebugInfoEntry::Attributes& attributes) const
+{
+	const DWARFDebugInfoEntry * die = this;
+	
+	while (die != NULL)
+	{
+		// If this is the original DIE that we are searching for a declaration 
+		// for, then don't look in the cache as we don't want our own decl 
+		// context to be our decl context...
+		if (die != this)
+		{            
+			switch (die->Tag())
+			{
+				case DW_TAG_compile_unit:
+				case DW_TAG_namespace:
+				case DW_TAG_structure_type:
+				case DW_TAG_union_type:
+				case DW_TAG_class_type:
+					return die;
+					
+				default:
+					break;
+			}
+		}
+		
+		dw_offset_t die_offset;
+        
+		die_offset = attributes.FormValueAsUnsigned(dwarf2Data, DW_AT_specification, DW_INVALID_OFFSET);
+		if (die_offset != DW_INVALID_OFFSET)
+		{
+			const DWARFDebugInfoEntry *spec_die = cu->GetDIEPtr (die_offset);
+			if (spec_die)
+			{
+				const DWARFDebugInfoEntry *spec_die_decl_ctx_die = spec_die->GetParentDeclContextDIE (dwarf2Data, cu);
+				if (spec_die_decl_ctx_die)
+					return spec_die_decl_ctx_die;
+			}
+		}
+		
+        die_offset = attributes.FormValueAsUnsigned(dwarf2Data, DW_AT_abstract_origin, DW_INVALID_OFFSET);
+		if (die_offset != DW_INVALID_OFFSET)
+		{
+			const DWARFDebugInfoEntry *abs_die = cu->GetDIEPtr (die_offset);
+			if (abs_die)
+			{
+				const DWARFDebugInfoEntry *abs_die_decl_ctx_die = abs_die->GetParentDeclContextDIE (dwarf2Data, cu);
+				if (abs_die_decl_ctx_die)
+					return abs_die_decl_ctx_die;
+			}
+		}
+		
+		die = die->GetParent();
+	}
+    return NULL;
+}
+
+
+const char *
+DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data, 
+									   DWARFCompileUnit* cu,
+									   std::string &storage) const
+{
+	DWARFDebugInfoEntry::Attributes attributes;
+	GetAttributes(dwarf2Data, cu, NULL, attributes);
+	return GetQualifiedName (dwarf2Data, cu, attributes, storage);
+}
+
+const char*
+DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data, 
+									   DWARFCompileUnit* cu,
+									   const DWARFDebugInfoEntry::Attributes& attributes,
+									   std::string &storage) const
+{
+	
+	const char *name = GetName (dwarf2Data, cu);
+	
+	if (name)
+	{
+		const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
+		storage.clear();
+		// TODO: change this to get the correct decl context parent....
+		while (parent_decl_ctx_die)
+		{
+			const dw_tag_t parent_tag = parent_decl_ctx_die->Tag();
+			switch (parent_tag)
+			{
+                case DW_TAG_namespace:
+				{
+					const char *namespace_name = parent_decl_ctx_die->GetName (dwarf2Data, cu);
+					if (namespace_name)
+					{
+						storage.insert (0, "::");
+						storage.insert (0, namespace_name);
+					}
+					else
+					{
+						storage.insert (0, "(anonymous namespace)::");
+					}
+					parent_decl_ctx_die = parent_decl_ctx_die->GetParentDeclContextDIE(dwarf2Data, cu);
+				}
+                    break;
+					
+                case DW_TAG_class_type:
+                case DW_TAG_structure_type:
+                case DW_TAG_union_type:
+				{
+					const char *class_union_struct_name = parent_decl_ctx_die->GetName (dwarf2Data, cu);
+                    
+					if (class_union_struct_name)
+					{
+						storage.insert (0, "::");
+						storage.insert (0, class_union_struct_name);
+					}
+					parent_decl_ctx_die = parent_decl_ctx_die->GetParentDeclContextDIE(dwarf2Data, cu);
+				}
+                    break;
+                    
+                default:
+                    parent_decl_ctx_die = NULL;
+                    break;
+			}
+		}
+		
+		if (storage.empty())
+			storage.append ("::");
+        
+		storage.append (name);
+	}
+	if (storage.empty())
+		return NULL;
+	return storage.c_str();
+}
+
+
 //----------------------------------------------------------------------
 // LookupAddress
 //----------------------------------------------------------------------
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
index f97ad88..350e4de 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -68,6 +68,7 @@
         dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].form; }
         bool ExtractFormValueAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, DWARFFormValue &form_value) const;
         uint64_t FormValueAsUnsignedAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, uint64_t fail_value) const;
+        uint64_t FormValueAsUnsigned (SymbolFileDWARF* dwarf2Data, dw_attr_t attr, uint64_t fail_value) const;
         uint32_t FindAttributeIndex(dw_attr_t attr) const;
         bool ContainsAttribute(dw_attr_t attr) const;
         bool RemoveAttribute(dw_attr_t attr);
@@ -226,6 +227,17 @@
                     const dw_offset_t die_offset,
                     lldb_private::Stream &s);
 
+    const char * GetQualifiedName (
+                    SymbolFileDWARF* dwarf2Data, 
+                    DWARFCompileUnit* cu,
+                    std::string &storage) const;
+    
+    const char * GetQualifiedName (
+                    SymbolFileDWARF* dwarf2Data, 
+                    DWARFCompileUnit* cu,
+                    const DWARFDebugInfoEntry::Attributes& attributes,
+                    std::string &storage) const;
+
 //    static int  Compare(
 //                    SymbolFileDWARF* dwarf2Data,
 //                    dw_offset_t a_die_offset,
@@ -340,6 +352,13 @@
             DWARFDebugInfoEntry*    GetFirstChild()         { return (HasChildren() && !m_empty_children) ? this + 1 : NULL; }
     const   DWARFDebugInfoEntry*    GetFirstChild() const   { return (HasChildren() && !m_empty_children) ? this + 1 : NULL; }
 
+    
+    const   DWARFDebugInfoEntry*    GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, 
+                                                             DWARFCompileUnit* cu) const;
+    const   DWARFDebugInfoEntry*    GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, 
+                                                             DWARFCompileUnit* cu, 
+                                                             const DWARFDebugInfoEntry::Attributes& attributes) const;
+
     void        
     SetParent (DWARFDebugInfoEntry* parent)     
     {
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 08772c6..f386a17 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2273,10 +2273,12 @@
 
     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);
+        LogMessage (log.get(), 
+                    "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", namespace_decl=%p, append=%u, max_matches=%u, variables)", 
+                    name.GetCString(), 
+                    namespace_decl,
+                    append, 
+                    max_matches);
     }
     
     if (!NamespaceDeclMatchesThisSymbolFile(namespace_decl))
@@ -2369,10 +2371,11 @@
     
     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);
+        LogMessage (log.get(), 
+                    "SymbolFileDWARF::FindGlobalVariables (regex=\"%s\", append=%u, max_matches=%u, variables)", 
+                    regex.GetText(), 
+                    append, 
+                    max_matches);
     }
 
     DWARFDebugInfo* info = DebugInfo();
@@ -2649,10 +2652,11 @@
     
     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);
+        LogMessage (log.get(), 
+                    "SymbolFileDWARF::FindFunctions (name=\"%s\", name_type_mask=0x%x, append=%u, sc_list)", 
+                    name.GetCString(), 
+                    name_type_mask, 
+                    append);
     }
 
     // If we aren't appending the results to this list, then clear the list
@@ -2922,10 +2926,10 @@
     
     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);
+        LogMessage (log.get(), 
+                    "SymbolFileDWARF::FindFunctions (regex=\"%s\", append=%u, sc_list)", 
+                     regex.GetText(), 
+                    append);
     }
     
 
@@ -2957,40 +2961,6 @@
     return sc_list.GetSize() - original_size;
 }
 
-void
-SymbolFileDWARF::ReportError (const char *format, ...)
-{
-    ::fprintf (stderr, 
-               "error: %s/%s ", 
-               m_obj_file->GetFileSpec().GetDirectory().GetCString(),
-               m_obj_file->GetFileSpec().GetFilename().GetCString());
-
-    if (m_obj_file->GetModule()->GetObjectName())
-        ::fprintf (stderr, "(%s) ", m_obj_file->GetModule()->GetObjectName().GetCString());
-
-    va_list args;
-    va_start (args, format);
-    vfprintf (stderr, format, args);
-    va_end (args);
-}
-
-void
-SymbolFileDWARF::ReportWarning (const char *format, ...)
-{
-    ::fprintf (stderr, 
-               "warning: %s/%s ", 
-               m_obj_file->GetFileSpec().GetDirectory().GetCString(),
-               m_obj_file->GetFileSpec().GetFilename().GetCString());
-
-    if (m_obj_file->GetModule()->GetObjectName())
-        ::fprintf (stderr, "(%s) ", m_obj_file->GetModule()->GetObjectName().GetCString());
-
-    va_list args;
-    va_start (args, format);
-    vfprintf (stderr, format, args);
-    va_end (args);
-}
-
 uint32_t
 SymbolFileDWARF::FindTypes(const SymbolContext& sc, const ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, TypeList& types)
 {
@@ -3002,10 +2972,11 @@
     
     if (log)
     {
-        log->Printf ("SymbolFileDWARF::FindTypes (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);
+        LogMessage (log.get(), 
+                    "SymbolFileDWARF::FindTypes (sc, name=\"%s\", append=%u, max_matches=%u, type_list)", 
+                    name.GetCString(), 
+                    append, 
+                    max_matches);
     }
 
     // If we aren't appending the results to this list, then clear the list
@@ -3086,9 +3057,8 @@
     
     if (log)
     {
-        log->Printf ("SymbolFileDWARF::FindNamespace (file=\"%s/%s\", sc, name=\"%s\")", 
-                     m_obj_file->GetFileSpec().GetDirectory().GetCString(),
-                     m_obj_file->GetFileSpec().GetFilename().GetCString(),
+        LogMessage (log.get(), 
+                    "SymbolFileDWARF::FindNamespace (sc, name=\"%s\")", 
                      name.GetCString());
     }
     
@@ -3635,33 +3605,24 @@
             LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
             if (log)
             {
-                const char *object_name = m_obj_file->GetModule()->GetObjectName().GetCString();
                 if (namespace_name)
                 {
-                    log->Printf ("ASTContext => %p: 0x%8.8llx: DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl * %p in %s/%s%s%s%s (original = %p)", 
+                    LogMessage (log.get(), 
+                                "ASTContext => %p: 0x%8.8llx: DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl *%p (original = %p)", 
                                  GetClangASTContext().getASTContext(),
                                  MakeUserID(die->GetOffset()),
                                  namespace_name,
                                  namespace_decl,
-                                 m_obj_file->GetFileSpec().GetDirectory().GetCString(),
-                                 m_obj_file->GetFileSpec().GetFilename().GetCString(),
-                                 object_name ? "(" : "",
-                                 object_name ? object_name : "",
-                                 object_name ? "(" : "",
                                  namespace_decl->getOriginalNamespace());
                 }
                 else
                 {
-                    log->Printf ("ASTContext => %p: 0x%8.8llx: DW_TAG_namespace (anonymous) => clang::NamespaceDecl * %p in %s/%s%s%s%s (original = %p)", 
-                                 GetClangASTContext().getASTContext(),
-                                 MakeUserID(die->GetOffset()),
-                                 namespace_decl,
-                                 m_obj_file->GetFileSpec().GetDirectory().GetCString(),
-                                 m_obj_file->GetFileSpec().GetFilename().GetCString(),
-                                 object_name ? "(" : "",
-                                 object_name ? object_name : "",
-                                 object_name ? "(" : "",
-                                 namespace_decl->getOriginalNamespace());
+                    LogMessage (log.get(),
+                                "ASTContext => %p: 0x%8.8llx: DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p (original = %p)", 
+                                GetClangASTContext().getASTContext(),
+                                MakeUserID(die->GetOffset()),
+                                namespace_decl,
+                                namespace_decl->getOriginalNamespace());
                 }
             }
 
@@ -4196,6 +4157,15 @@
                         // current type index just in case we have a forward
                         // declaration followed by an actual declarations in the
                         // DWARF. If this fails, we need to look elsewhere...
+                        if (log)
+                        {
+                            LogMessage (log.get(), 
+                                        "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is forward declaration, trying to find real type", 
+                                        this,
+                                        die->GetOffset(), 
+                                        DW_TAG_value_to_name(tag),
+                                        type_name_cstr);
+                        }
                     
                         type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str);
 
@@ -4209,6 +4179,16 @@
 
                         if (type_sp)
                         {
+                            if (log)
+                            {
+                                log->Printf ("SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is forward declaration, real type is 0x%8.8llx", 
+                                             this,
+                                             die->GetOffset(), 
+                                             DW_TAG_value_to_name(tag),
+                                             type_name_cstr,
+                                             type_sp->GetID());
+                            }
+
                             // We found a real definition for this type elsewhere
                             // so lets use it and cache the fact that we found
                             // a complete type for this die
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index afbd102..cc4cf55 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -456,11 +456,6 @@
                             const lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos);
 
 
-    void
-    ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-    void
-    ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
-    
     SymbolFileDWARFDebugMap *       m_debug_map_symfile;
     clang::TranslationUnitDecl *    m_clang_tu_decl;
     lldb_private::Flags             m_flags;
diff --git a/source/Symbol/SymbolFile.cpp b/source/Symbol/SymbolFile.cpp
index e729ac3..da10763 100644
--- a/source/Symbol/SymbolFile.cpp
+++ b/source/Symbol/SymbolFile.cpp
@@ -7,10 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/lldb-private.h"
 #include "lldb/Symbol/SymbolFile.h"
+
+#include "lldb/lldb-private.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamString.h"
 #include "lldb/Symbol/ObjectFile.h"
 
 using namespace lldb_private;
@@ -68,3 +71,45 @@
     return m_obj_file->GetModule()->GetClangASTContext();
 }
 
+
+void
+SymbolFile::ReportError (const char *format, ...)
+{
+    StreamString module_description;
+    m_obj_file->GetModule()->GetDescription (&module_description, lldb::eDescriptionLevelBrief);
+    ::fprintf (stderr, "error: %s ", module_description.GetString().c_str());
+    
+    va_list args;
+    va_start (args, format);
+    vfprintf (stderr, format, args);
+    va_end (args);
+}
+
+void
+SymbolFile::ReportWarning (const char *format, ...)
+{
+    StreamString module_description;
+    m_obj_file->GetModule()->GetDescription (&module_description, lldb::eDescriptionLevelBrief);
+    ::fprintf (stderr, "warning: %s ", module_description.GetString().c_str());
+    
+    va_list args;
+    va_start (args, format);
+    vfprintf (stderr, format, args);
+    va_end (args);
+}
+
+void
+SymbolFile::LogMessage (Log *log, const char *format, ...)
+{
+    if (log)
+    {
+        StreamString log_message;
+        m_obj_file->GetModule()->GetDescription (&log_message, lldb::eDescriptionLevelBrief);
+        log_message.PutChar(' ');
+        va_list args;
+        va_start (args, format);
+        log_message.PrintfVarArg (format, args);
+        va_end (args);
+        log->PutCString (log_message.GetString().c_str());
+    }
+}