[Lldb-commits] [lldb] r253538 - I like how PlatformAndroid/PlatformLinux log when their platforms

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 18 19:15:37 PST 2015


Author: jmolenda
Date: Wed Nov 18 21:15:37 2015
New Revision: 253538

URL: http://llvm.org/viewvc/llvm-project?rev=253538&view=rev
Log:
I like how PlatformAndroid/PlatformLinux log when their platforms
try to CreateInstance, and log the results.  I copied that for the
Mac platforms.


Modified:
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp?rev=253538&r1=253537&r2=253538&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp Wed Nov 18 21:15:37 2015
@@ -16,6 +16,7 @@
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -68,6 +69,20 @@ PlatformAppleTVSimulator::Terminate ()
 PlatformSP
 PlatformAppleTVSimulator::CreateInstance (bool force, const ArchSpec *arch)
 {
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+    if (log)
+    {
+        const char *arch_name;
+        if (arch && arch->GetArchitectureName ())
+            arch_name = arch->GetArchitectureName ();
+        else
+            arch_name = "<null>";
+
+        const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+
+        log->Printf ("PlatformAppleTVSimulator::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+    }
+
     bool create = force;
     if (create == false && arch && arch->IsValid())
     {
@@ -121,7 +136,16 @@ PlatformAppleTVSimulator::CreateInstance
         }
     }
     if (create)
+    {
+        if (log)
+            log->Printf ("PlatformAppleTVSimulator::%s() creating platform", __FUNCTION__);
+
         return PlatformSP(new PlatformAppleTVSimulator ());
+    }
+
+    if (log)
+        log->Printf ("PlatformAppleTVSimulator::%s() aborting creation of platform", __FUNCTION__);
+
     return PlatformSP();
 }
 

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp?rev=253538&r1=253537&r2=253538&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp Wed Nov 18 21:15:37 2015
@@ -16,6 +16,7 @@
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -68,6 +69,20 @@ PlatformAppleWatchSimulator::Terminate (
 PlatformSP
 PlatformAppleWatchSimulator::CreateInstance (bool force, const ArchSpec *arch)
 {
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+    if (log)
+    {
+        const char *arch_name;
+        if (arch && arch->GetArchitectureName ())
+            arch_name = arch->GetArchitectureName ();
+        else
+            arch_name = "<null>";
+
+        const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+
+        log->Printf ("PlatformAppleWatchSimulator::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+    }
+
     bool create = force;
     if (create == false && arch && arch->IsValid())
     {
@@ -121,7 +136,16 @@ PlatformAppleWatchSimulator::CreateInsta
         }
     }
     if (create)
+    {
+        if (log)
+            log->Printf ("PlatformAppleWatchSimulator::%s() creating platform", __FUNCTION__);
+
         return PlatformSP(new PlatformAppleWatchSimulator ());
+    }
+
+    if (log)
+        log->Printf ("PlatformAppleWatchSimulator::%s() aborting creation of platform", __FUNCTION__);
+
     return PlatformSP();
 }
 

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp?rev=253538&r1=253537&r2=253538&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp Wed Nov 18 21:15:37 2015
@@ -19,6 +19,7 @@
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -79,11 +80,29 @@ PlatformDarwinKernel::Terminate ()
 PlatformSP
 PlatformDarwinKernel::CreateInstance (bool force, const ArchSpec *arch)
 {
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+    if (log)
+    {
+        const char *arch_name;
+        if (arch && arch->GetArchitectureName ())
+            arch_name = arch->GetArchitectureName ();
+        else
+            arch_name = "<null>";
+
+        const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+
+        log->Printf ("PlatformDarwinKernel::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+    }
+
     // This is a special plugin that we don't want to activate just based on an ArchSpec for normal
     // userland debugging.  It is only useful in kernel debug sessions and the DynamicLoaderDarwinPlugin
     // (or a user doing 'platform select') will force the creation of this Platform plugin.
     if (force == false)
+    {
+        if (log)
+            log->Printf ("PlatformDarwinKernel::%s() aborting creation of platform because force == false", __FUNCTION__);
         return PlatformSP();
+    }
 
     bool create = force;
     LazyBool is_ios_debug_session = eLazyBoolCalculate;
@@ -150,7 +169,16 @@ PlatformDarwinKernel::CreateInstance (bo
         }
     }
     if (create)
+    {
+        if (log)
+            log->Printf ("PlatformDarwinKernel::%s() creating platform", __FUNCTION__);
+
         return PlatformSP(new PlatformDarwinKernel (is_ios_debug_session));
+    }
+
+    if (log)
+        log->Printf ("PlatformDarwinKernel::%s() aborting creation of platform", __FUNCTION__);
+
     return PlatformSP();
 }
 

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=253538&r1=253537&r2=253538&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Wed Nov 18 21:15:37 2015
@@ -19,6 +19,7 @@
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Error.h"
 #include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -73,6 +74,20 @@ PlatformMacOSX::Terminate ()
 PlatformSP
 PlatformMacOSX::CreateInstance (bool force, const ArchSpec *arch)
 {
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+    if (log)
+    {
+        const char *arch_name;
+        if (arch && arch->GetArchitectureName ())
+            arch_name = arch->GetArchitectureName ();
+        else
+            arch_name = "<null>";
+
+        const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+
+        log->Printf ("PlatformMacOSX::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+    }
+
     // The only time we create an instance is when we are creating a remote
     // macosx platform
     const bool is_host = false;
@@ -121,7 +136,15 @@ PlatformMacOSX::CreateInstance (bool for
         }
     }
     if (create)
+    {
+        if (log)
+            log->Printf ("PlatformMacOSX::%s() creating platform", __FUNCTION__);
         return PlatformSP(new PlatformMacOSX (is_host));
+    }
+
+    if (log)
+        log->Printf ("PlatformMacOSX::%s() aborting creation of platform", __FUNCTION__);
+
     return PlatformSP();
 }
 

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp?rev=253538&r1=253537&r2=253538&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp Wed Nov 18 21:15:37 2015
@@ -19,6 +19,7 @@
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -107,6 +108,20 @@ PlatformRemoteAppleTV::Terminate ()
 PlatformSP
 PlatformRemoteAppleTV::CreateInstance (bool force, const ArchSpec *arch)
 {
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+    if (log)
+    {
+        const char *arch_name;
+        if (arch && arch->GetArchitectureName ())
+            arch_name = arch->GetArchitectureName ();
+        else
+            arch_name = "<null>";
+
+        const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+
+        log->Printf ("PlatformRemoteAppleTV::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+    }
+
     bool create = force;
     if (!create && arch && arch->IsValid())
     {
@@ -164,7 +179,16 @@ PlatformRemoteAppleTV::CreateInstance (b
     }
 
     if (create)
+    {
+        if (log)
+            log->Printf ("PlatformRemoteAppleTV::%s() creating platform", __FUNCTION__);
+
         return lldb::PlatformSP(new PlatformRemoteAppleTV ());
+    }
+
+    if (log)
+        log->Printf ("PlatformRemoteAppleTV::%s() aborting creation of platform", __FUNCTION__);
+
     return lldb::PlatformSP();
 }
 

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp?rev=253538&r1=253537&r2=253538&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp Wed Nov 18 21:15:37 2015
@@ -19,6 +19,7 @@
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -107,6 +108,20 @@ PlatformRemoteAppleWatch::Terminate ()
 PlatformSP
 PlatformRemoteAppleWatch::CreateInstance (bool force, const ArchSpec *arch)
 {
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+    if (log)
+    {
+        const char *arch_name;
+        if (arch && arch->GetArchitectureName ())
+            arch_name = arch->GetArchitectureName ();
+        else
+            arch_name = "<null>";
+
+        const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+
+        log->Printf ("PlatformRemoteAppleWatch::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+    }
+
     bool create = force;
     if (!create && arch && arch->IsValid())
     {
@@ -172,7 +187,16 @@ PlatformRemoteAppleWatch::CreateInstance
 #endif
 
     if (create)
+    {
+        if (log)
+            log->Printf ("PlatformRemoteAppleWatch::%s() creating platform", __FUNCTION__);
+
         return lldb::PlatformSP(new PlatformRemoteAppleWatch ());
+    }
+
+    if (log)
+        log->Printf ("PlatformRemoteAppleWatch::%s() aborting creation of platform", __FUNCTION__);
+
     return lldb::PlatformSP();
 }
 

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp?rev=253538&r1=253537&r2=253538&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp Wed Nov 18 21:15:37 2015
@@ -91,6 +91,20 @@ PlatformRemoteiOS::Terminate ()
 PlatformSP
 PlatformRemoteiOS::CreateInstance (bool force, const ArchSpec *arch)
 {
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+    if (log)
+    {
+        const char *arch_name;
+        if (arch && arch->GetArchitectureName ())
+            arch_name = arch->GetArchitectureName ();
+        else
+            arch_name = "<null>";
+
+        const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+
+        log->Printf ("PlatformRemoteiOS::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+    }
+
     bool create = force;
     if (create == false && arch && arch->IsValid())
     {
@@ -149,7 +163,16 @@ PlatformRemoteiOS::CreateInstance (bool
     }
 
     if (create)
+    {
+        if (log)
+            log->Printf ("PlatformRemoteiOS::%s() creating platform", __FUNCTION__);
+
         return lldb::PlatformSP(new PlatformRemoteiOS ());
+    }
+
+    if (log)
+        log->Printf ("PlatformRemoteiOS::%s() aborting creation of platform", __FUNCTION__);
+
     return lldb::PlatformSP();
 }
 

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp?rev=253538&r1=253537&r2=253538&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp Wed Nov 18 21:15:37 2015
@@ -16,6 +16,7 @@
 #include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/ModuleSpec.h"
@@ -68,6 +69,20 @@ PlatformiOSSimulator::Terminate ()
 PlatformSP
 PlatformiOSSimulator::CreateInstance (bool force, const ArchSpec *arch)
 {
+    Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+    if (log)
+    {
+        const char *arch_name;
+        if (arch && arch->GetArchitectureName ())
+            arch_name = arch->GetArchitectureName ();
+        else
+            arch_name = "<null>";
+
+        const char *triple_cstr = arch ? arch->GetTriple ().getTriple ().c_str() : "<null>";
+
+        log->Printf ("PlatformiOSSimulator::%s(force=%s, arch={%s,%s})", __FUNCTION__, force ? "true" : "false", arch_name, triple_cstr);
+    }
+
     bool create = force;
     if (create == false && arch && arch->IsValid())
     {
@@ -124,7 +139,16 @@ PlatformiOSSimulator::CreateInstance (bo
         }
     }
     if (create)
+    {
+        if (log)
+            log->Printf ("PlatformiOSSimulator::%s() creating platform", __FUNCTION__);
+
         return PlatformSP(new PlatformiOSSimulator ());
+    }
+
+    if (log)
+        log->Printf ("PlatformiOSSimulator::%s() aborting creation of platform", __FUNCTION__);
+
     return PlatformSP();
 }
 




More information about the lldb-commits mailing list