v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
session.h
Go to the documentation of this file.
1// Copyright 2020 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_DEBUG_WASM_GDB_SERVER_SESSION_H_
6#define V8_DEBUG_WASM_GDB_SERVER_SESSION_H_
7
8#include "src/base/macros.h"
9
10namespace v8 {
11namespace internal {
12namespace wasm {
13namespace gdb_server {
14
15class Packet;
16class TransportBase;
17
18// Represents a gdb-remote debugging session.
20 public:
21 explicit Session(TransportBase* transport);
22 Session(const Session&) = delete;
23 Session& operator=(const Session&) = delete;
24
25 // Attempt to send a packet and optionally wait for an ACK from the receiver.
26 bool SendPacket(Packet* packet, bool expect_ack = true);
27
28 // Attempt to receive a packet.
29 bool GetPacket(Packet* packet);
30
31 // Return true if there is data to read.
32 bool IsDataAvailable() const;
33
34 // Return true if the connection is still valid.
35 bool IsConnected() const;
36
37 // Shutdown the connection.
38 void Disconnect();
39
40 // When a debugging session is active, the GDB-remote thread can block waiting
41 // for events and it will resume execution when one of these two events arise:
42 // - A network event (a new packet arrives, or the connection is dropped)
43 // - A thread event (the execution stopped because of a trap or breakpoint).
44 void WaitForDebugStubEvent();
45
46 // Signal that the debuggee execution stopped because of a trap or breakpoint.
47 bool SignalThreadEvent();
48
49 // By default, when either the debugger or the GDB-stub sends a packet,
50 // the first response expected is an acknowledgment: either '+' (to indicate
51 // the packet was received correctly) or '-' (to request retransmission).
52 // When a transport is reliable, the debugger may request that acknowledgement
53 // be disabled by means of the 'QStartNoAckMode' packet.
54 void EnableAck(bool ack_enabled) { ack_enabled_ = ack_enabled; }
55
56 private:
57 // Read a single character from the transport.
58 bool GetChar(char* ch);
59
60 // Read the content of a packet, from a leading '$' to a trailing '#'.
61 bool GetPayload(Packet* pkt, uint8_t* checksum);
62
63 TransportBase* io_; // Transport object not owned by the Session.
64 bool connected_; // Is the connection still valid.
65 bool ack_enabled_; // If true, emit or wait for '+' from RSP stream.
66};
67
68} // namespace gdb_server
69} // namespace wasm
70} // namespace internal
71} // namespace v8
72
73#endif // V8_DEBUG_WASM_GDB_SERVER_SESSION_H_
Session & operator=(const Session &)=delete
void EnableAck(bool ack_enabled)
Definition session.h:54
Definition c-api.cc:87
#define V8_EXPORT_PRIVATE
Definition macros.h:460