[Lldb-commits] [lldb] r137541 - in /lldb/trunk: include/lldb/API/SBDebugger.h source/API/SBDebugger.cpp tools/driver/Driver.cpp

Jim Ingham jingham at apple.com
Fri Aug 12 17:22:20 PDT 2011


Author: jingham
Date: Fri Aug 12 19:22:20 2011
New Revision: 137541

URL: http://llvm.org/viewvc/llvm-project?rev=137541&view=rev
Log:
Add a version of SBDebugger::Create which allows us to specify whether to source
in the init files or not.

Modified:
    lldb/trunk/include/lldb/API/SBDebugger.h
    lldb/trunk/source/API/SBDebugger.cpp
    lldb/trunk/tools/driver/Driver.cpp

Modified: lldb/trunk/include/lldb/API/SBDebugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=137541&r1=137540&r2=137541&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDebugger.h (original)
+++ lldb/trunk/include/lldb/API/SBDebugger.h Fri Aug 12 19:22:20 2011
@@ -25,9 +25,13 @@
     static void
     Terminate();
     
+    // Deprecated, use the one that takes a source_init_files bool.
     static lldb::SBDebugger
     Create();
 
+    static lldb::SBDebugger
+    Create(bool source_init_files);
+
     static void
     Destroy (lldb::SBDebugger &debugger);
 

Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=137541&r1=137540&r2=137541&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Fri Aug 12 19:22:20 2011
@@ -71,6 +71,12 @@
 SBDebugger
 SBDebugger::Create()
 {
+    return SBDebugger::Create(true);
+}
+
+SBDebugger
+SBDebugger::Create(bool source_init_files)
+{
     LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     SBDebugger debugger;
@@ -83,6 +89,19 @@
         log->Printf ("SBDebugger::Create () => SBDebugger(%p): %s", debugger.m_opaque_sp.get(), sstr.GetData());
     }
 
+    SBCommandInterpreter interp = debugger.GetCommandInterpreter();
+    if (source_init_files)
+    {
+        interp.get()->SkipLLDBInitFiles(false);
+        interp.get()->SkipAppInitFiles (false);
+        SBCommandReturnObject result;
+        interp.SourceInitFileInHomeDirectory(result);
+    }
+    else
+    {
+        interp.get()->SkipLLDBInitFiles(true);
+        interp.get()->SkipAppInitFiles (true);
+    }
     return debugger;
 }
 

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=137541&r1=137540&r2=137541&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Fri Aug 12 19:22:20 2011
@@ -83,7 +83,7 @@
 
 Driver::Driver () :
     SBBroadcaster ("Driver"),
-    m_debugger (SBDebugger::Create()),
+    m_debugger (SBDebugger::Create(false)),
     m_editline_pty (),
     m_editline_slave_fh (NULL),
     m_editline_reader (),
@@ -478,6 +478,15 @@
         }
     }
 
+    // This is kind of a pain, but since we make the debugger in the Driver's constructor, we can't
+    // know at that point whether we should read in init files yet.  So we don't read them in in the
+    // Driver constructor, then set the flags back to "read them in" here, and then if we see the
+    // "-n" flag, we'll turn it off again.  Finally we have to read them in by hand later in the
+    // main loop.
+    
+    m_debugger.SkipLLDBInitFiles (false);
+    m_debugger.SkipAppInitFiles (false);
+
     // Prepare for & make calls to getopt_long.
 #if __GLIBC__
     optind = 0;
@@ -542,6 +551,7 @@
 
                     case 'n':
                         m_debugger.SkipLLDBInitFiles (true);
+                        m_debugger.SkipAppInitFiles (true);
                         break;
 
                     case 'f':





More information about the lldb-commits mailing list