xref: /aosp_15_r20/external/stg/dwarf_processor.h (revision 9e3b08ae94a55201065475453d799e8b1378bea6)
1*9e3b08aeSAndroid Build Coastguard Worker // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2*9e3b08aeSAndroid Build Coastguard Worker // -*- mode: C++ -*-
3*9e3b08aeSAndroid Build Coastguard Worker //
4*9e3b08aeSAndroid Build Coastguard Worker // Copyright 2022 Google LLC
5*9e3b08aeSAndroid Build Coastguard Worker //
6*9e3b08aeSAndroid Build Coastguard Worker // Licensed under the Apache License v2.0 with LLVM Exceptions (the
7*9e3b08aeSAndroid Build Coastguard Worker // "License"); you may not use this file except in compliance with the
8*9e3b08aeSAndroid Build Coastguard Worker // License.  You may obtain a copy of the License at
9*9e3b08aeSAndroid Build Coastguard Worker //
10*9e3b08aeSAndroid Build Coastguard Worker //     https://llvm.org/LICENSE.txt
11*9e3b08aeSAndroid Build Coastguard Worker //
12*9e3b08aeSAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
13*9e3b08aeSAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
14*9e3b08aeSAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15*9e3b08aeSAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
16*9e3b08aeSAndroid Build Coastguard Worker // limitations under the License.
17*9e3b08aeSAndroid Build Coastguard Worker //
18*9e3b08aeSAndroid Build Coastguard Worker // Author: Aleksei Vetrov
19*9e3b08aeSAndroid Build Coastguard Worker 
20*9e3b08aeSAndroid Build Coastguard Worker #ifndef STG_DWARF_PROCESSOR_H_
21*9e3b08aeSAndroid Build Coastguard Worker #define STG_DWARF_PROCESSOR_H_
22*9e3b08aeSAndroid Build Coastguard Worker 
23*9e3b08aeSAndroid Build Coastguard Worker #include <elfutils/libdw.h>
24*9e3b08aeSAndroid Build Coastguard Worker 
25*9e3b08aeSAndroid Build Coastguard Worker #include <cstddef>
26*9e3b08aeSAndroid Build Coastguard Worker #include <memory>
27*9e3b08aeSAndroid Build Coastguard Worker #include <string>
28*9e3b08aeSAndroid Build Coastguard Worker #include <vector>
29*9e3b08aeSAndroid Build Coastguard Worker 
30*9e3b08aeSAndroid Build Coastguard Worker #include "dwarf_wrappers.h"
31*9e3b08aeSAndroid Build Coastguard Worker #include "filter.h"
32*9e3b08aeSAndroid Build Coastguard Worker #include "graph.h"
33*9e3b08aeSAndroid Build Coastguard Worker 
34*9e3b08aeSAndroid Build Coastguard Worker namespace stg {
35*9e3b08aeSAndroid Build Coastguard Worker namespace dwarf {
36*9e3b08aeSAndroid Build Coastguard Worker 
37*9e3b08aeSAndroid Build Coastguard Worker struct Types {
38*9e3b08aeSAndroid Build Coastguard Worker   struct Symbol {
39*9e3b08aeSAndroid Build Coastguard Worker     std::string scoped_name;
40*9e3b08aeSAndroid Build Coastguard Worker     std::string linkage_name;
41*9e3b08aeSAndroid Build Coastguard Worker     Address address;
42*9e3b08aeSAndroid Build Coastguard Worker     Id type_id;
43*9e3b08aeSAndroid Build Coastguard Worker   };
44*9e3b08aeSAndroid Build Coastguard Worker 
45*9e3b08aeSAndroid Build Coastguard Worker   size_t processed_entries = 0;
46*9e3b08aeSAndroid Build Coastguard Worker   // Container for all named type IDs allocated during DWARF processing.
47*9e3b08aeSAndroid Build Coastguard Worker   std::vector<Id> named_type_ids;
48*9e3b08aeSAndroid Build Coastguard Worker   std::vector<Symbol> symbols;
49*9e3b08aeSAndroid Build Coastguard Worker };
50*9e3b08aeSAndroid Build Coastguard Worker 
51*9e3b08aeSAndroid Build Coastguard Worker // Process every compilation unit from DWARF and returns processed STG along
52*9e3b08aeSAndroid Build Coastguard Worker // with information needed for matching to ELF symbols.
53*9e3b08aeSAndroid Build Coastguard Worker // If DWARF is missing, returns empty result.
54*9e3b08aeSAndroid Build Coastguard Worker Types Process(Dwarf* dwarf, bool is_little_endian_binary,
55*9e3b08aeSAndroid Build Coastguard Worker               const std::unique_ptr<Filter>& file_filter, Graph& graph);
56*9e3b08aeSAndroid Build Coastguard Worker 
57*9e3b08aeSAndroid Build Coastguard Worker }  // namespace dwarf
58*9e3b08aeSAndroid Build Coastguard Worker }  // namespace stg
59*9e3b08aeSAndroid Build Coastguard Worker 
60*9e3b08aeSAndroid Build Coastguard Worker #endif  // STG_DWARF_PROCESSOR_H_
61