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 16 #ifndef PANDA_LIBPANDABASE_OS_UNIX_NATIVE_STACK_H_ 17 #define PANDA_LIBPANDABASE_OS_UNIX_NATIVE_STACK_H_ 18 19 #include "os/thread.h" 20 #include <string> 21 #include <set> 22 23 namespace panda::os::unix::native_stack { 24 using FUNC_UNWINDSTACK = bool (*)(pid_t, std::ostream &, int); 25 26 void DumpKernelStack(std::ostream &os, pid_t tid, const char *tag, bool count); 27 28 std::string GetNativeThreadNameForFile(pid_t tid); 29 30 class DumpUnattachedThread { 31 public: 32 void AddTid(pid_t tid_thread); 33 bool InitKernelTidLists(); 34 void Dump(std::ostream &os, bool dump_native_crash, FUNC_UNWINDSTACK call_unwindstack); 35 36 private: 37 std::set<pid_t> kernel_tid_; 38 std::set<pid_t> thread_manager_tids_; 39 }; 40 41 bool ReadOsFile(const std::string &file_name, std::string *result); 42 bool WriterOsFile(const void *buffer, size_t count, int fd); 43 std::string ChangeJaveStackFormat(const char *descriptor); 44 45 } // namespace panda::os::unix::native_stack 46 47 #endif // PANDA_LIBPANDABASE_OS_UNIX_NATIVE_STACK_H_ 48