[Lldb-commits] [lldb] 3934a31 - [LLDB][NFC] Reliability fixes for IOHandlerCursesGUI

Slava Gurevich via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 11 21:11:01 PDT 2022


Author: Slava Gurevich
Date: 2022-08-11T21:10:53-07:00
New Revision: 3934a31cfa024edfaa406c3706dc943e59f9049c

URL: https://github.com/llvm/llvm-project/commit/3934a31cfa024edfaa406c3706dc943e59f9049c
DIFF: https://github.com/llvm/llvm-project/commit/3934a31cfa024edfaa406c3706dc943e59f9049c.diff

LOG: [LLDB][NFC] Reliability fixes for IOHandlerCursesGUI

- checking retval of function calls
- dead code removal
- null dereference fix

Differential Revision: https://reviews.llvm.org/D131615

Added: 
    

Modified: 
    lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp
index f96073ab698cb..c37c8106224fd 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -3500,19 +3500,19 @@ class ProcessLaunchFormDelegate : public FormDelegate {
 
     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 @@ class SourceFileWindowDelegate : public WindowDelegate {
     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 @@ class SourceFileWindowDelegate : public WindowDelegate {
                   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, "");


        


More information about the lldb-commits mailing list