diff options
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r-- | lldb/source/Commands/CommandObjectBreakpointCommand.cpp | 57 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectLog.cpp | 11 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectMemory.cpp | 2 |
3 files changed, 27 insertions, 43 deletions
diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp index c706bb555a6..0024e6d2e80 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -418,28 +418,25 @@ CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback size_t bytes_len ) { - FILE *out_fh = reader.GetDebugger().GetOutputFileHandle(); + File &out_file = reader.GetDebugger().GetOutputFile(); switch (notification) { case eInputReaderActivate: - if (out_fh) - { - ::fprintf (out_fh, "%s\n", g_reader_instructions); - if (reader.GetPrompt()) - ::fprintf (out_fh, "%s", reader.GetPrompt()); - ::fflush (out_fh); - } + out_file.Printf ("%s\n", g_reader_instructions); + if (reader.GetPrompt()) + out_file.Printf ("%s", reader.GetPrompt()); + out_file.Flush(); break; case eInputReaderDeactivate: break; case eInputReaderReactivate: - if (out_fh && reader.GetPrompt()) + if (reader.GetPrompt()) { - ::fprintf (out_fh, "%s", reader.GetPrompt()); - ::fflush (out_fh); + out_file.Printf ("%s", reader.GetPrompt()); + out_file.Flush(); } break; @@ -454,10 +451,10 @@ CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback ((BreakpointOptions::CommandData *)bp_options_baton->m_data)->user_source.AppendString (bytes, bytes_len); } } - if (out_fh && !reader.IsDone() && reader.GetPrompt()) + if (!reader.IsDone() && reader.GetPrompt()) { - ::fprintf (out_fh, "%s", reader.GetPrompt()); - ::fflush (out_fh); + out_file.Printf ("%s", reader.GetPrompt()); + out_file.Flush(); } break; @@ -475,8 +472,8 @@ CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback ((BreakpointOptions::CommandData *) bp_options_baton->m_data)->script_source.Clear(); } } - ::fprintf (out_fh, "Warning: No command attached to breakpoint.\n"); - ::fflush (out_fh); + out_file.Printf ("Warning: No command attached to breakpoint.\n"); + out_file.Flush(); } break; @@ -774,8 +771,8 @@ CommandObjectBreakpointCommand::BreakpointOptionsCallbackFunction Debugger &debugger = context->exe_ctx.target->GetDebugger(); CommandInterpreter &interpreter = debugger.GetCommandInterpreter(); - FILE *out_fh = debugger.GetOutputFileHandle(); - FILE *err_fh = debugger.GetErrorFileHandle(); + File &out_file = debugger.GetOutputFile(); + File &err_file = debugger.GetErrorFile(); uint32_t i; for (i = 0; i < num_commands; ++i) @@ -797,30 +794,24 @@ CommandObjectBreakpointCommand::BreakpointOptionsCallbackFunction { if (i < num_commands - 1) { - if (out_fh) - ::fprintf (out_fh, "Short-circuiting command execution because target state changed to %s." - " last command: \"%s\"\n", StateAsCString(internal_state), - commands.GetStringAtIndex(i)); + out_file.Printf ("Short-circuiting command execution because target state changed to %s." + " last command: \"%s\"\n", StateAsCString(internal_state), + commands.GetStringAtIndex(i)); } break; } - if (out_fh) - ::fprintf (out_fh, "%s", result.GetErrorStream().GetData()); - if (err_fh) - ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); + out_file.Printf ("%s", result.GetErrorStream().GetData()); + err_file.Printf ("%s", result.GetOutputStream().GetData()); result.Clear(); result.SetStatus (eReturnStatusSuccessFinishNoResult); } - if (err_fh && !result.Succeeded() && i < num_commands) - ::fprintf (err_fh, "Attempt to execute '%s' failed.\n", commands.GetStringAtIndex(i)); - - if (out_fh) - ::fprintf (out_fh, "%s", result.GetErrorStream().GetData()); + if (!result.Succeeded() && i < num_commands) + err_file.Printf ("Attempt to execute '%s' failed.\n", commands.GetStringAtIndex(i)); - if (err_fh) - ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); + out_file.Printf ("%s", result.GetErrorStream().GetData()); + err_file.Printf ("%s", result.GetOutputStream().GetData()); } } return ret_value; diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp index cf090af05e6..b887f1cc9f4 100644 --- a/lldb/source/Commands/CommandObjectLog.cpp +++ b/lldb/source/Commands/CommandObjectLog.cpp @@ -113,19 +113,16 @@ public: std::string channel(args.GetArgumentAtIndex(0)); args.Shift (); // Shift off the channel StreamSP log_stream_sp; - StreamFile *log_file_ptr = NULL; // This will get put in the log_stream_sp, no need to free it. if (m_options.log_file.empty()) { - log_file_ptr = new StreamFile(m_interpreter.GetDebugger().GetOutputFileHandle()); - log_stream_sp.reset(log_file_ptr); + log_stream_sp.reset(new StreamFile(m_interpreter.GetDebugger().GetOutputFile().GetDescriptor(), false)); } else { LogStreamMap::iterator pos = m_log_streams.find(m_options.log_file); if (pos == m_log_streams.end()) { - log_file_ptr = new StreamFile (m_options.log_file.c_str(), "w"); - log_stream_sp.reset (log_file_ptr); + log_stream_sp.reset (new StreamFile (m_options.log_file.c_str())); m_log_streams[m_options.log_file] = log_stream_sp; } else @@ -133,10 +130,6 @@ public: } assert (log_stream_sp.get()); - // If we ended up making a StreamFile for log output, line buffer it. - if (log_file_ptr != NULL) - log_file_ptr->SetLineBuffered(); - uint32_t log_options = m_options.log_options; if (log_options == 0) log_options = LLDB_LOG_OPTION_PREPEND_THREAD_NAME | LLDB_LOG_OPTION_THREADSAFE; diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 3020c01de81..949cadca352 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -347,7 +347,7 @@ public: if (m_options.m_append_to_outfile) mode[0] = 'a'; - if (outfile_stream.Open (path, mode)) + if (outfile_stream.GetFile ().Open (path, File::eOpenOptionWrite | File::eOpenOptionCanCreate).Success()) { if (m_options.m_output_as_binary) { |