1 /* 2 * Copyright (C) 2021 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 #ifndef EVENT_LOGGER_COMMAND_CATCHER 16 #define EVENT_LOGGER_COMMAND_CATCHER 17 18 #include <map> 19 #include <string> 20 #include <vector> 21 22 #include "event_log_catcher.h" 23 namespace OHOS { 24 namespace HiviewDFX { 25 class CommandCatcher : public EventLogCatcher { 26 public: 27 explicit CommandCatcher(); ~CommandCatcher()28 ~CommandCatcher() override {}; 29 bool Initialize(const std::string& packageNam, int pid, int intParam2) override; 30 int Catch(int fd) override; 31 void AddCmd(const std::vector<std::string>& cmd); GetPid()32 int GetPid() const 33 { 34 return pid_; 35 } 36 private: 37 int pid_ = -1; 38 std::string packageName_ = ""; 39 std::vector<std::vector<std::string>> cmdString_; 40 41 int HiDumper(int fd, const std::vector<std::string> &args); 42 }; 43 } // namespace HiviewDFX 44 } // namespace OHOS 45 #endif // EVENT_LOGGER_BINDER_LOG_CATCHER