1 //===-- OutputRedirector.h -------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===/ 8 9 #ifndef LLDB_TOOLS_LLDB_VSCODE_OUTPUT_REDIRECTOR_H 10 #define LLDB_TOOLS_LLDB_VSCODE_OUTPUT_REDIRECTOR_H 11 12 #include <thread> 13 14 #include "llvm/ADT/StringRef.h" 15 #include "llvm/Support/Error.h" 16 17 namespace lldb_vscode { 18 19 /// Redirects the output of a given file descriptor to a callback. 20 /// 21 /// \return 22 /// \a Error::success if the redirection was set up correctly, or an error 23 /// otherwise. 24 llvm::Error RedirectFd(int fd, std::function<void(llvm::StringRef)> callback); 25 26 } // namespace lldb_vscode 27 28 #endif // LLDB_TOOLS_LLDB_VSCODE_OUTPUT_REDIRECTOR_H 29