1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 // -*- Mode: C++ -*- 3 // 4 // Copyright (C) 2022 Red Hat, Inc. 5 // 6 // Author: Dodji Seketeli 7 8 /// @file 9 /// 10 /// This file contains the declarations for the @ref fe_iface a.k.a 11 /// "Front End Interface". 12 13 #ifndef __ABG_FE_IFACE_H__ 14 #define __ABG_FE_IFACE_H__ 15 16 #include "abg-ir.h" 17 #include "abg-suppression.h" 18 19 namespace abigail 20 { 21 22 /// The base class of all libabigail front-ends: The Front End Interface. 23 /// 24 /// A front end reads a given type of binary format and constructs a 25 /// libagbigail internal representation from it. 26 /// 27 /// The middle-end then manipulates that IR. 28 class fe_iface 29 { 30 protected: 31 struct priv; 32 priv* priv_; 33 34 public: 35 36 /// The status of the @ref fe_iface::read_corpus call. 37 enum status 38 { 39 /// The status is in an unknown state 40 STATUS_UNKNOWN = 0, 41 42 /// This status is for when the call went OK. 43 STATUS_OK = 1, 44 45 /// This status is for when the debug info could not be read. 46 STATUS_DEBUG_INFO_NOT_FOUND = 1 << 1, 47 48 /// This status is for when the alternate debug info could not be 49 /// found. 50 STATUS_ALT_DEBUG_INFO_NOT_FOUND = 1 << 2, 51 52 /// This status is for when the symbols of the ELF binaries could 53 /// not be read. 54 STATUS_NO_SYMBOLS_FOUND = 1 << 3, 55 }; 56 57 /// The generic options that control the behaviour of all Front-End 58 /// interfaces. 59 struct options_type 60 { 61 environment& env; 62 bool load_in_linux_kernel_mode = false; 63 bool load_all_types = false; 64 bool drop_undefined_syms = false; 65 bool show_stats = false; 66 bool do_log = false; 67 bool leverage_dwarf_factorization = true; 68 bool assume_odr_for_cplusplus = true; 69 options_type(environment&); 70 71 };// font_end_iface::options_type 72 73 fe_iface(const std::string& corpus_path, environment& e); 74 75 virtual ~fe_iface(); 76 77 void 78 reset(const std::string& corpus_path, environment& e); 79 80 const options_type& 81 options() const; 82 83 options_type& 84 options(); 85 86 const std::string& 87 corpus_path() const; 88 89 void 90 corpus_path(const std::string&); 91 92 const string& 93 dt_soname() const; 94 95 void 96 dt_soname(const string&); 97 98 bool 99 load_in_linux_kernel_mode() const; 100 101 suppr::suppressions_type& 102 suppressions(); 103 104 const suppr::suppressions_type& 105 suppressions() const; 106 107 void 108 suppressions(suppr::suppressions_type&); 109 110 void 111 add_suppressions(const suppr::suppressions_type&); 112 113 corpus_sptr 114 corpus(); 115 116 const corpus_sptr 117 corpus() const; 118 119 corpus_group_sptr& 120 corpus_group(); 121 122 const corpus_group_sptr& 123 corpus_group() const; 124 125 void 126 corpus_group(const ir::corpus_group_sptr& cg); 127 128 bool 129 has_corpus_group() const; 130 131 corpus_sptr 132 main_corpus_from_current_group(); 133 134 bool 135 current_corpus_is_main_corpus_from_current_group(); 136 137 corpus_sptr 138 should_reuse_type_from_corpus_group(); 139 140 void 141 maybe_add_fn_to_exported_decls(const function_decl* fn); 142 143 void 144 maybe_add_var_to_exported_decls(const var_decl* var); 145 146 virtual ir::corpus_sptr 147 read_corpus(status& status) = 0; 148 }; //end class fe_iface 149 150 typedef shared_ptr<fe_iface> fe_iface_sptr; 151 152 std::string 153 status_to_diagnostic_string(fe_iface::status s); 154 155 fe_iface::status 156 operator|(fe_iface::status, fe_iface::status); 157 158 fe_iface::status 159 operator&(fe_iface::status, fe_iface::status); 160 161 fe_iface::status& 162 operator|=(fe_iface::status&, fe_iface::status); 163 164 fe_iface::status& 165 operator&=(fe_iface::status&, fe_iface::status); 166 167 }// end namespace abigail 168 #endif // __ABG_FE_IFAC_H__ 169