LLDB
mainline
llvm-project
lldb
source
Plugins
Process
gdb-remote
GDBRemoteCommunicationHistory.h
Go to the documentation of this file.
1
//===-- GDBRemoteCommunicationHistory.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_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONHISTORY_H
10
#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONHISTORY_H
11
12
#include <string>
13
#include <vector>
14
15
#include "
lldb/Utility/GDBRemote.h
"
16
#include "
lldb/lldb-public.h
"
17
#include "llvm/Support/raw_ostream.h"
18
19
namespace
lldb_private
{
20
namespace
process_gdb_remote {
21
22
/// The history keeps a circular buffer of GDB remote packets. The history is
23
/// used for logging and replaying GDB remote packets.
24
class
GDBRemoteCommunicationHistory
{
25
public
:
26
GDBRemoteCommunicationHistory
(uint32_t size = 0);
27
28
~GDBRemoteCommunicationHistory
();
29
30
// For single char packets for ack, nack and /x03
31
void
AddPacket
(
char
packet_char,
GDBRemotePacket::Type
type,
32
uint32_t bytes_transmitted);
33
34
void
AddPacket
(
const
std::string &src, uint32_t src_len,
35
GDBRemotePacket::Type
type, uint32_t bytes_transmitted);
36
37
void
Dump
(
Stream
&strm)
const
;
38
void
Dump
(
Log
*log)
const
;
39
bool
DidDumpToLog
()
const
{
return
m_dumped_to_log
; }
40
41
private
:
42
uint32_t
GetFirstSavedPacketIndex
()
const
{
43
if
(
m_total_packet_count
<
m_packets
.size())
44
return
0;
45
else
46
return
m_curr_idx
+ 1;
47
}
48
49
uint32_t
GetNumPacketsInHistory
()
const
{
50
if
(
m_total_packet_count
<
m_packets
.size())
51
return
m_total_packet_count
;
52
else
53
return
(uint32_t)
m_packets
.size();
54
}
55
56
uint32_t
GetNextIndex
() {
57
++
m_total_packet_count
;
58
const
uint32_t idx =
m_curr_idx
;
59
m_curr_idx
=
NormalizeIndex
(idx + 1);
60
return
idx;
61
}
62
63
uint32_t
NormalizeIndex
(uint32_t i)
const
{
64
return
m_packets
.empty() ? 0 : i %
m_packets
.size();
65
}
66
67
std::vector<GDBRemotePacket>
m_packets
;
68
uint32_t
m_curr_idx
= 0;
69
uint32_t
m_total_packet_count
= 0;
70
mutable
bool
m_dumped_to_log
=
false
;
71
};
72
73
}
// namespace process_gdb_remote
74
}
// namespace lldb_private
75
76
#endif
// LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONHISTORY_H
GDBRemote.h
lldb_private::Log
Definition:
Log.h:132
lldb_private::Stream
A stream class that can stream formatted output to a file.
Definition:
Stream.h:28
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory
The history keeps a circular buffer of GDB remote packets.
Definition:
GDBRemoteCommunicationHistory.h:24
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::Dump
void Dump(Stream &strm) const
Definition:
GDBRemoteCommunicationHistory.cpp:59
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::m_total_packet_count
uint32_t m_total_packet_count
Definition:
GDBRemoteCommunicationHistory.h:69
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::GetNextIndex
uint32_t GetNextIndex()
Definition:
GDBRemoteCommunicationHistory.h:56
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::NormalizeIndex
uint32_t NormalizeIndex(uint32_t i) const
Definition:
GDBRemoteCommunicationHistory.h:63
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::GetNumPacketsInHistory
uint32_t GetNumPacketsInHistory() const
Definition:
GDBRemoteCommunicationHistory.h:49
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::GetFirstSavedPacketIndex
uint32_t GetFirstSavedPacketIndex() const
Definition:
GDBRemoteCommunicationHistory.h:42
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::m_dumped_to_log
bool m_dumped_to_log
Definition:
GDBRemoteCommunicationHistory.h:70
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::m_curr_idx
uint32_t m_curr_idx
Definition:
GDBRemoteCommunicationHistory.h:68
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::AddPacket
void AddPacket(char packet_char, GDBRemotePacket::Type type, uint32_t bytes_transmitted)
Definition:
GDBRemoteCommunicationHistory.cpp:28
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::DidDumpToLog
bool DidDumpToLog() const
Definition:
GDBRemoteCommunicationHistory.h:39
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::m_packets
std::vector< GDBRemotePacket > m_packets
Definition:
GDBRemoteCommunicationHistory.h:67
lldb_private::process_gdb_remote::GDBRemoteCommunicationHistory::~GDBRemoteCommunicationHistory
~GDBRemoteCommunicationHistory()
lldb-public.h
lldb_private
A class that represents a running process on the host machine.
Definition:
SBAddressRange.h:14
lldb_private::GDBRemotePacket::Type
Type
Definition:
GDBRemote.h:52
Generated on Fri Dec 20 2024 17:27:33 for LLDB by
1.9.6