1 //===-- StreamGDBRemote.cpp -------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Utility/StreamGDBRemote.h"
11 #include "lldb/Utility/Flags.h"
12 #include "lldb/Utility/Stream.h"
17 using namespace lldb_private;
19 StreamGDBRemote::StreamGDBRemote() : StreamString() {}
21 StreamGDBRemote::StreamGDBRemote(uint32_t flags, uint32_t addr_size,
23 : StreamString(flags, addr_size, byte_order) {}
25 StreamGDBRemote::~StreamGDBRemote() {}
27 int StreamGDBRemote::PutEscapedBytes(const void *s, size_t src_len) {
28 int bytes_written = 0;
29 const uint8_t *src = static_cast<const uint8_t *>(s);
30 bool binary_is_set = m_flags.Test(eBinary);
31 m_flags.Clear(eBinary);
36 if (byte == 0x23 || byte == 0x24 || byte == 0x7d || byte == 0x2a) {
37 bytes_written += PutChar(0x7d);
40 bytes_written += PutChar(byte);