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
130
133
142
144
151 eServerPacketType_I, // stdin notification
164
167 eServerPacketType_notify, // '%' notification
168
174
175 eServerPacketType_qMemTags, // read memory tags
176 eServerPacketType_QMemTags, // write memory tags
177
184 };
185
187
189
191
192 bool IsOKResponse() const;
193
194 bool IsUnsupportedResponse() const;
195
196 bool IsNormalResponse() const;
197
198 bool IsErrorResponse() const;
199
200 // Returns zero if the packet isn't a EXX packet where XX are two hex digits.
201 // Otherwise the error encoded in XX is returned.
202 uint8_t GetError();
203
205
206 size_t GetEscapedBinaryData(std::string &str);
207
210
211 // Read thread-id from the packet. If the packet is valid, returns
212 // the pair (PID, TID), otherwise returns std::nullopt. If the packet
213 // does not list a PID, default_pid is used.
214 std::optional<std::pair<lldb::pid_t, lldb::tid_t>>
215 GetPidTid(lldb::pid_t default_pid);
216
217protected:
219 void *m_validator_baton = nullptr;
220};
221
222#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)
ResponseType GetResponseType() const
An error handling class.
Definition: Status.h:44
#define UINT64_MAX
Definition: lldb-defines.h:23
uint64_t pid_t
Definition: lldb-types.h:83
uint64_t tid_t
Definition: lldb-types.h:84