summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillermo E. Martinez <guillermo.e.martinez@oracle.com>2022-05-06 21:03:26 -0500
committerDodji Seketeli <dodji@redhat.com>2022-05-16 18:07:40 +0200
commit28a629347f598e3b5a35152538c4a4638ca3995a (patch)
treeb1d53a78d52c9e6381b1c5ad05db9b9a7c8e5bb3
parentctf-reader: CTF debug info for some symbols is not found (diff)
downloadlibabigail-28a629347f598e3b5a35152538c4a4638ca3995a.tar.gz
libabigail-28a629347f598e3b5a35152538c4a4638ca3995a.tar.bz2
libabigail-28a629347f598e3b5a35152538c4a4638ca3995a.tar.xz
abipkgdiff: Add support to compare packages with CTF debug format
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> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
-rw-r--r--doc/manuals/abipkgdiff.rst4
-rw-r--r--tools/abipkgdiff.cc114
2 files changed, 98 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
468 ==== SELF CHECK SUCCEEDED for 'libGLU.so.1.3.1' ==== 468 ==== SELF CHECK SUCCEEDED for 'libGLU.so.1.3.1' ====
469 $ 469 $
470 470
471 * ``--ctf``
472
473 This is used to compare packages with CTF debug information, if present.
474
471.. _abipkgdiff_return_value_label: 475.. _abipkgdiff_return_value_label:
472 476
473Return value 477Return value
diff --git a/tools/abipkgdiff.cc b/tools/abipkgdiff.cc
index ef9fabf2..eabd19ae 100644
--- a/tools/abipkgdiff.cc
+++ b/tools/abipkgdiff.cc
@@ -90,6 +90,9 @@
90#include "abg-dwarf-reader.h" 90#include "abg-dwarf-reader.h"
91#include "abg-reader.h" 91#include "abg-reader.h"
92#include "abg-writer.h" 92#include "abg-writer.h"
93#ifdef WITH_CTF
94#include "abg-ctf-reader.h"
95#endif
93 96
94using std::cout; 97using std::cout;
95using std::cerr; 98using std::cerr;
@@ -202,6 +205,10 @@ public:
202 bool fail_if_no_debug_info; 205 bool fail_if_no_debug_info;
203 bool show_identical_binaries; 206 bool show_identical_binaries;
204 bool self_check; 207 bool self_check;
208#ifdef WITH_CTF
209 bool use_ctf;
210#endif
211
205 vector<string> kabi_whitelist_packages; 212 vector<string> kabi_whitelist_packages;
206 vector<string> suppression_paths; 213 vector<string> suppression_paths;
207 vector<string> kabi_whitelist_paths; 214 vector<string> kabi_whitelist_paths;
@@ -240,6 +247,10 @@ public:
240 fail_if_no_debug_info(), 247 fail_if_no_debug_info(),
241 show_identical_binaries(), 248 show_identical_binaries(),
242 self_check() 249 self_check()
250#ifdef WITH_CTF
251 ,
252 use_ctf()
253#endif
243 { 254 {
244 // set num_workers to the default number of threads of the 255 // set num_workers to the default number of threads of the
245 // underlying maching. This is the default value for the number 256 // underlying maching. This is the default value for the number
@@ -879,6 +890,9 @@ display_usage(const string& prog_name, ostream& out)
879 << " --verbose emit verbose progress messages\n" 890 << " --verbose emit verbose progress messages\n"
880 << " --self-check perform a sanity check by comparing " 891 << " --self-check perform a sanity check by comparing "
881 "binaries inside the input package against their ABIXML representation\n" 892 "binaries inside the input package against their ABIXML representation\n"
893#ifdef WITH_CTF
894 << " --ctf use CTF instead of DWARF in ELF files\n"
895#endif
882 << " --help|-h display this help message\n" 896 << " --help|-h display this help message\n"
883 << " --version|-v display program version information" 897 << " --version|-v display program version information"
884 " and exit\n"; 898 " and exit\n";
@@ -1302,15 +1316,31 @@ compare(const elf_file& elf1,
1302 << " ...\n"; 1316 << " ...\n";
1303 1317
1304 corpus_sptr corpus1; 1318 corpus_sptr corpus1;
1319#ifdef WITH_CTF
1320 abigail::ctf_reader::read_context_sptr ctxt_ctf;
1321#endif
1322 read_context_sptr ctxt_dwarf;
1305 { 1323 {
1306 read_context_sptr c = 1324#ifdef WITH_CTF
1307 create_read_context(elf1.path, di_dirs1, env.get(), 1325 if (opts.use_ctf)
1308 /*load_all_types=*/opts.show_all_types); 1326 {
1309 add_read_context_suppressions(*c, priv_types_supprs1); 1327 ctxt_ctf = abigail::ctf_reader::create_read_context(elf1.path,
1310 if (!opts.kabi_suppressions.empty()) 1328 env.get());
1311 add_read_context_suppressions(*c, opts.kabi_suppressions); 1329 ABG_ASSERT(ctxt_ctf);
1330 corpus1 = abigail::ctf_reader::read_corpus(ctxt_ctf.get(),
1331 c1_status);
1332 }
1333 else
1334#endif
1335 {
1336 ctxt_dwarf = create_read_context(elf1.path, di_dirs1, env.get(),
1337 /*load_all_types=*/opts.show_all_types);
1338 add_read_context_suppressions(*ctxt_dwarf, priv_types_supprs1);
1339 if (!opts.kabi_suppressions.empty())
1340 add_read_context_suppressions(*ctxt_dwarf, opts.kabi_suppressions);
1312 1341
1313 corpus1 = read_corpus_from_elf(*c, c1_status); 1342 corpus1 = read_corpus_from_elf(*ctxt_dwarf, c1_status);
1343 }
1314 1344
1315 bool bail_out = false; 1345 bool bail_out = false;
1316 if (!(c1_status & abigail::elf_reader::STATUS_OK)) 1346 if (!(c1_status & abigail::elf_reader::STATUS_OK))
@@ -1356,7 +1386,13 @@ compare(const elf_file& elf1,
1356 emit_prefix("abipkgdiff", cerr) 1386 emit_prefix("abipkgdiff", cerr)
1357 << "Could not find alternate debug info file"; 1387 << "Could not find alternate debug info file";
1358 string alt_di_path; 1388 string alt_di_path;
1359 abigail::dwarf_reader::refers_to_alt_debug_info(*c, alt_di_path); 1389#ifdef WITH_CTF
1390 if (opts.use_ctf)
1391 ;
1392 else
1393#endif
1394 abigail::dwarf_reader::refers_to_alt_debug_info(*ctxt_dwarf,
1395 alt_di_path);
1360 if (!alt_di_path.empty()) 1396 if (!alt_di_path.empty())
1361 cerr << ": " << alt_di_path << "\n"; 1397 cerr << ": " << alt_di_path << "\n";
1362 else 1398 else
@@ -1389,15 +1425,26 @@ compare(const elf_file& elf1,
1389 1425
1390 corpus_sptr corpus2; 1426 corpus_sptr corpus2;
1391 { 1427 {
1392 read_context_sptr c = 1428#ifdef WITH_CTF
1393 create_read_context(elf2.path, di_dirs2, env.get(), 1429 if (opts.use_ctf)
1394 /*load_all_types=*/opts.show_all_types); 1430 {
1395 add_read_context_suppressions(*c, priv_types_supprs2); 1431 ctxt_ctf = abigail::ctf_reader::create_read_context(elf2.path,
1432 env.get());
1433 corpus2 = abigail::ctf_reader::read_corpus(ctxt_ctf.get(),
1434 c2_status);
1435 }
1436 else
1437#endif
1438 {
1439 ctxt_dwarf = create_read_context(elf2.path, di_dirs2, env.get(),
1440 /*load_all_types=*/opts.show_all_types);
1441 add_read_context_suppressions(*ctxt_dwarf, priv_types_supprs2);
1396 1442
1397 if (!opts.kabi_suppressions.empty()) 1443 if (!opts.kabi_suppressions.empty())
1398 add_read_context_suppressions(*c, opts.kabi_suppressions); 1444 add_read_context_suppressions(*ctxt_dwarf, opts.kabi_suppressions);
1399 1445
1400 corpus2 = read_corpus_from_elf(*c, c2_status); 1446 corpus2 = read_corpus_from_elf(*ctxt_dwarf, c2_status);
1447 }
1401 1448
1402 bool bail_out = false; 1449 bool bail_out = false;
1403 if (!(c2_status & abigail::elf_reader::STATUS_OK)) 1450 if (!(c2_status & abigail::elf_reader::STATUS_OK))
@@ -1443,7 +1490,13 @@ compare(const elf_file& elf1,
1443 emit_prefix("abipkgdiff", cerr) 1490 emit_prefix("abipkgdiff", cerr)
1444 << "Could not find alternate debug info file"; 1491 << "Could not find alternate debug info file";
1445 string alt_di_path; 1492 string alt_di_path;
1446 abigail::dwarf_reader::refers_to_alt_debug_info(*c, alt_di_path); 1493#ifdef WITH_CTF
1494 if (opts.use_ctf)
1495 ;
1496 else
1497#endif
1498 abigail::dwarf_reader::refers_to_alt_debug_info(*ctxt_dwarf,
1499 alt_di_path);
1447 if (!alt_di_path.empty()) 1500 if (!alt_di_path.empty())
1448 cerr << ": " << alt_di_path << "\n"; 1501 cerr << ": " << alt_di_path << "\n";
1449 else 1502 else
@@ -1540,12 +1593,29 @@ compare_to_self(const elf_file& elf,
1540 << " ...\n"; 1593 << " ...\n";
1541 1594
1542 corpus_sptr corp; 1595 corpus_sptr corp;
1596#ifdef WITH_CTF
1597 abigail::ctf_reader::read_context_sptr ctxt_ctf;
1598#endif
1599 read_context_sptr ctxt_dwarf;
1543 { 1600 {
1544 read_context_sptr c = 1601#ifdef WITH_CTF
1545 create_read_context(elf.path, di_dirs, env.get(), 1602 if (opts.use_ctf)
1546 /*read_all_types=*/opts.show_all_types); 1603 {
1604 ctxt_ctf = abigail::ctf_reader::create_read_context(elf.path,
1605 env.get());
1606 ABG_ASSERT(ctxt_ctf);
1607 corp = abigail::ctf_reader::read_corpus(ctxt_ctf.get(),
1608 c_status);
1609 }
1610 else
1611#endif
1612 {
1613 ctxt_dwarf =
1614 create_read_context(elf.path, di_dirs, env.get(),
1615 /*read_all_types=*/opts.show_all_types);
1547 1616
1548 corp = read_corpus_from_elf(*c, c_status); 1617 corp = read_corpus_from_elf(*ctxt_dwarf, c_status);
1618 }
1549 1619
1550 if (!(c_status & abigail::elf_reader::STATUS_OK)) 1620 if (!(c_status & abigail::elf_reader::STATUS_OK))
1551 { 1621 {
@@ -3332,6 +3402,10 @@ parse_command_line(int argc, char* argv[], options& opts)
3332 (make_path_absolute(argv[j]).get()); 3402 (make_path_absolute(argv[j]).get());
3333 ++i; 3403 ++i;
3334 } 3404 }
3405#ifdef WITH_CTF
3406 else if (!strcmp(argv[i], "--ctf"))
3407 opts.use_ctf = true;
3408#endif
3335 else if (!strcmp(argv[i], "--help") 3409 else if (!strcmp(argv[i], "--help")
3336 || !strcmp(argv[i], "-h")) 3410 || !strcmp(argv[i], "-h"))
3337 { 3411 {