Skip to content

Commit 106a6ba

Browse files
committed
Adding a constant for the output event buffer size.
1 parent e5f7d85 commit 106a6ba

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

lldb/tools/lldb-dap/DAP.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ namespace lldb_dap {
6868

6969
typedef llvm::DenseMap<uint32_t, SourceBreakpoint> SourceBreakpointMap;
7070
typedef llvm::StringMap<FunctionBreakpoint> FunctionBreakpointMap;
71+
7172
enum class OutputType { Console, Stdout, Stderr, Telemetry };
7273

74+
/// Buffer size for handling output events.
75+
constexpr uint64_t OutputBufferSize = (1u << 12);
76+
7377
enum DAPBroadcasterBits {
7478
eBroadcastBitStopEventThread = 1u << 0,
7579
eBroadcastBitStopProgressThread = 1u << 1

lldb/tools/lldb-dap/OutputRedirector.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
#include <unistd.h>
1414
#endif
1515

16-
#include "OutputRedirector.h"
1716
#include "llvm/ADT/StringRef.h"
17+
#include "DAP.h"
18+
#include "OutputRedirector.h"
19+
1820

1921
using namespace llvm;
2022

@@ -42,7 +44,7 @@ Error RedirectFd(int fd, std::function<void(llvm::StringRef)> callback) {
4244

4345
int read_fd = new_fd[0];
4446
std::thread t([read_fd, callback]() {
45-
char buffer[4096];
47+
char buffer[OutputBufferSize];
4648
while (true) {
4749
ssize_t bytes_count = read(read_fd, &buffer, sizeof(buffer));
4850
if (bytes_count == 0)

lldb/tools/lldb-dap/lldb-dap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ void SendProcessEvent(LaunchMethod launch_method) {
399399
// Grab any STDOUT and STDERR from the process and send it up to VS Code
400400
// via an "output" event to the "stdout" and "stderr" categories.
401401
void SendStdOutStdErr(lldb::SBProcess &process) {
402-
char buffer[4096];
402+
char buffer[OutputBufferSize];
403403
size_t count;
404404
while ((count = process.GetSTDOUT(buffer, sizeof(buffer))) > 0)
405405
g_dap.SendOutput(OutputType::Stdout, llvm::StringRef(buffer, count));

0 commit comments

Comments
 (0)