1/* 2 * Copyright (c) 2021-2023 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#include "dump_catcher.h" 17 18#include "dfx_define.h" 19#include "dfx_dump_catcher.h" 20#include "dfx_log.h" 21 22namespace OHOS { 23namespace HiviewDFX { 24DumpCatcher &DumpCatcher::GetInstance() 25{ 26 static DumpCatcher ins; 27 return ins; 28} 29 30void DumpCatcher::Dump(int32_t pid, int32_t tid) const 31{ 32 DfxDumpCatcher dfxDump; 33 std::string msg = ""; 34 bool dumpRet = dfxDump.DumpCatch(pid, tid, msg); 35 if (!dumpRet) { 36 printf("Dump Failed.\n"); 37 } 38 if (!msg.empty()) { 39 printf("%s\n", msg.c_str()); 40 } else { 41 printf("Dump msg empty.\n"); 42 } 43} 44} // namespace HiviewDFX 45} // namespace OHOS 46