2 * Copyright 2013 Facebook, Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef FOLLY_EXPERIMENTAL_SYMBOLIZER_SYMBOLIZER_H_
19 #define FOLLY_EXPERIMENTAL_SYMBOLIZER_SYMBOLIZER_H_
23 #include <unordered_map>
25 #include "folly/Range.h"
26 #include "folly/experimental/symbolizer/Elf.h"
27 #include "folly/experimental/symbolizer/Dwarf.h"
30 namespace symbolizer {
33 * Convert an address to symbol name and source location.
38 * Symbolize an instruction pointer address, returning the symbol name
39 * and file/line number information.
41 * The returned StringPiece objects are valid for the lifetime of
42 * this Symbolizer object.
44 bool symbolize(uintptr_t address, folly::StringPiece& symbolName,
45 Dwarf::LocationInfo& location);
47 static void write(std::ostream& out, uintptr_t address,
48 folly::StringPiece symbolName,
49 const Dwarf::LocationInfo& location);
52 ElfFile& getFile(const std::string& name);
53 // cache open ELF files
54 std::unordered_map<std::string, ElfFile> elfFiles_;
57 } // namespace symbolizer
60 #endif /* FOLLY_EXPERIMENTAL_SYMBOLIZER_SYMBOLIZER_H_ */