[Lldb-commits] [PATCH] D131615: [LLDB][NFC] Reliability fixes for IOHandlerCursesGUI

Slava Gurevich via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 10 13:08:33 PDT 2022


fixathon created this revision.
fixathon added reviewers: clayborg, JDevlieghere, DavidSpickett, jasonmolenda.
Herald added a project: All.
fixathon requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

- checking retval of function calls
- signed/unsigned mismatch
- dead code removal
- null dereference fix


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131615

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===================================================================
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -388,10 +388,10 @@
   void AttributeOn(attr_t attr) { ::wattron(m_window, attr); }
   void AttributeOff(attr_t attr) { ::wattroff(m_window, attr); }
 
-  int GetMaxX() const { return getmaxx(m_window); }
-  int GetMaxY() const { return getmaxy(m_window); }
-  int GetWidth() const { return GetMaxX(); }
-  int GetHeight() const { return GetMaxY(); }
+  uint32_t GetMaxX() const { return getmaxx(m_window); }
+  uint32_t GetMaxY() const { return getmaxy(m_window); }
+  uint32_t GetWidth() const { return GetMaxX(); }
+  uint32_t GetHeight() const { return GetMaxY(); }
   Size GetSize() const { return Size(GetWidth(), GetHeight()); }
   // Get a zero origin rectangle width the surface size.
   Rect GetFrame() const { return Rect(Point(), GetSize()); }
@@ -3500,19 +3500,19 @@
 
     FileAction action;
     if (m_standard_input_field->IsSpecified()) {
-      action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), true,
-                  false);
-      launch_info.AppendFileAction(action);
+      if (action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), true,
+                      false))
+        launch_info.AppendFileAction(action);
     }
     if (m_standard_output_field->IsSpecified()) {
-      action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(), false,
-                  true);
-      launch_info.AppendFileAction(action);
+      if (action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(),
+                      false, true))
+        launch_info.AppendFileAction(action);
     }
     if (m_standard_error_field->IsSpecified()) {
-      action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(), false,
-                  true);
-      launch_info.AppendFileAction(action);
+      if (action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(),
+                      false, true))
+        launch_info.AppendFileAction(action);
     }
   }
 
@@ -6821,7 +6821,7 @@
     bool set_selected_line_to_pc = false;
 
     if (update_location) {
-      const bool process_alive = process ? process->IsAlive() : false;
+      const bool process_alive = process->IsAlive();
       bool thread_changed = false;
       if (process_alive) {
         thread = exe_ctx.GetThreadPtr();
@@ -7209,8 +7209,10 @@
                   window.Printf("%*s", desc_x - window.GetCursorX(), "");
                 window.MoveCursor(window_width - stop_description_len - 15,
                                   line_y);
-                window.PrintfTruncated(1, "<<< Thread %u: %s ",
-                                       thread->GetIndexID(), stop_description);
+                if (thread)
+                  window.PrintfTruncated(1, "<<< Thread %u: %s ",
+                                         thread->GetIndexID(),
+                                         stop_description);
               }
             } else {
               window.Printf("%*s", window_width - window.GetCursorX() - 1, "");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131615.451610.patch
Type: text/x-patch
Size: 3159 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220810/ad3196de/attachment.bin>


More information about the lldb-commits mailing list