[Lldb-commits] [lldb] r222599 - Make the sourcing of the local .lldbinit file quiet.

Jim Ingham jingham at apple.com
Fri Nov 21 17:33:22 PST 2014


Author: jingham
Date: Fri Nov 21 19:33:22 2014
New Revision: 222599

URL: http://llvm.org/viewvc/llvm-project?rev=222599&view=rev
Log:
Make the sourcing of the local .lldbinit file quiet.

<rdar://problem/19065278>

Modified:
    lldb/trunk/tools/driver/Driver.cpp
    lldb/trunk/tools/driver/Driver.h

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=222599&r1=222598&r2=222599&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Fri Nov 21 19:33:22 2014
@@ -438,7 +438,8 @@ Driver::OptionData::Clear ()
     {
         char path[2048];
         local_lldbinit.GetPath(path, 2047);
-        m_after_file_commands.push_back (std::pair<bool, std::string> (true, path));
+        InitialCmdEntry entry(path, true, true);
+        m_after_file_commands.push_back (entry);
     }
     
     m_debug_mode = false;
@@ -456,9 +457,9 @@ Driver::OptionData::Clear ()
 }
 
 void
-Driver::OptionData::AddInitialCommand (const char *command, CommandPlacement placement, bool is_file, SBError &error)
+Driver::OptionData::AddInitialCommand (const char *command, CommandPlacement placement, bool is_file,  bool silent, SBError &error)
 {
-    std::vector<std::pair<bool, std::string> > *command_set;
+    std::vector<InitialCmdEntry> *command_set;
     switch (placement)
     {
     case eCommandPlacementBeforeFile:
@@ -476,19 +477,18 @@ Driver::OptionData::AddInitialCommand (c
     {
         SBFileSpec file(command);
         if (file.Exists())
-            command_set->push_back (std::pair<bool, std::string> (true, optarg));
+            command_set->push_back (InitialCmdEntry(command, is_file, silent));
         else if (file.ResolveExecutableLocation())
         {
             char final_path[PATH_MAX];
             file.GetPath (final_path, sizeof(final_path));
-            std::string path_str (final_path);
-            command_set->push_back (std::pair<bool, std::string> (true, path_str));
+            command_set->push_back (InitialCmdEntry(final_path, is_file, silent));
         }
         else
             error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg);
     }
     else
-        command_set->push_back (std::pair<bool, std::string> (false, optarg));
+        command_set->push_back (InitialCmdEntry(command, is_file, silent));
 }
 
 void
@@ -522,7 +522,7 @@ Driver::GetScriptLanguage() const
 void
 Driver::WriteCommandsForSourcing (CommandPlacement placement, SBStream &strm)
 {
-    std::vector<std::pair<bool, std::string> > *command_set;
+    std::vector<OptionData::InitialCmdEntry> *command_set;
     switch (placement)
     {
     case eCommandPlacementBeforeFile:
@@ -536,11 +536,14 @@ Driver::WriteCommandsForSourcing (Comman
         break;
     }
     
-    for (const auto &command_pair : *command_set)
+    for (const auto &command_entry : *command_set)
     {
-        const char *command = command_pair.second.c_str();
-        if (command_pair.first)
-            strm.Printf("command source -s %i '%s'\n", m_option_data.m_source_quietly, command);
+        const char *command = command_entry.contents.c_str();
+        if (command_entry.is_file)
+        {
+            bool source_quietly = m_option_data.m_source_quietly || command_entry.source_quietly;
+            strm.Printf("command source -s %i '%s'\n", source_quietly, command);
+        }
         else
             strm.Printf("%s\n", command);
     }
@@ -748,10 +751,10 @@ Driver::ParseArgs (int argc, const char
                         break;
 
                     case 'K':
-                        m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterCrash, true, error);
+                        m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterCrash, true, true, error);
                         break;
                     case 'k':
-                        m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterCrash, false, error);
+                        m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterCrash, false, true, error);
                         break;
 
                     case 'n':
@@ -772,16 +775,16 @@ Driver::ParseArgs (int argc, const char
                         }
                         break;
                     case 's':
-                        m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile, true, error);
+                        m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile, true, true, error);
                         break;
                     case 'o':
-                        m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile, false, error);
+                        m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile, false, true, error);
                         break;
                     case 'S':
-                        m_option_data.AddInitialCommand(optarg, eCommandPlacementBeforeFile, true, error);
+                        m_option_data.AddInitialCommand(optarg, eCommandPlacementBeforeFile, true, true, error);
                         break;
                     case 'O':
-                        m_option_data.AddInitialCommand(optarg, eCommandPlacementBeforeFile, false, error);
+                        m_option_data.AddInitialCommand(optarg, eCommandPlacementBeforeFile, false, true, error);
                         break;
                     default:
                         m_option_data.m_print_help = true;

Modified: lldb/trunk/tools/driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.h?rev=222599&r1=222598&r2=222599&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.h (original)
+++ lldb/trunk/tools/driver/Driver.h Fri Nov 21 19:33:22 2014
@@ -75,17 +75,30 @@ public:
         Clear();
 
         void
-        AddInitialCommand (const char *command, CommandPlacement placement, bool is_file, lldb::SBError &error);
+        AddInitialCommand (const char *command, CommandPlacement placement, bool is_file, bool quietly, lldb::SBError &error);
     
         //static OptionDefinition m_cmd_option_table[];
 
+        struct InitialCmdEntry
+        {
+            InitialCmdEntry (const char *in_contents, bool in_is_file, bool in_quiet = false) :
+                contents (in_contents),
+                is_file  (in_is_file),
+                source_quietly(in_quiet)
+            {}
+
+            std::string contents;
+            bool        is_file;
+            bool        source_quietly;
+        };
+
         std::vector<std::string> m_args;
         lldb::ScriptLanguage m_script_lang;
         std::string m_core_file;
         std::string m_crash_log;
-        std::vector<std::pair<bool,std::string> > m_initial_commands;
-        std::vector<std::pair<bool,std::string> > m_after_file_commands;
-        std::vector<std::pair<bool,std::string> > m_after_crash_commands;
+        std::vector<InitialCmdEntry> m_initial_commands;
+        std::vector<InitialCmdEntry> m_after_file_commands;
+        std::vector<InitialCmdEntry> m_after_crash_commands;
         bool m_debug_mode;
         bool m_source_quietly;
         bool m_print_version;





More information about the lldb-commits mailing list