blob: 3c0d0332dbc217688ffcd67997903b47d34b22d6 [file] [log] [blame]
Christopher Ferrise7ba4cc2017-04-04 14:06:58 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _LIBUNWINDSTACK_SYMBOLS_H
18#define _LIBUNWINDSTACK_SYMBOLS_H
19
20#include <stdint.h>
21
22#include <string>
23#include <vector>
24
25// Forward declaration.
26class Memory;
27
28class Symbols {
29 struct Info {
30 Info(uint64_t start_offset, uint64_t end_offset, uint64_t str_offset)
31 : start_offset(start_offset), end_offset(end_offset), str_offset(str_offset) {}
32 uint64_t start_offset;
33 uint64_t end_offset;
34 uint64_t str_offset;
35 };
36
37 public:
38 Symbols(uint64_t offset, uint64_t size, uint64_t entry_size, uint64_t str_offset,
39 uint64_t str_size);
40 virtual ~Symbols() = default;
41
42 const Info* GetInfoFromCache(uint64_t addr);
43
44 template <typename SymType>
45 bool GetName(uint64_t addr, uint64_t load_bias, Memory* elf_memory, std::string* name,
46 uint64_t* func_offset);
47
48 void ClearCache() {
49 symbols_.clear();
50 cur_offset_ = offset_;
51 }
52
53 private:
54 uint64_t cur_offset_;
55 uint64_t offset_;
56 uint64_t end_;
57 uint64_t entry_size_;
58 uint64_t str_offset_;
59 uint64_t str_end_;
60
61 std::vector<Info> symbols_;
62};
63
64#endif // _LIBUNWINDSTACK_SYMBOLS_H