LLDB mainline
StringExtractorGDBRemote.h
Go to the documentation of this file.
1//===-- StringExtractorGDBRemote.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_UTILITY_STRINGEXTRACTORGDBREMOTE_H
10#define LLDB_UTILITY_STRINGEXTRACTORGDBREMOTE_H
11
12#include "lldb/Utility/Status.h"
14#include "llvm/ADT/StringRef.h"
15
16#include <optional>
17#include <string>
18
19#include <cstddef>
20#include <cstdint>
21
23public:
25 void *baton, const StringExtractorGDBRemote &response);
26
28
29 StringExtractorGDBRemote(llvm::StringRef str)
30 : StringExtractor(str), m_validator(nullptr) {}
31
32 StringExtractorGDBRemote(const char *cstr)
33 : StringExtractor(cstr), m_validator(nullptr) {}
34
35 bool ValidateResponse() const;
36
38
39 void SetResponseValidator(ResponseValidatorCallback callback, void *baton);
40
42
44
46
52 eServerPacketType_interrupt, // CTRL+c packet or "\x03"
53 eServerPacketType_A, // Program arguments packet
96 // debug server packages
108
131
134
143
145
152 eServerPacketType_I, // stdin notification
165
168 eServerPacketType_notify, // '%' notification
169
175
176 eServerPacketType_qMemTags, // read memory tags
177 eServerPacketType_QMemTags, // write memory tags
178
185 };
186
188
190
192
193 bool IsOKResponse() const;
194
195 bool IsUnsupportedResponse() const;
196
197 bool IsNormalResponse() const;
198
199 bool IsErrorResponse() const;
200
201 // Returns zero if the packet isn't a EXX packet where XX are two hex digits.
202 // Otherwise the error encoded in XX is returned.
203 uint8_t GetError();
204
206
207 size_t GetEscapedBinaryData(std::string &str);
208
211
212 // Read thread-id from the packet. If the packet is valid, returns
213 // the pair (PID, TID), otherwise returns std::nullopt. If the packet
214 // does not list a PID, default_pid is used.
215 std::optional<std::pair<lldb::pid_t, lldb::tid_t>>
216 GetPidTid(lldb::pid_t default_pid);
217
218protected:
220 void *m_validator_baton = nullptr;
221};
222
223#endif // LLDB_UTILITY_STRINGEXTRACTORGDBREMOTE_H
StringExtractorGDBRemote(const char *cstr)
void CopyResponseValidator(const StringExtractorGDBRemote &rhs)
ServerPacketType GetServerPacketType() const
StringExtractorGDBRemote()=default
static constexpr lldb::tid_t AllThreads
size_t GetEscapedBinaryData(std::string &str)
void SetResponseValidator(ResponseValidatorCallback callback, void *baton)
static constexpr lldb::pid_t AllProcesses
ResponseValidatorCallback m_validator
bool(* ResponseValidatorCallback)(void *baton, const StringExtractorGDBRemote &response)
std::optional< std::pair< lldb::pid_t, lldb::tid_t > > GetPidTid(lldb::pid_t default_pid)
StringExtractorGDBRemote(llvm::StringRef str)
An error handling class.
Definition Status.h:118
#define UINT64_MAX
uint64_t pid_t
Definition lldb-types.h:83
uint64_t tid_t
Definition lldb-types.h:84