OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2011 The Native Client Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can | |
4 * be found in the LICENSE file. | |
5 */ | |
6 | |
7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_DEBUG_STUB_DEBUG_PIPE_H_ | |
8 #define NATIVE_CLIENT_SRC_TRUSTED_DEBUG_STUB_DEBUG_PIPE_H_ 1 | |
9 | |
10 /* | |
11 * This module provides interfaces for transmitting and receiving | |
12 * packets that conform to the GDB serial line debug protocol. | |
13 * | |
14 * The packet are transmitted and received in the form of: | |
15 * $[<SQ>:]<C>[<..data...>]#<XS> | |
16 * | |
17 * | |
18 * Where | |
19 * <SQ> : is an optional two hex digit sequence number followed by ':' | |
20 * <C> : is a single character Command | |
21 * <data>: is the optinal paramters, payload, etc... | |
22 * <XS> : is an 8 bit sum as two hex digits preceeded by '#' | |
23 * | |
24 * Upon receit, the receiver will reply with either | |
25 * - : to signal a bad XSUM | |
26 * +[SQ] : to signal valid packet with the sequence if provided | |
27 * | |
28 * | |
29 */ | |
30 | |
31 #include <string> | |
32 #include <sstream> | |
33 | |
34 #include "native_client/src/include/portability.h" | |
35 #include "debug_conn/debug_flags.h" | |
36 | |
37 namespace nacl_debug_conn { | |
38 | |
39 class DebugPipe; | |
40 class DebugPacket; | |
41 class DebugStream; | |
42 | |
43 class DebugPipe : public DebugFlags { | |
44 public: | |
45 explicit DebugPipe(DebugStream *io_ptr); | |
46 ~DebugPipe(); | |
47 | |
48 enum DPResult { | |
49 DPR_ERROR = -1, // IO error on the stream, close the pipe | |
50 DPR_NO_DATA = 0, // No data availible | |
51 DPR_OK = 1 // Completed OK | |
52 }; | |
53 | |
54 enum { | |
55 DPF_IGNORE_ACK = 1, | |
56 DPF_USE_SEQ = 2, | |
57 DPF_DEBUG_SEND = 4, | |
58 DPF_DEBUG_RECV = 8, | |
59 DPF_DEBUG_MASK = (DPF_DEBUG_SEND | DPF_DEBUG_RECV) | |
60 }; | |
61 | |
62 public: | |
63 void SetName(const char *name); | |
64 const char *GetName() const; | |
65 | |
66 DPResult SendPacketOnly(DebugPacket *packet); | |
67 DPResult SendPacket(DebugPacket *packet); | |
68 DPResult GetPacket(DebugPacket *packet); | |
69 | |
70 bool DataAvail() const; | |
71 | |
72 protected: | |
73 DebugStream *GetIO(); | |
74 | |
75 DPResult GetChar(char *ch); | |
76 DPResult SendStream(const char *str); | |
77 | |
78 private: | |
79 std::string name_; | |
80 char outxsum_; | |
81 uint8_t seq_; | |
82 | |
83 DebugStream *io_; | |
84 }; | |
85 | |
86 } // namespace nacl_debug_conn | |
87 | |
88 #endif | |
OLD | NEW |