diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index cdba0d6da6b9..f1b943263537 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -88,7 +88,9 @@ public: 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 @@ protected: bool ValidTermWidthValue (const char *value, Error err); + bool + ValidTermWidthValue (uint32_t value, Error err); + const ConstString CreateInstanceName (); diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 6bb68db42f1c..9a7a3f576201 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -2523,10 +2523,7 @@ DebuggerInstanceSettings::ValidTermWidthValue (const char *value, Error err) 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 @@ DebuggerInstanceSettings::ValidTermWidthValue (const char *value, Error err) 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, diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 63844af8afd3..b022f38b7108 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -1484,11 +1484,9 @@ sigwinch_handler (int signo) 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); } } }