[Lldb-commits] [lldb] r116179 - in /lldb/trunk: include/lldb/API/SBDebugger.h include/lldb/Interpreter/CommandInterpreter.h source/API/SBDebugger.cpp source/Commands/CommandObjectBreakpoint.cpp source/Interpreter/CommandInterpreter.cpp tools/driver/Driver.cpp

Greg Clayton gclayton at apple.com
Sun Oct 10 18:05:37 PDT 2010


Author: gclayton
Date: Sun Oct 10 20:05:37 2010
New Revision: 116179

URL: http://llvm.org/viewvc/llvm-project?rev=116179&view=rev
Log:
Added a "--no-lldbinit" option (-n for short (which magically matches
what gdb uses)) so we can tell our "lldb" driver program to not automatically
parse any .lldbinit files. 


Modified:
    lldb/trunk/include/lldb/API/SBDebugger.h
    lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
    lldb/trunk/source/API/SBDebugger.cpp
    lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
    lldb/trunk/source/Interpreter/CommandInterpreter.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=116179&r1=116178&r2=116179&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBDebugger.h (original)
+++ lldb/trunk/include/lldb/API/SBDebugger.h Sun Oct 10 20:05:37 2010
@@ -42,6 +42,9 @@
     SetAsync (bool b);
 
     void
+    SkipLLDBInitFiles (bool b);
+
+    void
     SetInputFileHandle (FILE *f, bool transfer_ownership);
 
     void

Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=116179&r1=116178&r2=116179&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Sun Oct 10 20:05:37 2010
@@ -202,6 +202,12 @@
     ScriptInterpreter *
     GetScriptInterpreter ();
 
+    void
+    SkipLLDBInitFiles (bool skip_lldbinit_files)
+    {
+        m_skip_lldbinit_files = skip_lldbinit_files;
+    }
+
     bool
     GetSynchronous ();
 
@@ -239,6 +245,7 @@
 
     Debugger &m_debugger;   // The debugger session that this interpreter is associated with
     bool m_synchronous_execution;
+    bool m_skip_lldbinit_files;
     CommandObject::CommandMap m_command_dict; // Stores basic built-in commands (they cannot be deleted, removed or overwritten).
     CommandObject::CommandMap m_alias_dict;   // Stores user aliases/abbreviations for commands
     CommandObject::CommandMap m_user_dict;    // Stores user-defined commands

Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=116179&r1=116178&r2=116179&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Sun Oct 10 20:05:37 2010
@@ -10,11 +10,6 @@
 #include "lldb/API/SBDebugger.h"
 
 #include "lldb/lldb-include.h"
-#include "lldb/Interpreter/Args.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/State.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/TargetList.h"
 
 #include "lldb/API/SBListener.h"
 #include "lldb/API/SBBroadcaster.h"
@@ -29,6 +24,12 @@
 #include "lldb/API/SBStringList.h"
 #include "lldb/API/SBTarget.h"
 #include "lldb/API/SBThread.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/State.h"
+#include "lldb/Interpreter/Args.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/TargetList.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -82,6 +83,13 @@
         m_opaque_sp->SetAsyncExecution(b);
 }
 
