Repository: llvm/llvm-project
File: lldb/source/Expression/REPL.cpp (C++)

Code before:
                persistent_state->GetVariableAtIndex(vi);
            lldb::ValueObjectSP valobj_sp = persistent_var_sp->GetValueObject();

            PrintOneVariable(debugger, output_stream_sp, valobj_sp,
                             persistent_var_sp.get());
          }
        }

        if (!handled) {
          bool useColors =
              error_stream_sp->Lock().GetFile().GetIsTerminalWithColors();
          switch (execution_results) {
          case lldb::eExpressionSetupError:
          case lldb::eExpressionParseError:
            add_to_code = false;
            [[fallthrough]];
          case lldb::eExpressionDiscarded:
            error_stream_sp->Lock().Printf("%s\n", error.AsCString());
            break;

          case lldb::eExpressionCompleted:
            break;
          case lldb::eExpressionInterrupted:
            if (useColors) {
              error_stream_sp->Lock().Printf(ANSI_ESCAPE1(ANSI_FG_COLOR_RED));
              error_stream_sp->Lock().Printf(ANSI_ESCAPE1(ANSI_CTRL_BOLD));
            }
            error_stream_sp->Lock().Printf("Execution interrupted. ");
            if (useColors)
              error_stream_sp->Lock().Printf(ANSI_ESCAPE1(ANSI_CTRL_NORMAL));
            error_stream_sp->Lock().Printf(
                "Enter code to recover and continue.\nEnter LLDB "
                "commands to investigate (type :help for "
                "assistance.)\n");
            break;

          case lldb::eExpressionHitBreakpoint:
            // Breakpoint was hit, drop into LLDB command interpreter
            if (useColors) {
              error_stream_sp->Lock().Printf(ANSI_ESCAPE1(ANSI_FG_COLOR_RED));
              error_stream_sp->Lock().Printf(ANSI_ESCAPE1(ANSI_CTRL_BOLD));
            }
            output_stream_sp->Lock().Printf(
                "Execution stopped at breakpoint.  ");
            if (useColors)
              error_stream_sp->Lock().Printf(ANSI_ESCAPE1(ANSI_CTRL_NORMAL));
            output_stream_sp->Lock().Printf(
                "Enter LLDB commands to investigate (type help "
                "for assistance.)\n");
            {
              lldb::IOHandlerSP io_handler_sp(ci.GetIOHandler());

Review comment (suggestion):
This should be atomic and lock until we reset the color. Otherwise, we could be drawing the status line in bold red if it happened to refresh between this and the rest of the output. 

Code after:
                persistent_state->GetVariableAtIndex(vi);
            lldb::ValueObjectSP valobj_sp = persistent_var_sp->GetValueObject();

            PrintOneVariable(debugger, output_stream_sp, valobj_sp,
                             persistent_var_sp.get());
          }
        }

        if (!handled) {
          LockedStreamFile locked_error_stream = error_stream_sp->Lock();
          bool useColors =
              locked_error_stream.GetFile().GetIsTerminalWithColors();
          switch (execution_results) {
          case lldb::eExpressionSetupError:
          case lldb::eExpressionParseError:
            add_to_code = false;
            [[fallthrough]];
          case lldb::eExpressionDiscarded:
            locked_error_stream.Printf("%s\n", error.AsCString());
            break;

          case lldb::eExpressionCompleted:
            break;
          case lldb::eExpressionInterrupted:
            if (useColors) {
              locked_error_stream.Printf(ANSI_ESCAPE1(ANSI_FG_COLOR_RED));
              locked_error_stream.Printf(ANSI_ESCAPE1(ANSI_CTRL_BOLD));
            }
            locked_error_stream.Printf("Execution interrupted. ");
            if (useColors)
              locked_error_stream.Printf(ANSI_ESCAPE1(ANSI_CTRL_NORMAL));
            locked_error_stream.Printf(
                "Enter code to recover and continue.\nEnter LLDB "
                "commands to investigate (type :help for "
                "assistance.)\n");
            break;

          case lldb::eExpressionHitBreakpoint:
            // Breakpoint was hit, drop into LLDB command interpreter
            if (useColors) {
              locked_error_stream.Printf(ANSI_ESCAPE1(ANSI_FG_COLOR_RED));
              locked_error_stream.Printf(ANSI_ESCAPE1(ANSI_CTRL_BOLD));
            }
            output_stream_sp->Lock().Printf(
                "Execution stopped at breakpoint.  ");
            if (useColors)
              locked_error_stream.Printf(ANSI_ESCAPE1(ANSI_CTRL_NORMAL));
            locked_error_stream.Printf(
                "Enter LLDB commands to investigate (type help "
                "for assistance.)\n");
            {