@@ -33,21 +33,21 @@ enum RequestType : uint8_t
3333 // retrieve the valus in a set of blackboards
3434 BLACKBOARD = ' B' ,
3535
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' ,
4040 // Notify Groot that we reached a breakpoint
4141 BREAKPOINT_REACHED = ' N' ,
4242 // Groot will unlock a breakpoint
4343 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' ,
4646
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' ,
4949
50- DISABLE_ALL_BREAKPOINTS = ' X' ,
50+ DISABLE_ALL_HOOKS = ' X' ,
5151
5252 UNDEFINED = 0 ,
5353};
@@ -60,13 +60,13 @@ inline const char* ToString(const RequestType& type)
6060 case RequestType::STATUS: return " status" ;
6161 case RequestType::BLACKBOARD: return " blackboard" ;
6262
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 " ;
6565 case RequestType::BREAKPOINT_REACHED: return " breakpoint_reached" ;
6666 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 " ;
7070
7171 case RequestType::UNDEFINED: return " undefined" ;
7272 }
@@ -182,17 +182,29 @@ inline ReplyHeader DeserializeReplyHeader(const std::string& buffer)
182182 return header;
183183}
184184
185- struct Breakpoint
185+ struct Hook
186186{
187- using Ptr = std::shared_ptr<Breakpoint >;
187+ using Ptr = std::shared_ptr<Hook >;
188188
189189 // used to enable/disable the breakpoint
190190 bool enabled = true ;
191191
192+ enum class Position {
193+ PRE = 0 ,
194+ POST = 1
195+ };
196+
197+ Position position = Position::PRE;
198+
192199 uint16_t node_uid = 0 ;
193200
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;
196208
197209 // used by interactive breakpoints to wait for unlocking
198210 std::condition_variable wakeup;
@@ -210,21 +222,24 @@ struct Breakpoint
210222};
211223
212224
213- void to_json (nlohmann::json& js, const Breakpoint & bp) {
225+ void to_json (nlohmann::json& js, const Hook & bp) {
214226 js = nlohmann::json {
215227 {" enabled" , bp.enabled },
216228 {" uid" , bp.node_uid },
217- {" interactive " , bp.is_interactive },
229+ {" mode " , int ( bp.mode ) },
218230 {" once" , bp.remove_when_done },
219- {" desired_status" , toStr (bp.desired_status )}
231+ {" desired_status" , toStr (bp.desired_status )},
232+ {" position" , int (bp.position )}
220233 };
221234}
222235
223- void from_json (const nlohmann::json& js, Breakpoint & bp) {
236+ void from_json (const nlohmann::json& js, Hook & bp) {
224237 js.at (" enabled" ).get_to (bp.enabled );
225238 js.at (" uid" ).get_to (bp.node_uid );
226- js.at (" interactive" ).get_to (bp.is_interactive );
227239 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+
228243 const std::string desired_value = js.at (" desired_status" ).get <std::string>();
229244 bp.desired_status = convertFromString<NodeStatus>(desired_value);
230245}
0 commit comments