<rdar://problem/11757916>

Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file". 
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()

Cleaned up header includes a bit as well.

llvm-svn: 162860
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index fb7272d..5edd368 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -13,7 +13,9 @@
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Section.h"
 #include "lldb/Core/State.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/ObjCLanguageRuntime.h"
@@ -302,6 +304,31 @@
     return is_loaded;
 }
 
+uint32_t
+DynamicLoaderDarwinKernel::OSKextLoadedKextSummary::GetAddressByteSize ()
+{
+    if (module_sp)
+        return module_sp->GetArchitecture().GetAddressByteSize();
+    return 0;
+}
+
+lldb::ByteOrder
+DynamicLoaderDarwinKernel::OSKextLoadedKextSummary::GetByteOrder()
+{
+    if (module_sp)
+        return module_sp->GetArchitecture().GetByteOrder();
+    return lldb::endian::InlHostByteOrder();
+}
+
+lldb_private::ArchSpec
+DynamicLoaderDarwinKernel::OSKextLoadedKextSummary::GetArchitecture () const
+{
+    if (module_sp)
+        return module_sp->GetArchitecture();
+    return lldb_private::ArchSpec ();
+}
+
+
 //----------------------------------------------------------------------
 // Load the kernel module and initialize the "m_kernel" member. Return
 // true _only_ if the kernel is loaded the first time through (subsequent
@@ -826,3 +853,25 @@
     return 1;
 }
 
+lldb::ByteOrder
+DynamicLoaderDarwinKernel::GetByteOrderFromMagic (uint32_t magic)
+{
+    switch (magic)
+    {
+        case llvm::MachO::HeaderMagic32:
+        case llvm::MachO::HeaderMagic64:
+            return lldb::endian::InlHostByteOrder();
+            
+        case llvm::MachO::HeaderMagic32Swapped:
+        case llvm::MachO::HeaderMagic64Swapped:
+            if (lldb::endian::InlHostByteOrder() == lldb::eByteOrderBig)
+                return lldb::eByteOrderLittle;
+            else
+                return lldb::eByteOrderBig;
+            
+        default:
+            break;
+    }
+    return lldb::eByteOrderInvalid;
+}
+
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
index 005f5ea..9a6f90f 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
@@ -119,26 +119,8 @@
     }
 
     static lldb::ByteOrder
-    GetByteOrderFromMagic (uint32_t magic)
-    {
-        switch (magic)
-        {
-            case llvm::MachO::HeaderMagic32:
-            case llvm::MachO::HeaderMagic64:
-                return lldb::endian::InlHostByteOrder();
+    GetByteOrderFromMagic (uint32_t magic);
 
-            case llvm::MachO::HeaderMagic32Swapped:
-            case llvm::MachO::HeaderMagic64Swapped:
-                if (lldb::endian::InlHostByteOrder() == lldb::eByteOrderBig)
-                    return lldb::eByteOrderLittle;
-                else
-                    return lldb::eByteOrderBig;
-
-            default:
-                break;
-        }
-        return lldb::eByteOrderInvalid;
-    }
     enum
     {
         KERNEL_MODULE_MAX_NAME = 64u,
@@ -229,28 +211,13 @@
         }
 
         uint32_t
-        GetAddressByteSize ()
-        {
-            if (module_sp)
-                return module_sp->GetArchitecture().GetAddressByteSize();
-            return 0;
-        }
+        GetAddressByteSize ();
 
         lldb::ByteOrder
-        GetByteOrder()
-        {
-            if (module_sp)
-                return module_sp->GetArchitecture().GetByteOrder();
-            return lldb::endian::InlHostByteOrder();
-        }
+        GetByteOrder();
 
         lldb_private::ArchSpec
-        GetArchitecture () const
-        {
-            if (module_sp)
-                return module_sp->GetArchitecture();
-            return lldb_private::ArchSpec ();
-        }
+        GetArchitecture () const;
 
         void
         PutToLog (lldb_private::Log *log) const;
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index bc87588..5504c64 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -15,8 +15,11 @@
 #include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Section.h"
 #include "lldb/Core/State.h"
+#include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/RegisterContext.h"
@@ -1771,3 +1774,50 @@
     return 1;
 }
 
