From: "Guillermo E. Martinez" <guillermo.e.martinez@oracle.com>
To: libabigail@sourceware.org
Subject: [PATCH] abipkgdiff: Add support to compare packages with CTF debug format
Date: Fri, 6 May 2022 21:03:26 -0500 [thread overview]
Message-ID: <20220507020326.1417379-1-guillermo.e.martinez@oracle.com> (raw)
This patch add support in `abipkgdiff' to compare binaries with CTF
debug data. It depends of:
* https://sourceware.org/pipermail/libabigail/2022q2/004340.html
* https://sourceware.org/pipermail/libabigail/2022q2/004343.html
* https://sourceware.org/pipermail/libabigail/2022q2/004344.html
* [PATCH] ctf-reader: add support to looking debug information in
external path
Please let me know your comments, I'll really appreciate them.
Kind regards,
Guillermo
This patch add support in `abipkgdiff' to compare binaries with CTF
debug information inside of packages, when `--ctf' option is provided.
* tools/abipkgdiff.cc: Include `abg-ctf-reader.h'.
(options::use_ctf): Add new data member.
(display_usage): Add `--ctf' usage.
(compare): Add condition to use ctf-reader to extract
(parse_command_line): Set `options::use_ctf' when --ctf
option is provided.
and build CTF corpora when `options::use_ctf' is set.
(compare_to_self): Likewise.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
---
doc/manuals/abipkgdiff.rst | 4 ++
tools/abipkgdiff.cc | 116 ++++++++++++++++++++++++++++++-------
2 files changed, 100 insertions(+), 20 deletions(-)
diff --git a/doc/manuals/abipkgdiff.rst b/doc/manuals/abipkgdiff.rst
index c15dc51f..f297c9a8 100644
--- a/doc/manuals/abipkgdiff.rst
+++ b/doc/manuals/abipkgdiff.rst
@@ -468,6 +468,10 @@ Options
==== SELF CHECK SUCCEEDED for 'libGLU.so.1.3.1' ====
$
+ * ``--ctf``
+
+ This is used to compare packages with CTF debug information, if present.
+
.. _abipkgdiff_return_value_label:
Return value
diff --git a/tools/abipkgdiff.cc b/tools/abipkgdiff.cc
index ef9fabf2..91b3711f 100644
--- a/tools/abipkgdiff.cc
+++ b/tools/abipkgdiff.cc
@@ -90,6 +90,9 @@
#include "abg-dwarf-reader.h"
#include "abg-reader.h"
#include "abg-writer.h"
+#ifdef WITH_CTF
+#include "abg-ctf-reader.h"
+#endif
using std::cout;
using std::cerr;
@@ -202,6 +205,10 @@ public:
bool fail_if_no_debug_info;
bool show_identical_binaries;
bool self_check;
+#ifdef WITH_CTF
+ bool use_ctf;
+#endif
+
vector<string> kabi_whitelist_packages;
vector<string> suppression_paths;
vector<string> kabi_whitelist_paths;
@@ -240,6 +247,10 @@ public:
fail_if_no_debug_info(),
show_identical_binaries(),
self_check()
+#ifdef WITH_CTF
+ ,
+ use_ctf()
+#endif
{
// set num_workers to the default number of threads of the
// underlying maching. This is the default value for the number
@@ -879,6 +890,9 @@ display_usage(const string& prog_name, ostream& out)
<< " --verbose emit verbose progress messages\n"
<< " --self-check perform a sanity check by comparing "
"binaries inside the input package against their ABIXML representation\n"
+#ifdef WITH_CTF
+ << " --ctf use CTF instead of DWARF in ELF files\n"
+#endif
<< " --help|-h display this help message\n"
<< " --version|-v display program version information"
" and exit\n";
@@ -1302,15 +1316,32 @@ compare(const elf_file& elf1,
<< " ...\n";
corpus_sptr corpus1;
+#ifdef WITH_CTF
+ abigail::ctf_reader::read_context_sptr ctxt_ctf;
+#endif
+ read_context_sptr ctxt_dwarf;
{
- read_context_sptr c =
- create_read_context(elf1.path, di_dirs1, env.get(),
- /*load_all_types=*/opts.show_all_types);
- add_read_context_suppressions(*c, priv_types_supprs1);
- if (!opts.kabi_suppressions.empty())
- add_read_context_suppressions(*c, opts.kabi_suppressions);
+#ifdef WITH_CTF
+ if (opts.use_ctf)
+ {
+ ctxt_ctf = abigail::ctf_reader::create_read_context(elf1.path,
+ di_dirs1,
+ env.get());
+ ABG_ASSERT(ctxt_ctf);
+ corpus1 = abigail::ctf_reader::read_corpus(ctxt_ctf.get(),
+ c1_status);
+ }
+ else
+#endif
+ {
+ ctxt_dwarf = create_read_context(elf1.path, di_dirs1, env.get(),
+ /*load_all_types=*/opts.show_all_types);
+ add_read_context_suppressions(*ctxt_dwarf, priv_types_supprs1);
+ if (!opts.kabi_suppressions.empty())
+ add_read_context_suppressions(*ctxt_dwarf, opts.kabi_suppressions);
- corpus1 = read_corpus_from_elf(*c, c1_status);
+ corpus1 = read_corpus_from_elf(*ctxt_dwarf, c1_status);
+ }
bool bail_out = false;
if (!(c1_status & abigail::elf_reader::STATUS_OK))
@@ -1356,7 +1387,13 @@ compare(const elf_file& elf1,
emit_prefix("abipkgdiff", cerr)
<< "Could not find alternate debug info file";
string alt_di_path;
- abigail::dwarf_reader::refers_to_alt_debug_info(*c, alt_di_path);
+#ifdef WITH_CTF
+ if (opts.use_ctf)
+ ;
+ else
+#endif
+ abigail::dwarf_reader::refers_to_alt_debug_info(*ctxt_dwarf,
+ alt_di_path);
if (!alt_di_path.empty())
cerr << ": " << alt_di_path << "\n";
else
@@ -1389,15 +1426,26 @@ compare(const elf_file& elf1,
corpus_sptr corpus2;
{
- read_context_sptr c =
- create_read_context(elf2.path, di_dirs2, env.get(),
- /*load_all_types=*/opts.show_all_types);
- add_read_context_suppressions(*c, priv_types_supprs2);
+#ifdef WITH_CTF
+ if (opts.use_ctf)
+ {
+ ctxt_ctf = abigail::ctf_reader::create_read_context
+ (elf2.path, di_dirs2, env.get());
+ corpus2 = abigail::ctf_reader::read_corpus(ctxt_ctf.get(),
+ c2_status);
+ }
+ else
+#endif
+ {
+ ctxt_dwarf = create_read_context(elf2.path, di_dirs2, env.get(),
+ /*load_all_types=*/opts.show_all_types);
+ add_read_context_suppressions(*ctxt_dwarf, priv_types_supprs2);
- if (!opts.kabi_suppressions.empty())
- add_read_context_suppressions(*c, opts.kabi_suppressions);
+ if (!opts.kabi_suppressions.empty())
+ add_read_context_suppressions(*ctxt_dwarf, opts.kabi_suppressions);
- corpus2 = read_corpus_from_elf(*c, c2_status);
+ corpus2 = read_corpus_from_elf(*ctxt_dwarf, c2_status);
+ }
bool bail_out = false;
if (!(c2_status & abigail::elf_reader::STATUS_OK))
@@ -1443,7 +1491,13 @@ compare(const elf_file& elf1,
emit_prefix("abipkgdiff", cerr)
<< "Could not find alternate debug info file";
string alt_di_path;
- abigail::dwarf_reader::refers_to_alt_debug_info(*c, alt_di_path);
+#ifdef WITH_CTF
+ if (opts.use_ctf)
+ ;
+ else
+#endif
+ abigail::dwarf_reader::refers_to_alt_debug_info(*ctxt_dwarf,
+ alt_di_path);
if (!alt_di_path.empty())
cerr << ": " << alt_di_path << "\n";
else
@@ -1540,12 +1594,30 @@ compare_to_self(const elf_file& elf,
<< " ...\n";
corpus_sptr corp;
+#ifdef WITH_CTF
+ abigail::ctf_reader::read_context_sptr ctxt_ctf;
+#endif
+ read_context_sptr ctxt_dwarf;
{
- read_context_sptr c =
- create_read_context(elf.path, di_dirs, env.get(),
- /*read_all_types=*/opts.show_all_types);
+#ifdef WITH_CTF
+ if (opts.use_ctf)
+ {
+ ctxt_ctf = abigail::ctf_reader::create_read_context(elf.path,
+ di_dirs,
+ env.get());
+ ABG_ASSERT(ctxt_ctf);
+ corp = abigail::ctf_reader::read_corpus(ctxt_ctf.get(),
+ c_status);
+ }
+ else
+#endif
+ {
+ ctxt_dwarf =
+ create_read_context(elf.path, di_dirs, env.get(),
+ /*read_all_types=*/opts.show_all_types);
- corp = read_corpus_from_elf(*c, c_status);
+ corp = read_corpus_from_elf(*ctxt_dwarf, c_status);
+ }
if (!(c_status & abigail::elf_reader::STATUS_OK))
{
@@ -3332,6 +3404,10 @@ parse_command_line(int argc, char* argv[], options& opts)
(make_path_absolute(argv[j]).get());
++i;
}
+#ifdef WITH_CTF
+ else if (!strcmp(argv[i], "--ctf"))
+ opts.use_ctf = true;
+#endif
else if (!strcmp(argv[i], "--help")
|| !strcmp(argv[i], "-h"))
{
base-commit: c96463e1ad974b7c4561886d7a3aa8a3c9a35607
prerequisite-patch-id: 781b026536589341e1e4378d9529fe258633bb53
prerequisite-patch-id: e6191c510bc90e225bd0858d333e2e01b6e52a62
prerequisite-patch-id: b87e0b761bf3f909eb84147b3b13e2a338de9509
prerequisite-patch-id: 6ddc271ce828e41f3d7c1f472ad01be8fb10b5d3
--
2.35.1
next reply other threads:[~2022-05-07 2:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-07 2:03 Guillermo E. Martinez [this message]
2022-05-16 22:09 ` Dodji Seketeli
2022-05-16 22:21 ` Guillermo E. Martinez
2022-05-17 7:11 ` Dodji Seketeli
2022-05-17 13:13 ` Guillermo E. Martinez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220507020326.1417379-1-guillermo.e.martinez@oracle.com \
--to=guillermo.e.martinez@oracle.com \
--cc=libabigail@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).