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 /* This files contains process dump header. */ 17 18 #ifndef DFX_SYMBOLS_CACHE_H 19 #define DFX_SYMBOLS_CACHE_H 20 21 #include <cstdint> 22 #include <string> 23 #include <vector> 24 #include "iosfwd" 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 typedef struct DfxSymbol { 30 uint64_t start; 31 uint64_t end; 32 std::string funcName; 33 } DfxSymbol; 34 #ifdef __cplusplus 35 }; 36 #endif 37 struct unw_addr_space; 38 namespace OHOS { 39 namespace HiviewDFX { 40 class DfxSymbolsCache final { 41 public: DfxSymbolsCache()42 DfxSymbolsCache() {}; ~DfxSymbolsCache()43 ~DfxSymbolsCache() {}; 44 bool GetNameAndOffsetByPc(struct unw_addr_space *as, uint64_t pc, std::string& name, uint64_t& offset); 45 46 private: 47 bool GetNameAndOffsetByPc(uint64_t pc, std::string& name, uint64_t& offset); 48 std::vector<DfxSymbol> cachedSymbols_; 49 }; 50 } // namespace HiviewDFX 51 } // namespace OHOS 52 53 #endif // DFX_SYMBOL_CACHE_H 54