1 /** 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PANDA_TOOLING_INSPECTOR_BREAKPOINT_HOOKS_H 17 #define PANDA_TOOLING_INSPECTOR_BREAKPOINT_HOOKS_H 18 19 #include "tooling/debug_interface.h" 20 #include "tooling/pt_location.h" 21 22 #include <cstddef> 23 #include <map> 24 25 namespace panda { 26 class JsonObject; 27 class JsonObjectBuilder; 28 } // namespace panda 29 30 namespace panda::tooling::inspector { 31 class Inspector; 32 class SourceFile; 33 34 class BreakpointHooks : public PtHooks { 35 public: 36 explicit BreakpointHooks(Inspector &inspector); 37 38 void Breakpoint(PtThread thread, Method * /* method */, const PtLocation & /* location */) override; 39 40 private: 41 void GetPossibleBreakpoints(JsonObjectBuilder &result, const JsonObject ¶ms); 42 void RemoveBreakpoint(const JsonObject ¶ms); 43 bool SetBreakpoint(size_t breakpointId, const SourceFile &sourceFile, size_t lineNumber); 44 void SetBreakpointAtLocation(JsonObjectBuilder &result, const JsonObject ¶ms); 45 void SetBreakpointByUrl(JsonObjectBuilder &result, const JsonObject ¶ms); 46 void SetBreakpointsActive(const JsonObject ¶ms); 47 GenerateBreakpointId()48 size_t GenerateBreakpointId() 49 { 50 return nextId_++; 51 } 52 53 Inspector &inspector_; 54 bool active_ {true}; 55 std::multimap<size_t, PtLocation> locations_; 56 size_t nextId_ {0}; 57 }; 58 } // namespace panda::tooling::inspector 59 60 #endif // PANDA_TOOLING_INSPECTOR_BREAKPOINT_HOOKS_H 61