+void
+SBDebugger::SkipLLDBInitFiles (bool b)
+{
+    if (m_opaque_sp)
+        m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles (b);
+}
+
 // Shouldn't really be settable after initialization as this could cause lots of problems; don't want users
 // trying to switch modes in the middle of a debugging session.
 void

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=116179&r1=116178&r2=116179&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Sun Oct 10 20:05:37 2010
@@ -309,78 +309,79 @@
     switch (break_type)
     {
         case eSetTypeFileAndLine: // Breakpoint by source position
-        {
-            FileSpec file;
-            if (m_options.m_filename.empty())
             {
-                StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame;
-                if (cur_frame == NULL)
-                {
-                    result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame.");
-                    result.SetStatus (eReturnStatusFailed);
-                    break;
-                }
-                else if (!cur_frame->HasDebugInformation())
-                {
-                    result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info.");
-                    result.SetStatus (eReturnStatusFailed);
-                    break;
-                }
-                else
+                FileSpec file;
+                if (m_options.m_filename.empty())
                 {
-                    const SymbolContext &context = cur_frame->GetSymbolContext(true);
-                    if (context.line_entry.file)
+                    StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame;
+                    if (cur_frame == NULL)
                     {
-                        file = context.line_entry.file;
-                    }
-                    else if (context.comp_unit != NULL)
-                    {    file = context.comp_unit;
+                        result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame.");
+                        result.SetStatus (eReturnStatusFailed);
+                        break;
                     }
-                    else
+                    else if (!cur_frame->HasDebugInformation())
                     {
-                        result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame.");
+                        result.AppendError ("Attempting to set breakpoint by line number alone but selected frame has no debug info.");
                         result.SetStatus (eReturnStatusFailed);
                         break;
                     }
+                    else
+                    {
+                        const SymbolContext &context = cur_frame->GetSymbolContext(true);
+                        if (context.line_entry.file)
+                        {
+                            file = context.line_entry.file;
+                        }
+                        else if (context.comp_unit != NULL)
+                        {    file = context.comp_unit;
+                        }
+                        else
+                        {
+                            result.AppendError ("Attempting to set breakpoint by line number alone but can't find the file for the selected frame.");
+                            result.SetStatus (eReturnStatusFailed);
+                            break;
+                        }
+                    }
+                }
+                else
+                {
+                    file.SetFile(m_options.m_filename.c_str());
                 }
-            }
-            else
-            {
-                file.SetFile(m_options.m_filename.c_str());
-            }
 
-            if (use_module)
-            {
-                for (int i = 0; i < num_modules; ++i)
+                if (use_module)
                 {
-                    module.SetFile(m_options.m_modules[i].c_str());
-                    bp = target->CreateBreakpoint (&module,
-                                                   file,
-                                                   m_options.m_line_num,
-                                                   m_options.m_ignore_inlines).get();
-                    if (bp)
-                    {
-                        StreamString &output_stream = result.GetOutputStream();
-                        output_stream.Printf ("Breakpoint created: ");
-                        bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
-                        output_stream.EOL();
-                        result.SetStatus (eReturnStatusSuccessFinishResult);
-                    }
-                    else
+                    for (int i = 0; i < num_modules; ++i)
                     {
-                        result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n",
-                                                    m_options.m_modules[i].c_str());
-                        result.SetStatus (eReturnStatusFailed);
+                        module.SetFile(m_options.m_modules[i].c_str());
+                        bp = target->CreateBreakpoint (&module,
+                                                       file,
+                                                       m_options.m_line_num,
+                                                       m_options.m_ignore_inlines).get();
+                        if (bp)
+                        {
+                            StreamString &output_stream = result.GetOutputStream();
+                            output_stream.Printf ("Breakpoint created: ");
+                            bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
+                            output_stream.EOL();
+                            result.SetStatus (eReturnStatusSuccessFinishResult);
+                        }
+                        else
+                        {
+                            result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n",
+                                                        m_options.m_modules[i].c_str());
+                            result.SetStatus (eReturnStatusFailed);
+                        }
                     }
                 }
+                else
+                    bp = target->CreateBreakpoint (NULL,
+                                                   file,
+                                                   m_options.m_line_num,
+                                                   m_options.m_ignore_inlines).get();
             }
-            else
-                bp = target->CreateBreakpoint (NULL,
-                                               file,
-                                               m_options.m_line_num,
-                                               m_options.m_ignore_inlines).get();
-        }
-        break;
+            break;
+
         case eSetTypeAddress: // Breakpoint by address
             bp = target->CreateBreakpoint (m_options.m_load_addr, false).get();
             break;

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=116179&r1=116178&r2=116179&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Sun Oct 10 20:05:37 2010
@@ -59,7 +59,8 @@
 ) :
     Broadcaster ("CommandInterpreter"),
     m_debugger (debugger),
-    m_synchronous_execution (synchronous_execution)
+    m_synchronous_execution (synchronous_execution),
+    m_skip_lldbinit_files (false)
 {
     const char *dbg_name = debugger.GetInstanceName().AsCString();
     std::string lang_name = ScriptInterpreter::LanguageToString (script_language);
@@ -1060,6 +1061,10 @@
 void
 CommandInterpreter::SourceInitFile (bool in_cwd, CommandReturnObject &result)
 {
+    // Don't parse any .lldbinit files if we were asked not to
+    if (m_skip_lldbinit_files)
+        return;
+
     const char *init_file_path = in_cwd ? "./.lldbinit" : "~/.lldbinit";
     FileSpec init_file (init_file_path);
     // If the file exists, tell HandleCommand to 'source' it; this will do the actual broadcasting

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=116179&r1=116178&r2=116179&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Sun Oct 10 20:05:37 2010
@@ -75,6 +75,9 @@
     { LLDB_OPT_SET_ALL,  false,  "editor",           'e',  no_argument,  NULL,  NULL,  eArgTypeNone,
         "Tells the debugger to open source files using the host's \"external editor\" mechanism." },
 
+    { LLDB_OPT_SET_ALL,  false,  "no-lldbinit",           'n',  no_argument,  NULL,  NULL,  eArgTypeNone,
+        "Do not automatically parse any '.lldbinit' files." },
+
 //    { LLDB_OPT_SET_4,  true,  "crash-log",      'c',  required_argument,  NULL,  NULL,  eArgTypeFilename,
 //        "Load executable images from a crash log for symbolication." },
 
@@ -554,10 +557,15 @@
                     case 'c':
                         m_option_data.m_crash_log = optarg;
                         break;
+
                     case 'e':
                         m_option_data.m_use_external_editor = true;
                         break;
-                        
+
+                    case 'n':
+                        m_debugger.SkipLLDBInitFiles (true);
+                        break;
+
                     case 'f':
                         {
                             SBFileSpec file(optarg);





More information about the lldb-commits mailing list