OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Native Client 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 #ifndef DEBUGGER_RSP_RSP_INFO_PACKETS_H_ | |
5 #define DEBUGGER_RSP_RSP_INFO_PACKETS_H_ | |
6 #include <deque> | |
7 #include <string> | |
8 #include <utility> | |
9 #include "debugger/rsp/rsp_packets.h" | |
10 | |
11 namespace rsp { | |
12 /// Tell the remote stub about features supported by gdb, and query the stub | |
13 /// for features it supports. | |
14 /// Example: "qSupported:xmlRegisters=i386;qRelocInsn+" | |
15 class QuerySupportedCommand : public Packet { | |
16 public: | |
17 QuerySupportedCommand() {} | |
18 | |
19 virtual Packet* Clone() const { return new QuerySupportedCommand; } | |
20 virtual void AcceptVisitor(PacketVisitor* vis) { vis->Visit(this); } | |
21 virtual bool FromBlob(const std::string& type, debug::Blob* message); | |
22 virtual void ToBlob(debug::Blob* message) const; | |
23 | |
24 /// Adds a feature to the list of features. | |
25 /// @param[in] name name of the feature | |
26 /// @param[in] value value of the feature | |
27 void AddFeature(const std::string& name, const std::string& value); | |
28 | |
29 /// Serialize features into |message|. | |
30 /// @param[out] message destination for the features | |
31 void SaveFeaturesToBlob(debug::Blob* message) const; | |
32 | |
33 /// @return number of features | |
34 size_t GetFeaturesNum() const; | |
35 | |
36 /// @return feature name at |pos|. | |
37 /// @param[in] pos feature position | |
38 std::string GetFeatureName(size_t pos) const; | |
39 | |
40 /// @return feature value | |
41 /// @param[in] name name of the requested feature | |
42 std::string GetFeature(const std::string& name) const; | |
43 | |
44 protected: | |
45 std::deque<std::pair<std::string, std::string> > features_; | |
46 }; | |
47 | |
48 /// Reply to the |QuerySupportedCommand|. | |
49 class QuerySupportedReply : public QuerySupportedCommand { | |
50 public: | |
51 QuerySupportedReply() {} | |
52 | |
53 virtual Packet* Clone() const { return new QuerySupportedReply; } | |
54 virtual void AcceptVisitor(PacketVisitor* vis) { vis->Visit(this); } | |
55 virtual void ToBlob(debug::Blob* message) const; | |
56 }; | |
57 | |
58 /// Request to read 'features; file. | |
59 /// Example: "qXfer:features:read:target.xml:0,7ca" | |
60 class QXferFeaturesReadCommand : public Packet { | |
61 public: | |
62 static const char* kPrefix; | |
63 | |
64 QXferFeaturesReadCommand(); | |
65 virtual Packet* Clone() const { return new QXferFeaturesReadCommand; } | |
66 virtual void AcceptVisitor(PacketVisitor* vis) { vis->Visit(this); } | |
67 virtual bool FromBlob(const std::string& type, debug::Blob* message); | |
68 virtual void ToBlob(debug::Blob* message) const; | |
69 | |
70 std::string file_name() const { return file_name_; } | |
71 uint32_t offset() const { return offset_; } | |
72 uint32_t length() const { return length_;} | |
73 void set_file_name(std::string name) { file_name_ = name; } | |
74 void set_offset(uint32_t x) { offset_ = x; } | |
75 void set_length(uint32_t x) { length_ = x; } | |
76 | |
77 protected: | |
78 std::string file_name_; | |
79 uint32_t offset_; | |
80 uint32_t length_; | |
81 }; | |
82 | |
83 /// Reply to QXferFeaturesReadCommand | |
84 /// Example: "l<target><architecture>i386:x86-64</architecture></target>" | |
85 class QXferReply : public Packet { | |
86 public: | |
87 QXferReply() : eom_(true) {} | |
88 virtual Packet* Clone() const { return new QXferReply; } | |
89 virtual void AcceptVisitor(PacketVisitor* vis) { vis->Visit(this); } | |
90 virtual bool FromBlob(const std::string& type, debug::Blob* message); | |
91 virtual void ToBlob(debug::Blob* message) const; | |
92 | |
93 bool eom() const { return eom_; } | |
94 std::string body() const { return body_; } | |
95 | |
96 void set_eom(bool eom) { eom_ = eom; } | |
97 void set_body(const std::string& body) { body_ = body; } | |
98 | |
99 protected: | |
100 bool eom_; | |
101 std::string body_; | |
102 }; | |
103 | |
104 /// Get section offsets that the target used when relocating the image. | |
105 /// Example: qOffsets -> Text=c00000000;Data=c00000000 | |
106 class GetOffsetsCommand : public OneWordPacket { | |
107 public: | |
108 GetOffsetsCommand() : OneWordPacket("qOffsets") {} | |
109 virtual Packet* Clone() const { return new GetOffsetsCommand; } | |
110 virtual void AcceptVisitor(PacketVisitor* vis) { vis->Visit(this); } | |
111 }; | |
112 | |
113 /// Reply to GetOffsetsCommand. | |
114 /// Example: Text=c00000000;Data=c00000000 | |
115 class GetOffsetsReply : public Packet { | |
116 public: | |
117 GetOffsetsReply() : text_offset_(0), data_offset_(0) {} | |
118 virtual Packet* Clone() const { return new GetOffsetsReply; } | |
119 virtual void AcceptVisitor(PacketVisitor* vis) { vis->Visit(this); } | |
120 virtual bool FromBlob(const std::string& type, debug::Blob* message); | |
121 virtual void ToBlob(debug::Blob* message) const; | |
122 | |
123 uint64_t text_offset() const { return text_offset_; } | |
124 uint64_t data_offset() const { return data_offset_; } | |
125 | |
126 void set_text_offset(uint64_t offs) { text_offset_ = offs; } | |
127 void set_data_offset(uint64_t offs) { data_offset_ = offs; } | |
128 | |
129 private: | |
130 uint64_t text_offset_; | |
131 uint64_t data_offset_; | |
132 }; | |
133 | |
134 } // namespace rsp | |
135 | |
136 #endif // DEBUGGER_RSP_RSP_INFO_PACKETS_H_ | |
137 | |
OLD | NEW |