@@ -56,7 +56,7 @@ namespace btf
/// @return a smart pointer to the resulting btf::reader.
elf_based_reader_sptr
create_reader(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& env,
bool load_all_types = false,
bool linux_kernel_mode = false);
@@ -30,13 +30,13 @@ namespace ctf
elf_based_reader_sptr
create_reader(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& env);
void
reset_reader(elf_based_reader& ctxt,
const std::string& elf_path,
- const vector<char**>& debug_info_root_path);
+ const vector<string>& debug_info_root_path);
} // end namespace ctf_reader
} // end namespace abigail
@@ -31,7 +31,7 @@ using namespace abigail::ir;
elf_based_reader_sptr
create_reader(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& environment,
bool read_all_types = false,
bool linux_kernel_mode = false);
@@ -39,13 +39,13 @@ create_reader(const std::string& elf_path,
void
reset_reader(elf_based_reader& rdr,
const std::string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
bool read_all_types = false,
bool linux_kernel_mode = false);
corpus_sptr
read_corpus_from_elf(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& environment,
bool load_all_types,
fe_iface::status& status);
@@ -43,7 +43,7 @@ protected:
/// method to create a reader instance as this constructor is
/// protected.
elf_based_reader(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& env);
public:
@@ -51,7 +51,7 @@ public:
virtual void
initialize(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths);
+ const vector<string>& debug_info_root_paths);
virtual ir::corpus_sptr
read_and_add_corpus_to_group(ir::corpus_group& group,
@@ -59,7 +59,7 @@ public:
virtual void
initialize(const string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
bool load_all_types,
bool linux_kernel_mode) = 0;
@@ -67,19 +67,19 @@ class reader : public fe_iface
public:
reader(const std::string& elf_path,
- const vector<char**>& debug_info_roots,
+ const vector<string>& debug_info_roots,
environment& env);
~reader();
virtual void
initialize(const std::string& elf_path,
- const vector<char**>& debug_info_roots);
+ const vector<string>& debug_info_roots);
virtual void
initialize(const std::string& elf_path);
- const vector<char**>&
+ const vector<string>&
debug_info_root_paths() const;
const Dwfl_Callbacks&
@@ -40,11 +40,11 @@ const char* get_anonymous_subrange_internal_name_prefix();
bool file_exists(const string&);
bool is_regular_file(const string&);
bool file_has_dwarf_debug_info(const string& elf_file_path,
- const vector<char**>& debug_info_root_paths);
+ const vector<string>& debug_info_root_paths);
bool file_has_ctf_debug_info(const string& elf_file_path,
- const vector<char**>& debug_info_root_paths);
+ const vector<string>& debug_info_root_paths);
bool file_has_btf_debug_info(const string& elf_file_path,
- const vector<char**>& debug_info_root_paths);
+ const vector<string>& debug_info_root_paths);
bool is_dir(const string&);
bool dir_exists(const string&);
bool dir_is_empty(const string &);
@@ -114,6 +114,9 @@ get_binary_paths_from_kernel_dist(const string& dist_root,
string& vmlinux_path,
vector<string>& module_paths);
+bool
+get_file_path_dirs_under_dir(const string& root, vector<string>& dirs);
+
string
get_default_system_suppression_file_path();
@@ -366,6 +369,9 @@ file_is_kernel_debuginfo_package(const string& file_path,
std::shared_ptr<char>
make_path_absolute(const char*p);
+string
+make_path_absolute(const string& p);
+
char*
make_path_absolute_to_be_freed(const char*p);
@@ -382,7 +388,7 @@ build_corpus_group_from_kernel_dist_under(const string& root,
elf_based_reader_sptr
create_best_elf_based_reader(const string& elf_file_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& env,
corpus::origin requested_debug_info_kind,
bool show_all_types,
@@ -409,7 +409,7 @@ protected:
/// @param linux_kernel_mode
void
initialize(const string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
bool load_all_types,
bool linux_kernel_mode)
{
@@ -448,7 +448,7 @@ protected:
/// @param linux_kernel_mode if true, then consider the binary being
/// analyzed as a linux kernel binary.
reader(const string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& environment,
bool load_all_types,
bool linux_kernel_mode)
@@ -479,7 +479,7 @@ public:
/// analyzed as a linux kernel binary.
static btf::reader_sptr
create(const string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& environment,
bool load_all_types,
bool linux_kernel_mode)
@@ -1330,7 +1330,7 @@ public:
/// @return a smart pointer to the resulting btf::reader.
elf_based_reader_sptr
create_reader(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& env,
bool load_all_types,
bool linux_kernel_mode)
@@ -261,7 +261,7 @@ public:
/// that ABI artifacts that are to be compared all need to be
/// created within the same environment.
reader(const string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& env)
: elf_based_reader(elf_path, debug_info_root_paths, env),
ctfa(), ctf_sect(), symtab_sect(), strtab_sect()
@@ -311,7 +311,7 @@ public:
///
void
initialize(const string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
bool load_all_types = false,
bool linux_kernel_mode = false)
{
@@ -385,7 +385,7 @@ public:
// for vmlinux.ctfa should be provided with --debug-info-dir
// option.
for (const auto& path : debug_info_root_paths())
- if (tools_utils::find_file_under_dir(*path, "vmlinux.ctfa", ctfa_file))
+ if (tools_utils::find_file_under_dir(path, "vmlinux.ctfa", ctfa_file))
return true;
return false;
@@ -1753,7 +1753,7 @@ fill_ctf_section(const Elf_Scn *elf_section, ctf_sect_t *ctf_section)
/// @param env a libabigail IR environment.
elf_based_reader_sptr
create_reader(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& env)
{
reader_sptr result(new reader(elf_path,
@@ -1781,7 +1781,7 @@ create_reader(const std::string& elf_path,
void
reset_reader(elf_based_reader& rdr,
const std::string& elf_path,
- const vector<char**>& debug_info_root_path)
+ const vector<string>& debug_info_root_path)
{
ctf::reader& r = dynamic_cast<reader&>(rdr);
r.initialize(elf_path, debug_info_root_path);
@@ -2114,7 +2114,7 @@ protected:
/// linux kernel symbol tables when determining if a symbol is
/// exported or not.
reader(const string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& environment,
bool load_all_types,
bool linux_kernel_mode)
@@ -2215,7 +2215,7 @@ public:
/// is exported or not.
void
initialize(const string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
bool load_all_types,
bool linux_kernel_mode)
{
@@ -2242,7 +2242,7 @@ public:
/// is exported or not.
static dwarf::reader_sptr
create(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& environment,
bool load_all_types,
bool linux_kernel_mode)
@@ -17801,7 +17801,7 @@ build_ir_node_from_die(reader& rdr,
/// @return a smart pointer to the resulting dwarf::reader.
elf_based_reader_sptr
create_reader(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& environment,
bool load_all_types,
bool linux_kernel_mode)
@@ -17852,7 +17852,7 @@ create_reader(const std::string& elf_path,
void
reset_reader(elf_based_reader& rdr,
const std::string& elf_path,
- const vector<char**>&debug_info_root_path,
+ const vector<string>&debug_info_root_path,
bool read_all_types,
bool linux_kernel_mode)
{
@@ -17895,7 +17895,7 @@ reset_reader(elf_based_reader& rdr,
/// @return the resulting status.
corpus_sptr
read_corpus_from_elf(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& environment,
bool load_all_types,
fe_iface::status& status)
@@ -49,7 +49,7 @@ struct elf_based_reader::priv
///
/// @param env the environment used by the reader.
elf_based_reader::elf_based_reader(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& env)
: elf::reader(elf_path, debug_info_root_paths, env),
priv_(new priv)
@@ -72,7 +72,7 @@ elf_based_reader::~elf_based_reader()
/// split debug info files.
void
elf_based_reader::initialize(const std::string& elf_path,
- const vector<char**>& debug_info_root_paths)
+ const vector<string>& debug_info_root_paths)
{
elf::reader::initialize(elf_path, debug_info_root_paths);
priv_->initialize();
@@ -88,7 +88,7 @@ void
elf_based_reader::initialize(const std::string& corpus_path)
{
fe_iface::initialize(corpus_path);
- vector<char**> v;
+ vector<string> v;
initialize(corpus_path, v, /*load_all_type=*/false,
/*linux_kernel_mode=*/false);
}
@@ -112,7 +112,7 @@ struct reader::priv
// demand.
mutable symtab_reader::symtab_sptr symt;
// Where split debug info is to be searched for on disk.
- vector<char**> debug_info_root_paths;
+ vector<string> debug_info_root_paths;
// The formatted string version of debug_info_root_paths. The
// format is according to what elfutils expects. For the details of
// what elfutils expects, please read the comments of the function
@@ -145,7 +145,7 @@ struct reader::priv
Elf_Scn* btf_section = nullptr;
priv(reader& reeder, const std::string& elf_path,
- const vector<char**>& debug_info_roots)
+ const vector<string>& debug_info_roots)
: rdr(reeder)
{
rdr.corpus_path(elf_path);
@@ -163,7 +163,7 @@ struct reader::priv
/// @param debug_info_roots the vector of new directories where to
/// look for split debug info file.
void
- initialize(const vector<char**>& debug_info_roots)
+ initialize(const vector<string>& debug_info_roots)
{
clear_alt_dwarf_debug_info_data();
clear_alt_ctf_debug_info_data();
@@ -207,8 +207,8 @@ struct reader::priv
{
if (formated_di_root_paths.empty())
formated_di_root_paths = "-";
- if (*path)
- formated_di_root_paths += string(*path) + string (":");
+ if (!path.empty())
+ formated_di_root_paths += path + ":";
}
raw_formated_di_root_paths =
const_cast<char*>(formated_di_root_paths.c_str());
@@ -325,7 +325,7 @@ struct reader::priv
for (const auto& path : rdr.debug_info_root_paths())
{
std::string file_path;
- if (!tools_utils::find_file_under_dir(*path, name, file_path))
+ if (!tools_utils::find_file_under_dir(path, name, file_path))
continue;
if ((alt_ctf_fd = open(file_path.c_str(), O_RDONLY)) == -1)
@@ -371,7 +371,7 @@ struct reader::priv
///
/// @param env the environment which the reader operates in.
reader::reader(const string& elf_path,
- const vector<char**>& debug_info_roots,
+ const vector<string>& debug_info_roots,
ir::environment& env)
: fe_iface(elf_path, env),
priv_(new priv(*this, elf_path, debug_info_roots))
@@ -397,7 +397,7 @@ reader::~reader()
/// for split debug information files.
void
reader::initialize(const std::string& elf_path,
- const vector<char**>& debug_info_roots)
+ const vector<string>& debug_info_roots)
{
fe_iface::initialize(elf_path);
corpus_path(elf_path);
@@ -417,7 +417,7 @@ reader::initialize(const std::string& elf_path,
void
reader::initialize(const std::string& elf_path)
{
- vector<char**> v;
+ vector<string> v;
initialize(elf_path, v);
}
@@ -426,7 +426,7 @@ reader::initialize(const std::string& elf_path)
///
/// @return the vector of directory paths to look into for split
/// debug information files.
-const vector<char**>&
+const vector<string>&
reader::debug_info_root_paths() const
{return priv_->debug_info_root_paths;}
@@ -461,7 +461,7 @@ dir_contains_ctf_archive(const string& directory,
/// that contains debug info.
bool
file_has_dwarf_debug_info(const string& elf_file_path,
- const vector<char**>& debug_info_root_paths)
+ const vector<string>& debug_info_root_paths)
{
if (guess_file_type(elf_file_path) != FILE_TYPE_ELF)
return false;
@@ -497,7 +497,7 @@ file_has_dwarf_debug_info(const string& elf_file_path,
/// that contains debug info.
bool
file_has_ctf_debug_info(const string& elf_file_path,
- const vector<char**>& debug_info_root_paths)
+ const vector<string>& debug_info_root_paths)
{
if (guess_file_type(elf_file_path) != FILE_TYPE_ELF)
return false;
@@ -521,7 +521,7 @@ file_has_ctf_debug_info(const string& elf_file_path,
// vmlinux.ctfa could be provided with --debug-info-dir
for (const auto& path : debug_info_root_paths)
- if (path && *path && find_file_under_dir(*path, "vmlinux.ctfa", vmlinux))
+ if (!path.empty() && find_file_under_dir(path, "vmlinux.ctfa", vmlinux))
return true;
return false;
@@ -541,7 +541,7 @@ file_has_ctf_debug_info(const string& elf_file_path,
/// that contains debug info.
bool
file_has_btf_debug_info(const string& elf_file_path,
- const vector<char**>& debug_info_root_paths)
+ const vector<string>& debug_info_root_paths)
{
if (guess_file_type(elf_file_path) != FILE_TYPE_ELF)
return false;
@@ -2174,6 +2174,31 @@ make_path_absolute(const char*p)
return result;
}
+/// Return a copy of the path given in argument, turning it into an
+/// absolute path by prefixing it with the concatenation of the result
+/// of get_current_dir_name() and the '/' character.
+///
+///
+/// @param p the path to turn into an absolute path.
+///
+/// @return The resulting absolute path.
+string
+make_path_absolute(const string& p)
+{
+ string result;
+
+ if (!p.empty() && p[0] != '/')
+ {
+ shared_ptr<char> pwd(get_current_dir_name(),
+ malloced_char_star_deleter());
+ result = string(pwd.get()) + "/" + p;
+ }
+ else if (!p.empty())
+ result = p;
+
+ return result;
+}
+
/// Return a copy of the path given in argument, turning it into an
/// absolute path by prefixing it with the concatenation of the result
/// of get_current_dir_name() and the '/' character.
@@ -3210,7 +3235,7 @@ load_vmlinux_corpus(elf_based_reader_sptr rdr,
const string& vmlinux,
vector<string>& modules,
const string& root,
- vector<char**>& di_roots,
+ vector<string>& di_roots,
vector<string>& suppr_paths,
vector<string>& kabi_wl_paths,
suppressions_type& supprs,
@@ -3372,20 +3397,17 @@ build_corpus_group_from_kernel_dist_under(const string& root,
if (got_binary_paths)
{
- shared_ptr<char> di_root =
- make_path_absolute(debug_info_root.c_str());
- char *di_root_ptr = di_root.get();
- vector<char**> di_roots;
- di_roots.push_back(&di_root_ptr);
+ string di_root =
+ make_path_absolute(debug_info_root);
+ vector<string> di_roots;
+ di_roots.push_back(di_root);
#ifdef WITH_CTF
- shared_ptr<char> di_root_ctf;
- char *di_root_ctf_ptr;
+ string di_root_ctf;
if (requested_fe_kind & corpus::CTF_ORIGIN)
{
- di_root_ctf = make_path_absolute(root.c_str());
- di_root_ctf_ptr = di_root_ctf.get();
- di_roots.push_back(&di_root_ctf_ptr);
+ di_root_ctf = make_path_absolute(root);
+ di_roots.push_back(di_root_ctf);
}
#endif
@@ -3443,7 +3465,7 @@ build_corpus_group_from_kernel_dist_under(const string& root,
/// designated by @p elf_file_path.
elf_based_reader_sptr
create_best_elf_based_reader(const string& elf_file_path,
- const vector<char**>& debug_info_root_paths,
+ const vector<string>& debug_info_root_paths,
environment& env,
corpus::origin requested_fe_kind,
bool show_all_types,
@@ -104,7 +104,7 @@ main(int argc, char* argv[])
corpus_sptr c1, c2;
environment env;
- vector<char**> di_roots;
+ vector<string> di_roots;
c1 = dwarf::read_corpus_from_elf(opts.elf1, di_roots, env,
/*load_all_types=*/false,
c1_status);
@@ -385,7 +385,7 @@ main()
abigail::fe_iface::STATUS_UNKNOWN;
environment env;
- std::vector<char**> di_roots;
+ std::vector<string> di_roots;
abigail::corpus_sptr corp0 =
dwarf::read_corpus_from_elf(in_elfv0_path,
/*debug_info_root_path=*/di_roots,
@@ -160,7 +160,7 @@ main(int argc, char **argv)
abigail::ir::environment env;
abigail::corpus_sptr c;
abigail::fe_iface::status status = abigail::fe_iface::STATUS_OK;
- std::vector<char**> di_roots;
+ std::vector<string> di_roots;
if (!(c = dwarf::read_corpus_from_elf(file_name, di_roots, env,
/*load_all_type=*/false,
status)))
@@ -107,7 +107,7 @@ test_task_btf::perform()
abigail::fe_iface::status status =
abigail::fe_iface::STATUS_UNKNOWN;
- vector<char**> di_roots;
+ vector<string> di_roots;
ABG_ASSERT(abigail::tools_utils::file_exists(in_elf_path));
abigail::elf_based_reader_sptr rdr = abigail::btf::create_reader(in_elf_path,
@@ -452,7 +452,7 @@ test_task_ctf::perform()
abigail::fe_iface::status status =
abigail::fe_iface::STATUS_UNKNOWN;
- vector<char**> di_roots;
+ vector<string> di_roots;
ABG_ASSERT(abigail::tools_utils::file_exists(in_elf_path));
abigail::elf_based_reader_sptr rdr = ctf::create_reader(in_elf_path,
@@ -48,7 +48,7 @@ read_corpus(const std::string& path,
const std::string& absolute_path = test_data_dir + path;
environment env;
- const std::vector<char**> debug_info_root_paths;
+ const std::vector<string> debug_info_root_paths;
abigail::elf_based_reader_sptr rdr =
dwarf::create_reader(absolute_path, debug_info_root_paths,
env, /* load_all_type = */ true,
@@ -85,8 +85,6 @@ using abigail::suppr::suppression_sptr;
using abigail::suppr::suppressions_type;
using abigail::suppr::read_suppressions;
-
-
class options
{
options();
@@ -97,9 +95,9 @@ public:
string app_path;
string lib1_path;
string lib2_path;
- shared_ptr<char> app_di_root_path;
- shared_ptr<char> lib1_di_root_path;
- shared_ptr<char> lib2_di_root_path;
+ string app_di_root_path;
+ string lib1_di_root_path;
+ string lib2_di_root_path;
vector<string> suppression_paths;
bool display_help;
bool display_version;
@@ -295,7 +293,7 @@ parse_command_line(int argc, char* argv[], options& opts)
// elfutils wants the root path to the debug info to be
// absolute.
opts.app_di_root_path =
- abigail::tools_utils::make_path_absolute(argv[i + 1]);
+ abigail::tools_utils::make_path_absolute(string(argv[i + 1]));
++i;
}
else if (!strcmp(argv[i], "--lib-debug-info-dir1")
@@ -307,7 +305,7 @@ parse_command_line(int argc, char* argv[], options& opts)
// elfutils wants the root path to the debug info to be
// absolute.
opts.lib1_di_root_path =
- abigail::tools_utils::make_path_absolute(argv[i + 1]);
+ abigail::tools_utils::make_path_absolute(string(argv[i + 1]));
++i;
}
else if (!strcmp(argv[i], "--lib-debug-info-dir2")
@@ -319,7 +317,7 @@ parse_command_line(int argc, char* argv[], options& opts)
// elfutils wants the root path to the debug info to be
// absolute.
opts.lib2_di_root_path =
- abigail::tools_utils::make_path_absolute(argv[i + 1]);
+ abigail::tools_utils::make_path_absolute(string(argv[i + 1]));
++i;
}
else if (!strcmp(argv[i], "--suppressions")
@@ -849,7 +847,7 @@ perform_compat_check_in_weak_mode(options& opts,
static corpus_sptr
read_corpus(options opts,
abigail::fe_iface::status& status,
- const vector<char**> di_roots,
+ const vector<string> di_roots,
environment &env,
const string &path)
{
@@ -982,9 +980,10 @@ main(int argc, char* argv[])
return abigail::tools_utils::ABIDIFF_OK;
// Read the application ELF file.
- char * app_di_root = opts.app_di_root_path.get();
- vector<char**> app_di_roots;
- app_di_roots.push_back(&app_di_root);
+ string& app_di_root = opts.app_di_root_path;
+ vector<string> app_di_roots;
+ if (!app_di_root.empty())
+ app_di_roots.push_back(app_di_root);
abigail::fe_iface::status status = abigail::fe_iface::STATUS_UNKNOWN;
environment env;
@@ -1042,9 +1041,10 @@ main(int argc, char* argv[])
if (!abigail::tools_utils::check_file(opts.lib1_path, cerr, opts.prog_name))
return abigail::tools_utils::ABIDIFF_ERROR;
- char * lib1_di_root = opts.lib1_di_root_path.get();
- vector<char**> lib1_di_roots;
- lib1_di_roots.push_back(&lib1_di_root);
+ string& lib1_di_root = opts.lib1_di_root_path;
+ vector<string> lib1_di_roots;
+ if (!lib1_di_root.empty())
+ lib1_di_roots.push_back(lib1_di_root);
corpus_sptr lib1_corpus = read_corpus(opts, status,
lib1_di_roots,
env, opts.lib1_path);
@@ -1077,9 +1077,10 @@ main(int argc, char* argv[])
if (!opts.weak_mode)
{
ABG_ASSERT(!opts.lib2_path.empty());
- char * lib2_di_root = opts.lib2_di_root_path.get();
- vector<char**> lib2_di_roots;
- lib2_di_roots.push_back(&lib2_di_root);
+ string& lib2_di_root = opts.lib2_di_root_path;
+ vector<string> lib2_di_roots;
+ if (!lib2_di_root.empty())
+ lib2_di_roots.push_back(lib2_di_root);
lib2_corpus = read_corpus(opts, status,
lib2_di_roots, env,
opts.lib2_path);
@@ -138,10 +138,8 @@ struct options
#ifdef WITH_BTF
bool use_btf;
#endif
- vector<char*> di_root_paths1;
- vector<char*> di_root_paths2;
- vector<char**> prepared_di_root_paths1;
- vector<char**> prepared_di_root_paths2;
+ vector<string> di_root_paths1;
+ vector<string> di_root_paths2;
vector<string> added_bins_dirs1;
vector<string> added_bins_dirs2;
vector<string> added_bins1;
@@ -209,18 +207,6 @@ struct options
~options()
{
- for (vector<char*>::iterator i = di_root_paths1.begin();
- i != di_root_paths1.end();
- ++i)
- free(*i);
-
- for (vector<char*>::iterator i = di_root_paths2.begin();
- i != di_root_paths2.end();
- ++i)
- free(*i);
-
- prepared_di_root_paths1.clear();
- prepared_di_root_paths2.clear();
}
};//end struct options;
@@ -371,7 +357,7 @@ parse_command_line(int argc, char* argv[], options& opts)
// elfutils wants the root path to the debug info to be
// absolute.
opts.di_root_paths1.push_back
- (abigail::tools_utils::make_path_absolute_to_be_freed(argv[j]));
+ (abigail::tools_utils::make_path_absolute(string(argv[j])));
++i;
}
else if (!strcmp(argv[i], "--debug-info-dir2")
@@ -1094,21 +1080,6 @@ adjust_diff_context_for_kmidiff(diff_context &ctxt)
ctxt.show_linkage_names(false);
}
-/// Convert options::di_root_paths{1,2} into
-/// options::prepared_di_root_paths{1,2} which is the suitable type
-/// format that the dwarf_reader expects.
-///
-/// @param o the options to consider.
-static void
-prepare_di_root_paths(options& o)
-{
- abigail::tools_utils::convert_char_stars_to_char_star_stars
- (o.di_root_paths1, o.prepared_di_root_paths1);
-
- abigail::tools_utils::convert_char_stars_to_char_star_stars
- (o.di_root_paths2, o.prepared_di_root_paths2);
-}
-
/// Emit an appropriate error message if necessary, given an error
/// code.
///
@@ -1156,7 +1127,7 @@ handle_error(abigail::fe_iface::status status_code,
emit_prefix(prog_name, cerr) <<
"could not find the debug info\n";
{
- if (opts.prepared_di_root_paths1.empty() == 0)
+ if (opts.di_root_paths1.empty() == 0)
emit_prefix(prog_name, cerr)
<< "Maybe you should consider using the "
"--debug-info-dir1 option to tell me about the "
@@ -1166,21 +1137,21 @@ handle_error(abigail::fe_iface::status status_code,
{
emit_prefix(prog_name, cerr)
<< "Maybe the root path to the debug information '";
- for (vector<char**>::const_iterator i
- = opts.prepared_di_root_paths1.begin();
- i != opts.prepared_di_root_paths1.end();
+ for (vector<string>::const_iterator i
+ = opts.di_root_paths1.begin();
+ i != opts.di_root_paths1.end();
++i)
{
- if (i != opts.prepared_di_root_paths1.end())
+ if (i != opts.di_root_paths1.end())
cerr << ", ";
- cerr << **i;
+ cerr << *i;
}
cerr << "' is wrong?\n";
}
}
{
- if (opts.prepared_di_root_paths2.empty())
+ if (opts.di_root_paths2.empty())
emit_prefix(prog_name, cerr)
<< "Maybe you should consider using the "
"--debug-info-dir2 option to tell me about the "
@@ -1190,14 +1161,14 @@ handle_error(abigail::fe_iface::status status_code,
{
emit_prefix(prog_name, cerr)
<< "Maybe the root path to the debug information '";
- for (vector<char**>::const_iterator i
- = opts.prepared_di_root_paths2.begin();
- i != opts.prepared_di_root_paths2.end();
+ for (vector<string>::const_iterator i
+ = opts.di_root_paths2.begin();
+ i != opts.di_root_paths2.end();
++i)
{
- if (i != opts.prepared_di_root_paths2.end())
+ if (i != opts.di_root_paths2.end())
cerr << ", ";
- cerr << **i;
+ cerr << *i;
}
cerr << "' is wrong?\n";
}
@@ -1350,8 +1321,6 @@ main(int argc, char* argv[])
return 0;
}
- prepare_di_root_paths(opts);
-
if (!maybe_check_suppression_files(opts))
return (abigail::tools_utils::ABIDIFF_USAGE_ERROR
| abigail::tools_utils::ABIDIFF_ERROR);
@@ -1427,7 +1396,7 @@ main(int argc, char* argv[])
#endif
abigail::elf_based_reader_sptr rdr =
create_best_elf_based_reader(opts.file1,
- opts.prepared_di_root_paths1,
+ opts.di_root_paths1,
env, requested_fe_kind,
opts.show_all_types,
opts.linux_kernel_mode);
@@ -1518,7 +1487,7 @@ main(int argc, char* argv[])
#endif
abigail::elf_based_reader_sptr rdr =
create_best_elf_based_reader(opts.file2,
- opts.prepared_di_root_paths2,
+ opts.di_root_paths2,
env, requested_fe_kind,
opts.show_all_types,
opts.linux_kernel_mode);
@@ -87,8 +87,7 @@ struct options
string wrong_option;
string in_file_path;
string out_file_path;
- vector<char*> di_root_paths;
- vector<char**> prepared_di_root_paths;
+ vector<string> di_root_paths;
vector<string> headers_dirs;
vector<string> header_files;
vector<string> added_bins_dirs;
@@ -189,12 +188,6 @@ struct options
~options()
{
- for (vector<char*>::iterator i = di_root_paths.begin();
- i != di_root_paths.end();
- ++i)
- free(*i);
-
- prepared_di_root_paths.clear();
}
};
@@ -789,7 +782,7 @@ load_corpus_and_write_abixml(char* argv[],
// specfied in opts ...
abigail::elf_based_reader_sptr reader =
create_best_elf_based_reader(opts.in_file_path,
- opts.prepared_di_root_paths,
+ opts.di_root_paths,
env, requested_fe_kind,
opts.load_all_types,
opts.linux_kernel_mode);
@@ -865,7 +858,7 @@ load_corpus_and_write_abixml(char* argv[],
emit_prefix(argv[0], cerr)
<< "Could not read debug info for '" << opts.in_file_path
<< "' from debug info root directory '";
- for (vector<char*>::const_iterator i =
+ for (vector<string>::const_iterator i =
opts.di_root_paths.begin();
i != opts.di_root_paths.end();
++i)
@@ -1127,18 +1120,6 @@ load_kernel_corpus_group_and_write_abixml(char* argv[],
return exit_code;
}
-/// Convert options::di_root_paths into
-/// options::prepared_di_root_paths which is the suitable type format
-/// that the dwarf_reader expects.
-///
-/// @param o the options to consider.
-static void
-prepare_di_root_paths(options& o)
-{
- tools_utils::convert_char_stars_to_char_star_stars(o.di_root_paths,
- o.prepared_di_root_paths);
-}
-
int
main(int argc, char* argv[])
{
@@ -1186,8 +1167,6 @@ main(int argc, char* argv[])
return 1;
}
- prepare_di_root_paths(opts);
-
if (!maybe_check_suppression_files(opts))
return 1;
@@ -86,7 +86,7 @@ struct options
#ifdef WITH_CTF
bool use_ctf;
#endif
- std::shared_ptr<char> di_root_path;
+ string di_root_path;
vector<string> suppression_paths;
string headers_dir;
vector<string> header_files;
@@ -544,7 +544,7 @@ parse_command_line(int argc, char* argv[], options& opts)
// elfutils wants the root path to the debug info to be
// absolute.
opts.di_root_path =
- abigail::tools_utils::make_path_absolute(argv[i + 1]);
+ abigail::tools_utils::make_path_absolute(string(argv[i + 1]));
++i;
}
else if (!strcmp(argv[i], "--headers-dir")
@@ -778,7 +778,7 @@ main(int argc, char* argv[])
abigail::corpus_sptr corp;
abigail::corpus_group_sptr group;
abigail::fe_iface::status s = abigail::fe_iface::STATUS_OK;
- char* di_root_path = 0;
+ string di_root_path;
file_type type = guess_file_type(opts.file_path);
switch (type)
@@ -800,9 +800,9 @@ main(int argc, char* argv[])
case abigail::tools_utils::FILE_TYPE_ELF:
case abigail::tools_utils::FILE_TYPE_AR:
{
- di_root_path = opts.di_root_path.get();
- vector<char**> di_roots;
- di_roots.push_back(&di_root_path);
+ di_root_path = opts.di_root_path;
+ vector<string> di_roots;
+ di_roots.push_back(di_root_path);
abigail::elf_based_reader_sptr rdr;
#ifdef WITH_CTF
if (opts.use_ctf)
@@ -855,7 +855,7 @@ main(int argc, char* argv[])
if (s & abigail::fe_iface::STATUS_DEBUG_INFO_NOT_FOUND)
{
cerr << "could not find the debug info";
- if(di_root_path == 0)
+ if(di_root_path.empty())
emit_prefix(argv[0], cerr)
<< " Maybe you should consider using the "
"--debug-info-dir1 option to tell me about the "
@@ -1532,12 +1532,11 @@ compare(const elf_file& elf1,
ostream& out,
abigail::fe_iface::status* detailed_error_status = 0)
{
- char *di_dir1 = (char*) debug_dir1.c_str(),
- *di_dir2 = (char*) debug_dir2.c_str();
-
- vector<char**> di_dirs1, di_dirs2;
- di_dirs1.push_back(&di_dir1);
- di_dirs2.push_back(&di_dir2);
+ vector<string> di_dirs1, di_dirs2;
+ if (!debug_dir1.empty())
+ di_dirs1.push_back(debug_dir1);
+ if (!debug_dir2.empty())
+ di_dirs2.push_back(debug_dir2);
if (opts.verbose)
emit_prefix("abipkgdiff", cerr)
@@ -1645,8 +1644,8 @@ compare(const elf_file& elf1,
<< "while reading file" << elf1.path << "\n";
emit_prefix("abipkgdiff", cerr) << "Could not find debug info file";
- if (di_dir1 && strcmp(di_dir1, ""))
- cerr << " under " << di_dir1 << "\n";
+ if (!debug_dir1.empty())
+ cerr << " under " << debug_dir1 << "\n";
else
cerr << "\n";
@@ -1734,8 +1733,8 @@ compare(const elf_file& elf1,
<< "while reading file" << elf2.path << "\n";
emit_prefix("abipkgdiff", cerr) << "Could not find debug info file";
- if (di_dir2 && strcmp(di_dir2, ""))
- cerr << " under " << di_dir2 << "\n";
+ if (!debug_dir2.empty())
+ cerr << " under " << debug_dir2 << "\n";
else
cerr << "\n";
@@ -1815,10 +1814,9 @@ compare_to_self(const elf_file& elf,
ostream& out,
abigail::fe_iface::status* detailed_error_status = 0)
{
- char *di_dir = (char*) debug_dir.c_str();
-
- vector<char**> di_dirs;
- di_dirs.push_back(&di_dir);
+ vector<string> di_dirs;
+ if (!debug_dir.empty())
+ di_dirs.push_back(debug_dir);
abigail::fe_iface::status c_status = abigail::fe_iface::STATUS_OK;