Add the ability to disable individual log categories, rather
than just the entire log channel.

Add checks, where appropriate, to make sure a log channel/category has 
not been disabled before attempting to write to it.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@117715 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
index 5a73486..776ffeb 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
@@ -35,7 +35,7 @@
 }
 
 void
-ProcessGDBRemoteLog::DisableLog ()
+ProcessGDBRemoteLog::DeleteLog ()
 {
     if (g_log)
     {
@@ -44,10 +44,53 @@
     }
 }
 
+void
+ProcessGDBRemoteLog::DisableLog (Args &args, Stream *feedback_strm)
+{
+    if (g_log)
+    {
+        uint32_t flag_bits = g_log->GetMask().Get();
+        const size_t argc = args.GetArgumentCount ();
+        for (size_t i = 0; i < argc; ++i)
+        {
+            const char *arg = args.GetArgumentAtIndex (i);
+            
+
+            if      (::strcasecmp (arg, "all")        == 0   ) flag_bits &= ~GDBR_LOG_ALL;
+            else if (::strcasecmp (arg, "async")      == 0   ) flag_bits &= ~GDBR_LOG_ASYNC;
+            else if (::strcasestr (arg, "break")      == arg ) flag_bits &= ~GDBR_LOG_BREAKPOINTS;
+            else if (::strcasestr (arg, "comm")       == arg ) flag_bits &= ~GDBR_LOG_COMM;
+            else if (::strcasecmp (arg, "default")    == 0   ) flag_bits &= ~GDBR_LOG_DEFAULT;
+            else if (::strcasecmp (arg, "packets")    == 0   ) flag_bits &= ~GDBR_LOG_PACKETS;
+            else if (::strcasecmp (arg, "memory")     == 0   ) flag_bits &= ~GDBR_LOG_MEMORY;
+            else if (::strcasecmp (arg, "data-short") == 0   ) flag_bits &= ~GDBR_LOG_MEMORY_DATA_SHORT;
+            else if (::strcasecmp (arg, "data-long")  == 0   ) flag_bits &= ~GDBR_LOG_MEMORY_DATA_LONG;
+            else if (::strcasecmp (arg, "process")    == 0   ) flag_bits &= ~GDBR_LOG_PROCESS;
+            else if (::strcasecmp (arg, "step")       == 0   ) flag_bits &= ~GDBR_LOG_STEP;
+            else if (::strcasecmp (arg, "thread")     == 0   ) flag_bits &= ~GDBR_LOG_THREAD;
+            else if (::strcasecmp (arg, "verbose")    == 0   ) flag_bits &= ~GDBR_LOG_VERBOSE;
+            else if (::strcasestr (arg, "watch")      == arg ) flag_bits &= ~GDBR_LOG_WATCHPOINTS;
+            else
+            {
+                feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+                ListLogCategories (feedback_strm);
+            }
+            
+        }
+        
+        if (flag_bits == 0)
+            DeleteLog();
+        else
+            g_log->GetMask().Reset (flag_bits);
+    }
+    
+    return;
+}
+
 Log *
 ProcessGDBRemoteLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &args, Stream *feedback_strm)
 {
-    DisableLog ();
+    DeleteLog ();
     g_log = new Log (log_stream_sp);
     if (g_log)
     {