[Lldb-commits] [lldb] r155665 - in /lldb/trunk: include/lldb/Core/Debugger.h source/Core/Debugger.cpp tools/driver/Driver.cpp

Jim Ingham jingham at apple.com
Thu Apr 26 14:39:32 PDT 2012


Author: jingham
Date: Thu Apr 26 16:39:32 2012
New Revision: 155665

URL: http://llvm.org/viewvc/llvm-project?rev=155665&view=rev
Log:
Don't call SBDebugger::SetInternalVariable in the sigwinch_handler, since that takes locks and potentially does allocations.
Just call SBDebugger::SetTerminalWidth on the driver's SBDebugger, which does the same job, but no locks.
Also add the value checking to SetTerminalWidth you get with SetInternalVariable(..., "term-width", ...).

rdar://problem/11310563

Modified:
    lldb/trunk/include/lldb/Core/Debugger.h
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/tools/driver/Driver.cpp

Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=155665&r1=155664&r2=155665&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Thu Apr 26 16:39:32 2012
@@ -88,7 +88,9 @@
     void
     SetTerminalWidth (uint32_t term_width)
     {
-        m_term_width = term_width;
+        Error err;
+        if (ValidTermWidthValue(term_width, err))
+            m_term_width = term_width;
     }
 
     uint32_t
@@ -229,6 +231,9 @@
     bool
     ValidTermWidthValue (const char *value, Error err);
 
+    bool
+    ValidTermWidthValue (uint32_t value, Error err);
+
     const ConstString
     CreateInstanceName ();
 

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=155665&r1=155664&r2=155665&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Thu Apr 26 16:39:32 2012
@@ -2523,10 +2523,7 @@
         
         if (end && end[0] == '\0')
         {
-            if (width >= 10 && width <= 1024)
-                valid = true;
-            else
-                err.SetErrorString ("invalid term-width value; value must be between 10 and 1024");
+            return ValidTermWidthValue (width, err);
         }
         else
             err.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string", value);
@@ -2535,6 +2532,17 @@
     return valid;
 }
 
+bool
+DebuggerInstanceSettings::ValidTermWidthValue (uint32_t value, Error err)
+{
+    if (value >= 10 && value <= 1024)
+        return true;
+    else
+    {
+        err.SetErrorString ("invalid term-width value; value must be between 10 and 1024");
+        return false;
+    }
+}
 
 void
 DebuggerInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name,

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=155665&r1=155664&r2=155665&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Thu Apr 26 16:39:32 2012
@@ -1484,11 +1484,9 @@
     if (isatty (STDIN_FILENO)
         && ::ioctl (STDIN_FILENO, TIOCGWINSZ, &window_size) == 0)
     {
-        if ((window_size.ws_col > 0) && (strlen (g_debugger_name) > 0))
+        if ((window_size.ws_col > 0) && g_driver != NULL)
         {
-            char width_str_buffer[25];
-            ::sprintf (width_str_buffer, "%d", window_size.ws_col);
-            SBDebugger::SetInternalVariable ("term-width", width_str_buffer, g_debugger_name);
+            g_driver->GetDebugger().SetTerminalWidth (window_size.ws_col);
         }
     }
 }





More information about the lldb-commits mailing list