@@ -33,21 +33,21 @@ enum RequestType : uint8_t
33
33
// retrieve the valus in a set of blackboards
34
34
BLACKBOARD = ' B' ,
35
35
36
- // Groot requests the insertion of a breakpoint
37
- BREAKPOINT_INSERT = ' I' ,
38
- // Groot requests to remove a breakpoint
39
- BREAKPOINT_REMOVE = ' R' ,
36
+ // Groot requests the insertion of a hook
37
+ HOOK_INSERT = ' I' ,
38
+ // Groot requests to remove a hook
39
+ HOOK_REMOVE = ' R' ,
40
40
// Notify Groot that we reached a breakpoint
41
41
BREAKPOINT_REACHED = ' N' ,
42
42
// Groot will unlock a breakpoint
43
43
BREAKPOINT_UNLOCK = ' U' ,
44
- // receive the existing breakpoints in JSON format
45
- BREAKPOINTS_DUMP = ' D' ,
44
+ // receive the existing hooks in JSON format
45
+ HOOKS_DUMP = ' D' ,
46
46
47
- // Remove all breakpoints . To be done before disconnecting Groot
48
- REMOVE_ALL_BREAKPOINTS = ' A' ,
47
+ // Remove all hooks . To be done before disconnecting Groot
48
+ REMOVE_ALL_HOOKS = ' A' ,
49
49
50
- DISABLE_ALL_BREAKPOINTS = ' X' ,
50
+ DISABLE_ALL_HOOKS = ' X' ,
51
51
52
52
UNDEFINED = 0 ,
53
53
};
@@ -60,13 +60,13 @@ inline const char* ToString(const RequestType& type)
60
60
case RequestType::STATUS: return " status" ;
61
61
case RequestType::BLACKBOARD: return " blackboard" ;
62
62
63
- case RequestType::BREAKPOINT_INSERT : return " breakpoint_insert " ;
64
- case RequestType::BREAKPOINT_REMOVE : return " breakpoint_remove " ;
63
+ case RequestType::HOOK_INSERT : return " hook_insert " ;
64
+ case RequestType::HOOK_REMOVE : return " hook_remove " ;
65
65
case RequestType::BREAKPOINT_REACHED: return " breakpoint_reached" ;
66
66
case RequestType::BREAKPOINT_UNLOCK: return " breakpoint_unlock" ;
67
- case RequestType::REMOVE_ALL_BREAKPOINTS : return " breakpoint_remove_all " ;
68
- case RequestType::BREAKPOINTS_DUMP : return " breakpoints_dump " ;
69
- case RequestType::DISABLE_ALL_BREAKPOINTS : return " disable_breakpoints " ;
67
+ case RequestType::REMOVE_ALL_HOOKS : return " hooks_remove_all " ;
68
+ case RequestType::HOOKS_DUMP : return " hooks_dump " ;
69
+ case RequestType::DISABLE_ALL_HOOKS : return " disable_hooks " ;
70
70
71
71
case RequestType::UNDEFINED: return " undefined" ;
72
72
}
@@ -182,17 +182,29 @@ inline ReplyHeader DeserializeReplyHeader(const std::string& buffer)
182
182
return header;
183
183
}
184
184
185
- struct Breakpoint
185
+ struct Hook
186
186
{
187
- using Ptr = std::shared_ptr<Breakpoint >;
187
+ using Ptr = std::shared_ptr<Hook >;
188
188
189
189
// used to enable/disable the breakpoint
190
190
bool enabled = true ;
191
191
192
+ enum class Position {
193
+ PRE = 0 ,
194
+ POST = 1
195
+ };
196
+
197
+ Position position = Position::PRE;
198
+
192
199
uint16_t node_uid = 0 ;
193
200
194
- // interactive breakpoints are unblucked using unlockBreakpoint()
195
- bool is_interactive = true ;
201
+ enum class Mode {
202
+ BREAKPOINT = 0 ,
203
+ REPLACE = 1
204
+ };
205
+
206
+ // interactive breakpoints are unblocked using unlockBreakpoint()
207
+ Mode mode = Mode::BREAKPOINT;
196
208
197
209
// used by interactive breakpoints to wait for unlocking
198
210
std::condition_variable wakeup;
@@ -210,21 +222,24 @@ struct Breakpoint
210
222
};
211
223
212
224
213
- void to_json (nlohmann::json& js, const Breakpoint & bp) {
225
+ void to_json (nlohmann::json& js, const Hook & bp) {
214
226
js = nlohmann::json {
215
227
{" enabled" , bp.enabled },
216
228
{" uid" , bp.node_uid },
217
- {" interactive " , bp.is_interactive },
229
+ {" mode " , int ( bp.mode ) },
218
230
{" once" , bp.remove_when_done },
219
- {" desired_status" , toStr (bp.desired_status )}
231
+ {" desired_status" , toStr (bp.desired_status )},
232
+ {" position" , int (bp.position )}
220
233
};
221
234
}
222
235
223
- void from_json (const nlohmann::json& js, Breakpoint & bp) {
236
+ void from_json (const nlohmann::json& js, Hook & bp) {
224
237
js.at (" enabled" ).get_to (bp.enabled );
225
238
js.at (" uid" ).get_to (bp.node_uid );
226
- js.at (" interactive" ).get_to (bp.is_interactive );
227
239
js.at (" once" ).get_to (bp.remove_when_done );
240
+ bp. mode = static_cast <Hook::Mode>(js.at (" mode" ).get <int >());
241
+ bp.position = static_cast <Hook::Position>(js.at (" position" ).get <int >());
242
+
228
243
const std::string desired_value = js.at (" desired_status" ).get <std::string>();
229
244
bp.desired_status = convertFromString<NodeStatus>(desired_value);
230
245
}
0 commit comments