libabigail
abg-fe-iface.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2 // -*- Mode: C++ -*-
3 //
4 // Copyright (C) 2022-2023 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
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.
47 
48  /// This status is for when the alternate debug info could not be
49  /// found.
51 
52  /// This status is for when the symbols of the ELF binaries could
53  /// not be read.
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  /// If this option is set to true, then the functions and
65  /// variables that have an undefined symbol are going to be
66  /// represented in the IR.
68  bool drop_undefined_syms = false;
69  bool show_stats = false;
70  bool do_log = false;
71  bool leverage_dwarf_factorization = true;
72  bool assume_odr_for_cplusplus = true;
74 
75  };// font_end_iface::options_type
76 
77  fe_iface(const std::string& corpus_path, environment& e);
78 
79  virtual ~fe_iface();
80 
81  virtual void
82  initialize(const std::string& corpus_path);
83 
84  const options_type&
85  options() const;
86 
88  options();
89 
90  const std::string&
91  corpus_path() const;
92 
93  void
94  corpus_path(const std::string&);
95 
96  const string&
97  dt_soname() const;
98 
99  void
100  dt_soname(const string&);
101 
102  bool
104 
106  suppressions();
107 
109  suppressions() const;
110 
111  void
113 
114  void
116 
117  corpus_sptr
118  corpus();
119 
120  const corpus_sptr
121  corpus() const;
122 
123  corpus_group_sptr&
124  corpus_group();
125 
126  const corpus_group_sptr&
127  corpus_group() const;
128 
129  void
130  corpus_group(const ir::corpus_group_sptr& cg);
131 
132  bool
133  has_corpus_group() const;
134 
135  corpus_sptr
137 
138  bool
140 
141  corpus_sptr
143 
144  void
146 
147  void
149 
150  virtual ir::corpus_sptr
151  read_corpus(status& status) = 0;
152 }; //end class fe_iface
153 
154 typedef shared_ptr<fe_iface> fe_iface_sptr;
155 
156 std::string
158 
161 
164 
167 
170 
171 }// end namespace abigail
172 #endif // __ABG_FE_IFAC_H__
Types of the main internal representation of libabigail.
The base class of all libabigail front-ends: The Front End Interface.
Definition: abg-fe-iface.h:29
bool has_corpus_group() const
Test if there is a corpus group being built.
status
The status of the fe_iface::read_corpus call.
Definition: abg-fe-iface.h:38
@ STATUS_NO_SYMBOLS_FOUND
This status is for when the symbols of the ELF binaries could not be read.
Definition: abg-fe-iface.h:54
@ STATUS_DEBUG_INFO_NOT_FOUND
This status is for when the debug info could not be read.
Definition: abg-fe-iface.h:46
@ STATUS_ALT_DEBUG_INFO_NOT_FOUND
This status is for when the alternate debug info could not be found.
Definition: abg-fe-iface.h:50
@ STATUS_OK
This status is for when the call went OK.
Definition: abg-fe-iface.h:43
@ STATUS_UNKNOWN
The status is in an unknown state.
Definition: abg-fe-iface.h:40
const options_type & options() const
Getter of the the options of the current Front End Interface.
Definition: abg-fe-iface.cc:92
void add_fn_to_exported_or_undefined_decls(const function_decl *fn)
Add the representation of the ABI of a function to the set of exported declarations or undefined decl...
corpus_sptr corpus()
Getter for the ABI corpus being built by the current front-end.
suppr::suppressions_type & suppressions()
Getter of the vector of suppression specifications associated with the current front-end.
corpus_group_sptr & corpus_group()
Getter for the ABI corpus group being built by the current front-end.
fe_iface(const std::string &corpus_path, environment &e)
Constructor of the type fe_iface.
Definition: abg-fe-iface.cc:68
virtual void initialize(const std::string &corpus_path)
Re-initialize the current Front End.
Definition: abg-fe-iface.cc:82
corpus_sptr should_reuse_type_from_corpus_group()
Return true if the current corpus is part of a corpus group being built and if it's not the main corp...
bool load_in_linux_kernel_mode() const
Test if the input binary is to be considered as a Linux Kernel binary.
bool current_corpus_is_main_corpus_from_current_group()
Test if the current corpus being built is the main corpus of the current corpus group.
virtual ~fe_iface()
Desctructor of the Front End Interface.
Definition: abg-fe-iface.cc:74
void add_var_to_exported_or_undefined_decls(const var_decl *var)
Add the representation of the ABI of a variable to the set of exported or undefined declarations of t...
const std::string & corpus_path() const
Getter of the path to the file which an ABI corpus is to be created for.
const string & dt_soname() const
Getter for the SONAME of the analyzed binary.
corpus_sptr main_corpus_from_current_group()
Return the main corpus from the current corpus group, if any.
void add_suppressions(const suppr::suppressions_type &)
Add suppressions specifications to the set of suppressions to be used during the construction of the ...
This is an abstraction of the set of resources necessary to manage several aspects of the internal re...
Definition: abg-ir.h:140
Abstraction for a function declaration.
Definition: abg-ir.h:3111
Abstracts a variable declaration.
Definition: abg-ir.h:3008
vector< suppression_sptr > suppressions_type
Convenience typedef for a vector of suppression_sptr.
Definition: abg-fwd.h:1658
Toplevel namespace for libabigail.
fe_iface::status & operator|=(fe_iface::status &l, fe_iface::status r)
The bitwise |= operator for the fe_iface::status type.
fe_iface::status & operator&=(fe_iface::status &l, fe_iface::status r)
The bitwise &= operator for the fe_iface::status type.
fe_iface::status operator&(fe_iface::status l, fe_iface::status r)
The bitwise AND operator for the fe_iface::status type.
fe_iface::status operator|(fe_iface::status l, fe_iface::status r)
The bitwise OR operator for the fe_iface::status type.
std::string status_to_diagnostic_string(fe_iface::status s)
Return a diagnostic status with english sentences to describe the problems encoded in a given abigail...
The generic options that control the behaviour of all Front-End interfaces.
Definition: abg-fe-iface.h:60
options_type(environment &)
Constructor of the type fe_iface::options_type.
Definition: abg-fe-iface.cc:57
bool load_undefined_interfaces
If this option is set to true, then the functions and variables that have an undefined symbol are goi...
Definition: abg-fe-iface.h:67