libabigail
abg-elf-based-reader.cc
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-2025 Red Hat, Inc.
5//
6// Author: Dodji Seketeli
7
8/// @file
9///
10/// This file contains the definitions of the entry points of the
11/// generic interface for ELF-based front-ends. The generic interface
12/// for ELF-based front-ends is named @ref elf_based_reader. Examples
13/// of front-ends that implement that interface are @ref
14/// abigail::dwarf_reader::reader and abigail::ctf_raeder::reader.
15
16#include "abg-internal.h"
17
18// <headers defining libabigail's API go under here>
19ABG_BEGIN_EXPORT_DECLARATIONS
20
22
23ABG_END_EXPORT_DECLARATIONS
24// </headers defining libabigail's API>
25namespace abigail
26{
27
28/// The private data of the @ref elf_based_reader type.
29struct elf_based_reader::priv
30{
31
32 void
34 {
35 }
36
37 priv()
38 {
39 initialize();
40 }
41}; // end struct elf_based_reader::priv
42
43/// Constructor of the @erf elf_based_reader type.
44///
45/// @param elf_path the path the ELF file to read.
46///
47/// @param debug_info_root_paths a vector of paths to look into for
48/// split debug info files.
49///
50/// @param env the environment used by the reader.
51elf_based_reader::elf_based_reader(const std::string& elf_path,
52 const vector<char**>& debug_info_root_paths,
53 environment& env)
54 : elf::reader(elf_path, debug_info_root_paths, env),
55 priv_(new priv)
56{
57 priv_->initialize();
58}
59
60/// Destructor of the reader.
62{delete priv_;}
63
64/// (re)Initialize) the resources used by the current reader.
65///
66/// This frees the resources of the current reader and gets it ready
67/// to read data from another ELF file.
68///
69/// @param elf_path the path to the new ELF file to consider.
70///
71/// @param debug_info_root_paths a vector of paths to look into for
72/// split debug info files.
73void
74elf_based_reader::initialize(const std::string& elf_path,
75 const vector<char**>& debug_info_root_paths)
76{
78 priv_->initialize();
79}
80
81/// (re)Initialize the resources used by the current reader.
82///
83/// This invokes fe_iface::initialize as wel as the virtual pure
84/// elf_based_reader::initialize() interface.
85///
86/// @param corpus_path path to the corpus to be built.
87void
88elf_based_reader::initialize(const std::string& corpus_path)
89{
91 vector<char**> v;
92 initialize(corpus_path, v, /*load_all_type=*/false,
93 /*linux_kernel_mode=*/false);
94}
95
96/// Read an ABI corpus and add it to a given corpus group.
97///
98/// @param group the corpus group to consider. The new corpus is
99/// added to this group.
100///
101/// @param status output parameter. This is the status of the
102/// creation of the current ABI corpus. It's set by this function iff
103/// a non-nil @ref corpus_sptr is returned.
104///
105/// @return the resulting ABI corpus.
106ir::corpus_sptr
109{
110 ir::corpus_sptr corp = read_corpus(status);
111 group.add_corpus(corp);
112 return corp;
113}
114
115} // end namespace abigail
This file contains the declarations for an elf-based. DWARF and CTF readers can inherit this one.
virtual ir::corpus_sptr read_corpus(status &status)
Read the ELF information associated to the current ELF file and construct an ABI representation from ...
const vector< char ** > & debug_info_root_paths() const
Getter of the vector of directory paths to look into for split debug information files.
virtual void initialize(const std::string &elf_path, const vector< char ** > &debug_info_roots)
Re-initialize the resources used by the current elf::reader type.
~elf_based_reader()
Destructor of the reader.
virtual ir::corpus_sptr read_and_add_corpus_to_group(ir::corpus_group &group, fe_iface::status &status)
Read an ABI corpus and add it to a given corpus group.
virtual void initialize(const std::string &elf_path, const vector< char ** > &debug_info_root_paths)
(re)Initialize) the resources used by the current reader.
status
The status of the fe_iface::read_corpus call.
Definition: abg-fe-iface.h:38
virtual void initialize(const std::string &corpus_path)
Re-initialize the current Front End.
Definition: abg-fe-iface.cc:81
const std::string & corpus_path() const
Getter of the path to the file which an ABI corpus is to be created for.
Abstraction of a group of corpora.
Definition: abg-corpus.h:386
void add_corpus(const corpus_sptr &)
Add a new corpus to the current instance of corpus_group.
Definition: abg-corpus.cc:1914
This is an abstraction of the set of resources necessary to manage several aspects of the internal re...
Definition: abg-ir.h:148
Toplevel namespace for libabigail.