Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:57

0001 //===-- GDBRemote.h ----------------------------------------------*- C++-*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_UTILITY_GDBREMOTE_H
0010 #define LLDB_UTILITY_GDBREMOTE_H
0011 
0012 #include "lldb/Utility/FileSpec.h"
0013 #include "lldb/Utility/StreamString.h"
0014 #include "lldb/lldb-enumerations.h"
0015 #include "lldb/lldb-public.h"
0016 #include "llvm/Support/raw_ostream.h"
0017 
0018 #include <cstddef>
0019 #include <cstdint>
0020 #include <string>
0021 #include <vector>
0022 
0023 namespace lldb_private {
0024 
0025 class StreamGDBRemote : public StreamString {
0026 public:
0027   StreamGDBRemote();
0028 
0029   StreamGDBRemote(uint32_t flags, uint32_t addr_size,
0030                   lldb::ByteOrder byte_order);
0031 
0032   ~StreamGDBRemote() override;
0033 
0034   /// Output a block of data to the stream performing GDB-remote escaping.
0035   ///
0036   /// \param[in] s
0037   ///     A block of data.
0038   ///
0039   /// \param[in] src_len
0040   ///     The amount of data to write.
0041   ///
0042   /// \return
0043   ///     Number of bytes written.
0044   // TODO: Convert this function to take ArrayRef<uint8_t>
0045   int PutEscapedBytes(const void *s, size_t src_len);
0046 };
0047 
0048 /// GDB remote packet as used by the GDB remote communication history. Packets
0049 /// can be serialized to file.
0050 struct GDBRemotePacket {
0051 
0052   enum Type { ePacketTypeInvalid = 0, ePacketTypeSend, ePacketTypeRecv };
0053 
0054   GDBRemotePacket() = default;
0055 
0056   void Clear() {
0057     packet.data.clear();
0058     type = ePacketTypeInvalid;
0059     bytes_transmitted = 0;
0060     packet_idx = 0;
0061     tid = LLDB_INVALID_THREAD_ID;
0062   }
0063 
0064   struct BinaryData {
0065     std::string data;
0066   };
0067 
0068   void Dump(Stream &strm) const;
0069 
0070   BinaryData packet;
0071   Type type = ePacketTypeInvalid;
0072   uint32_t bytes_transmitted = 0;
0073   uint32_t packet_idx = 0;
0074   lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
0075 
0076 private:
0077   llvm::StringRef GetTypeStr() const;
0078 };
0079 
0080 } // namespace lldb_private
0081 
0082 #endif // LLDB_UTILITY_GDBREMOTE_H