xref: /aosp_15_r20/external/perfetto/src/profiling/symbolizer/breakpad_symbolizer.h (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1 /*
2  * Copyright (C) 2021 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 SRC_PROFILING_SYMBOLIZER_BREAKPAD_SYMBOLIZER_H_
18 #define SRC_PROFILING_SYMBOLIZER_BREAKPAD_SYMBOLIZER_H_
19 
20 #include "perfetto/ext/base/string_view.h"
21 #include "src/profiling/symbolizer/symbolizer.h"
22 
23 namespace perfetto {
24 namespace profiling {
25 
26 // A subclass of Symbolizer that overrides the Symbolize method to make the
27 // symbolization process work for breakpad files.
28 class BreakpadSymbolizer : public Symbolizer {
29  public:
30   // Takes the path to a folder containing breakpad symbol files as an argument.
31   // The files in this folder will be used to symbolize a given trace. Each
32   // breakpad symbol file should use the upper case hex representation of the
33   // module ID, contained in the first line of the file, as the name of the
34   // file, with a ".breakpad" suffix. eg: <module_id>.breakpad.
35   explicit BreakpadSymbolizer(const std::string& symbol_dir_path);
36 
37   BreakpadSymbolizer(BreakpadSymbolizer&& other) = default;
38   BreakpadSymbolizer& operator=(BreakpadSymbolizer&& other) = default;
39 
40   std::vector<std::vector<SymbolizedFrame>> Symbolize(
41       const std::string&,
42       const std::string& build_id,
43       uint64_t,
44       const std::vector<uint64_t>& address) override;
45 
SetBreakpadFileForTesting(const std::string & path)46   void SetBreakpadFileForTesting(const std::string& path) {
47     file_path_for_testing_ = path;
48   }
49 
50  private:
51   std::string symbol_dir_path_;
52   std::string file_path_for_testing_;
53 };
54 
55 }  // namespace profiling
56 }  // namespace perfetto
57 
58 #endif  // SRC_PROFILING_SYMBOLIZER_BREAKPAD_SYMBOLIZER_H_
59