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
176
177 eServerPacketType_qMemTags, // read memory tags
178 eServerPacketType_QMemTags, // write memory tags
179
186 };
187
189
191
193
194 bool IsOKResponse() const;
195
196 bool IsUnsupportedResponse() const;
197
198 bool IsNormalResponse() const;
199
200 bool IsErrorResponse() const;
201
202 // Returns zero if the packet isn't a EXX packet where XX are two hex digits.
203 // Otherwise the error encoded in XX is returned.
204 uint8_t GetError();
205
207
208 size_t GetEscapedBinaryData(std::string &str);
209
212
213 // Read thread-id from the packet. If the packet is valid, returns
214 // the pair (PID, TID), otherwise returns std::nullopt. If the packet
215 // does not list a PID, default_pid is used.
216 std::optional<std::pair<lldb::pid_t, lldb::tid_t>>
217 GetPidTid(lldb::pid_t default_pid);
218
219protected:
221 void *m_validator_baton = nullptr;
222};
223
224#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