+uint32_t
+DynamicLoaderMacOSXDYLD::AddrByteSize()
+{
+    switch (m_dyld.header.magic)
+    {
+        case llvm::MachO::HeaderMagic32:
+        case llvm::MachO::HeaderMagic32Swapped:
+            return 4;
+            
+        case llvm::MachO::HeaderMagic64:
+        case llvm::MachO::HeaderMagic64Swapped:
+            return 8;
+            
+        default:
+            break;
+    }
+    return 0;
+}
+
+lldb::ByteOrder
+DynamicLoaderMacOSXDYLD::GetByteOrderFromMagic (uint32_t magic)
+{
+    switch (magic)
+    {
+        case llvm::MachO::HeaderMagic32:
+        case llvm::MachO::HeaderMagic64:
+            return lldb::endian::InlHostByteOrder();
+            
+        case llvm::MachO::HeaderMagic32Swapped:
+        case llvm::MachO::HeaderMagic64Swapped:
+            if (lldb::endian::InlHostByteOrder() == lldb::eByteOrderBig)
+                return lldb::eByteOrderLittle;
+            else
+                return lldb::eByteOrderBig;
+            
+        default:
+            break;
+    }
+    return lldb::eByteOrderInvalid;
+}
+
+lldb::ByteOrder
+DynamicLoaderMacOSXDYLD::DYLDImageInfo::GetByteOrder()
+{
+    return DynamicLoaderMacOSXDYLD::GetByteOrderFromMagic(header.magic);
+}
+
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
index 9e7ec75..f7e9ac5 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
@@ -118,45 +118,10 @@
                          lldb::user_id_t break_loc_id);
 
     uint32_t
-    AddrByteSize()
-    {
-        switch (m_dyld.header.magic)
-        {
-            case llvm::MachO::HeaderMagic32:
-            case llvm::MachO::HeaderMagic32Swapped:
-                return 4;
-
-            case llvm::MachO::HeaderMagic64:
-            case llvm::MachO::HeaderMagic64Swapped:
-                return 8;
-
-            default:
-                break;
-        }
-        return 0;
-    }
+    AddrByteSize();
 
     static lldb::ByteOrder
-    GetByteOrderFromMagic (uint32_t magic)
-    {
-        switch (magic)
-        {
-            case llvm::MachO::HeaderMagic32:
-            case llvm::MachO::HeaderMagic64:
-                return lldb::endian::InlHostByteOrder();
-
-            case llvm::MachO::HeaderMagic32Swapped:
-            case llvm::MachO::HeaderMagic64Swapped:
-                if (lldb::endian::InlHostByteOrder() == lldb::eByteOrderBig)
-                    return lldb::eByteOrderLittle;
-                else
-                    return lldb::eByteOrderBig;
-
-            default:
-                break;
-        }
-        return lldb::eByteOrderInvalid;
-    }
+    GetByteOrderFromMagic (uint32_t magic);
 
     bool
     ReadMachHeader (lldb::addr_t addr,
@@ -269,26 +234,7 @@
         }
 
         lldb::ByteOrder
-        GetByteOrder()
-        {
-            switch (header.magic)
-            {
-            case llvm::MachO::HeaderMagic32:        // MH_MAGIC
-            case llvm::MachO::HeaderMagic64:        // MH_MAGIC_64
-                return lldb::endian::InlHostByteOrder();
-
-            case llvm::MachO::HeaderMagic32Swapped: // MH_CIGAM
-            case llvm::MachO::HeaderMagic64Swapped: // MH_CIGAM_64
-                if (lldb::endian::InlHostByteOrder() == lldb::eByteOrderLittle)
-                    return lldb::eByteOrderBig;
-                else
-                    return lldb::eByteOrderLittle;
-            default:
-                assert (!"invalid header.magic value");
-                break;
-            }
-            return lldb::endian::InlHostByteOrder();
-        }
+        GetByteOrder();
 
         lldb_private::ArchSpec
         GetArchitecture () const
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index ee64332..404f4b1 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -13,6 +13,7 @@
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index b863f11..251590f 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -12,6 +12,10 @@
 // Other libraries and framework includes
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
diff --git a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
index ef79001..9b15ea8 100644
--- a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
@@ -9,6 +9,8 @@
 
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/Target.h"
 
 #include "DynamicLoaderStatic.h"