summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2017-11-21 11:09:00 +0100
committerDodji Seketeli <dodji@redhat.com>2017-11-21 11:09:00 +0100
commit933c7440343af55ffdbcc226507e53d941d772f5 (patch)
tree86ce8a84a3d1ce9c75502daf3731370dea44fc8e
parentSupport systems where fts.h can't be used with _FILE_OFFSET_BITS set (diff)
downloadlibabigail-933c7440343af55ffdbcc226507e53d941d772f5.tar.gz
libabigail-933c7440343af55ffdbcc226507e53d941d772f5.tar.bz2
libabigail-933c7440343af55ffdbcc226507e53d941d772f5.tar.xz
Bug 22438 - Emit a clear message when debug info is not found
The alternate debug info file referred to a binary can be missing, even though the rest of the debug info is not. In that case, libabigail starts loading the debug info and then it crashes when trying to get DIEs that are part of the missing alternate debug info. This patch detects when the alternate debug info is missing, so that abidiff and abipkgdiff can gracefully bail out, yielding a meaningful error message. * include/abg-dwarf-reader.h (enum abigail::dwarf_reader::status): Add a new STATUS_ALT_DEBUG_INFO_NOT_FOUND enumerator there. (refers_to_alt_debug_info): Declare new function. * src/abg-dwarf-reader.cc (read_corpus_from_elf): Detect when the referred-to alternate debug info file is not found and flip the STATUS_ALT_DEBUG_INFO_NOT_FOUND bit of the status accordingly. If the debug info was found but not the alternate debug info, then do not try to read the debug info at all. (refers_to_alt_debug_info): Define new function. * tools/abidiff.cc (handle_error): Define new static function. (main): Use it, rather than handling errors preventing libabigail from reading the corpus on a case by case basis. tools/abipkgdiff.cc (compare): Handle the case where no alternate debug info was found. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: New test output reference. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm: New test input RPM. * tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm: Likewise. * tests/data/Makefile.am: Add the new test files above to source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add a new test case from the new input files above. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
-rw-r--r--include/abg-dwarf-reader.h14
-rw-r--r--src/abg-dwarf-reader.cc40
-rw-r--r--tests/data/Makefile.am3
-rw-r--r--tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt1
-rw-r--r--tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpmbin0 -> 59858 bytes
-rw-r--r--tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpmbin0 -> 22234 bytes
-rw-r--r--tests/test-diff-pkg.cc12
-rw-r--r--tools/abidiff.cc206
-rw-r--r--tools/abipkgdiff.cc124
9 files changed, 302 insertions, 98 deletions
diff --git a/include/abg-dwarf-reader.h b/include/abg-dwarf-reader.h
index 8e261408..b986ccb5 100644
--- a/include/abg-dwarf-reader.h
+++ b/include/abg-dwarf-reader.h
@@ -52,12 +52,16 @@ enum status
52 /// This status is for when the call went OK. 52 /// This status is for when the call went OK.
53 STATUS_OK = 1, 53 STATUS_OK = 1,
54 54
55 /// This satus is for when the debug info could not be read. 55 /// This status is for when the debug info could not be read.
56 STATUS_DEBUG_INFO_NOT_FOUND = 1 << 1, 56 STATUS_DEBUG_INFO_NOT_FOUND = 1 << 1,
57 57
58 /// This status is for when the alternate debug info could not be
59 /// found.
60 STATUS_ALT_DEBUG_INFO_NOT_FOUND = 1 << 2,
61
58 /// This status is for when the symbols of the ELF binaries could 62 /// This status is for when the symbols of the ELF binaries could
59 /// not be read. 63 /// not be read.
60 STATUS_NO_SYMBOLS_FOUND = 1 << 2, 64 STATUS_NO_SYMBOLS_FOUND = 1 << 3,
61}; 65};
62 66
63string 67string
@@ -144,8 +148,12 @@ lookup_public_function_symbol_from_elf(const environment* env,
144 const string& symname, 148 const string& symname,
145 vector<elf_symbol_sptr>& func_syms); 149 vector<elf_symbol_sptr>& func_syms);
146 150
151bool
152refers_to_alt_debug_info(const read_context& ctxt,
153 string& alt_di_path);
154
147status 155status
148has_alt_debug_info(read_context& elf_path, 156has_alt_debug_info(read_context& ctxt,
149 bool& has_alt_di, 157 bool& has_alt_di,
150 string& alt_debug_info_path); 158 string& alt_debug_info_path);
151 159
diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 601b2d88..44a98e7c 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -15684,6 +15684,12 @@ read_corpus_from_elf(read_context& ctxt, status& status)
15684 if (!ctxt.load_debug_info()) 15684 if (!ctxt.load_debug_info())
15685 status |= STATUS_DEBUG_INFO_NOT_FOUND; 15685 status |= STATUS_DEBUG_INFO_NOT_FOUND;
15686 15686
15687 {
15688 string alt_di_path;
15689 if (refers_to_alt_debug_info(ctxt, alt_di_path) && !ctxt.alt_dwarf())
15690 status |= STATUS_ALT_DEBUG_INFO_NOT_FOUND;
15691 }
15692
15687 if (!get_ignore_symbol_table(ctxt)) 15693 if (!get_ignore_symbol_table(ctxt))
15688 { 15694 {
15689 ctxt.load_elf_properties(); 15695 ctxt.load_elf_properties();
@@ -15692,7 +15698,13 @@ read_corpus_from_elf(read_context& ctxt, status& status)
15692 status |= STATUS_NO_SYMBOLS_FOUND; 15698 status |= STATUS_NO_SYMBOLS_FOUND;
15693 } 15699 }
15694 15700
15695 if (status & STATUS_NO_SYMBOLS_FOUND) 15701 if (// If no elf symbol was found ...
15702 status & STATUS_NO_SYMBOLS_FOUND
15703 // ... or if debug info was found but not the required alternate
15704 // debug info ...
15705 || ((status & STATUS_ALT_DEBUG_INFO_NOT_FOUND)
15706 && !(status & STATUS_DEBUG_INFO_NOT_FOUND)))
15707 // ... then we cannot handle the binary.
15696 return corpus_sptr(); 15708 return corpus_sptr();
15697 15709
15698 // Read the variable and function descriptions from the debug info 15710 // Read the variable and function descriptions from the debug info
@@ -15864,6 +15876,32 @@ lookup_public_function_symbol_from_elf(const environment* env,
15864 return value; 15876 return value;
15865} 15877}
15866 15878
15879/// Check if the underlying elf file refers to an alternate debug info
15880/// file associated to it.
15881///
15882/// Note that "alternate debug info sections" is a GNU extension as
15883/// of DWARF4 and is described at
15884/// http://www.dwarfstd.org/ShowIssue.php?issue=120604.1.
15885///
15886/// @param ctxt the context used to read the elf file.
15887///
15888/// @param alt_di the path to the alternate debug info file. This is
15889/// set iff the function returns true.
15890///
15891/// @return true if the ELF file refers to an alternate debug info
15892/// file.
15893bool
15894refers_to_alt_debug_info(const read_context& ctxt,
15895 string& alt_di_path)
15896{
15897 if (!ctxt.alt_debug_info_path().empty())
15898 {
15899 alt_di_path = ctxt.alt_debug_info_path();
15900 return true;
15901 }
15902 return false;
15903}
15904
15867/// Check if the underlying elf file has an alternate debug info file 15905/// Check if the underlying elf file has an alternate debug info file
15868/// associated to it. 15906/// associated to it.
15869/// 15907///
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 72add0f2..7d8d25f7 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -1345,6 +1345,9 @@ test-diff-pkg/libcdio-0.94-1.fc26.x86_64.rpm \
1345test-diff-pkg/libcdio-0.94-2.fc26.x86_64.rpm \ 1345test-diff-pkg/libcdio-0.94-2.fc26.x86_64.rpm \
1346test-diff-pkg/libcdio-debuginfo-0.94-1.fc26.x86_64.rpm \ 1346test-diff-pkg/libcdio-debuginfo-0.94-1.fc26.x86_64.rpm \
1347test-diff-pkg/libcdio-debuginfo-0.94-2.fc26.x86_64.rpm \ 1347test-diff-pkg/libcdio-debuginfo-0.94-2.fc26.x86_64.rpm \
1348test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm \
1349test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm \
1350test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt \
1348\ 1351\
1349test-fedabipkgdiff/dbus-glib-0.104-3.fc23.x86_64.rpm \ 1352test-fedabipkgdiff/dbus-glib-0.104-3.fc23.x86_64.rpm \
1350test-fedabipkgdiff/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm \ 1353test-fedabipkgdiff/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm \
diff --git a/tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt b/tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt
new file mode 100644
index 00000000..64da524e
--- /dev/null
+++ b/tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt
@@ -0,0 +1 @@
abipkgdiff: Could not find alternate debug info file: ../../../../.dwz/libxfce4ui-4.12.1-8.fc27.ppc64
diff --git a/tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm b/tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm
new file mode 100644
index 00000000..56067a96
--- /dev/null
+++ b/tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm
Binary files differ
diff --git a/tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm b/tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm
new file mode 100644
index 00000000..e4e553f7
--- /dev/null
+++ b/tests/data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm
Binary files differ
diff --git a/tests/test-diff-pkg.cc b/tests/test-diff-pkg.cc
index 74dbcb66..d2cbccae 100644
--- a/tests/test-diff-pkg.cc
+++ b/tests/test-diff-pkg.cc
@@ -510,6 +510,18 @@ static InOutSpec in_out_specs[] =
510 "data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt", 510 "data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt",
511 "output/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt" 511 "output/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt"
512 }, 512 },
513 {
514 "data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm",
515 "data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64.rpm",
516 "--fail-no-dbg",
517 "",
518 "data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm",
519 "data/test-diff-pkg/libxfce4ui-devel-debuginfo-4.12.1-8.fc27.ppc64.rpm",
520 "",
521 "",
522 "data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt",
523 "output/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt"
524 },
513#endif //WITH_RPM 525#endif //WITH_RPM
514 526
515#ifdef WITH_DEB 527#ifdef WITH_DEB
diff --git a/tools/abidiff.cc b/tools/abidiff.cc
index c8704e67..fab2953c 100644
--- a/tools/abidiff.cc
+++ b/tools/abidiff.cc
@@ -776,6 +776,108 @@ adjust_diff_context_for_kmidiff(diff_context_sptr &ctxt)
776 (false); 776 (false);
777} 777}
778 778
779/// Emit an appropriate error message if necessary, given an error
780/// code.
781///
782/// To emit the appropriate error message the function might need to
783/// access the context in which the (ELF) input file was being loaded,
784/// if it's present.
785///
786/// @param status_code the status code returned after trying to load
787/// the input file.
788///
789/// @param ctxt the context used to load the ELF file, if we still
790/// have it. If this is nil, then it's ignored.
791///
792/// @param prog_name the name of the current program. This is
793/// important as it's used in the error message.
794///
795/// @param input_file_name the name of the input file that we are
796/// tryin to load.
797///
798/// @param debug_info_dir1 if non nil, then this points to the path of
799/// the root debug info directory of the first binary that we are
800/// trying to load.. If nil, then it's ignored.
801///
802/// @param debug_info_dir2 if non nil, then this points to the path of
803/// the root debug info directory of the second binary that we are
804/// trying to load.. If nil, then it's ignored.
805///
806/// @return abigail::tools_utils::ABIDIFF_ERROR if an error was
807/// detected, abigail::tools_utils::ABIDIFF_OK otherwise.
808static abigail::tools_utils::abidiff_status
809handle_error(abigail::dwarf_reader::status status_code,
810 const abigail::dwarf_reader::read_context* ctxt,
811 const string& prog_name,
812 const string& input_file_name,
813 char** debug_info_dir1,
814 char** debug_info_dir2)
815{
816 if (!(status_code & abigail::dwarf_reader::STATUS_OK))
817 {
818 emit_prefix(prog_name, cerr)
819 << "failed to read input file " << input_file_name << "\n";
820
821 if (status_code & abigail::dwarf_reader::STATUS_DEBUG_INFO_NOT_FOUND)
822 {
823 emit_prefix(prog_name, cerr) <<
824 "could not find the debug info\n";
825 if (debug_info_dir1)
826 {
827 if (*debug_info_dir1 == 0)
828 emit_prefix(prog_name, cerr)
829 << "Maybe you should consider using the "
830 "--debug-info-dir1 option to tell me about the "
831 "root directory of the debuginfo? "
832 "(e.g, --debug-info-dir1 /usr/lib/debug)\n";
833 else
834 emit_prefix(prog_name, cerr)
835 << "Maybe the root path to the debug information '"
836 << *debug_info_dir1 << "' is wrong?\n";
837 }
838
839 if (debug_info_dir2)
840 {
841 if (*debug_info_dir2 == 0)
842 emit_prefix(prog_name, cerr)
843 << "Maybe you should consider using the "
844 "--debug-info-dir2 option to tell me about the "
845 "root directory of the debuginfo? "
846 "(e.g, --debug-info-dir2 /usr/lib/debug)\n";
847 else
848 emit_prefix(prog_name, cerr)
849 << "Maybe the root path to the debug information '"
850 << *debug_info_dir2 << "' is wrong?\n";
851 }
852 }
853
854 if (status_code & abigail::dwarf_reader::STATUS_ALT_DEBUG_INFO_NOT_FOUND)
855 {
856 emit_prefix(prog_name, cerr)
857 << "could not find the alternate debug info file";
858 if (ctxt)
859 {
860 string alt_di_path;
861 abigail::dwarf_reader::refers_to_alt_debug_info(*ctxt,
862 alt_di_path);
863 if (!alt_di_path.empty())
864 cerr << " at: " << alt_di_path;
865 }
866 cerr << "\n";
867 }
868
869 if (status_code & abigail::dwarf_reader::STATUS_NO_SYMBOLS_FOUND)
870 emit_prefix(prog_name, cerr)
871 << "could not find the ELF symbols in the file '"
872 << input_file_name
873 << "'\n";
874
875 return abigail::tools_utils::ABIDIFF_ERROR;
876 }
877
878 return abigail::tools_utils::ABIDIFF_OK;
879}
880
779int 881int
780main(int argc, char* argv[]) 882main(int argc, char* argv[])
781{ 883{
@@ -894,6 +996,11 @@ main(int argc, char* argv[])
894 set_suppressions(*ctxt, opts); 996 set_suppressions(*ctxt, opts);
895 abigail::dwarf_reader::set_do_log(*ctxt, opts.do_log); 997 abigail::dwarf_reader::set_do_log(*ctxt, opts.do_log);
896 c1 = abigail::dwarf_reader::read_corpus_from_elf(*ctxt, c1_status); 998 c1 = abigail::dwarf_reader::read_corpus_from_elf(*ctxt, c1_status);
999 if (!c1)
1000 return handle_error(c1_status, ctxt.get(),
1001 argv[0], opts.file1,
1002 &di_dir1,
1003 /*debug_info_dir2=*/0);
897 } 1004 }
898 break; 1005 break;
899 case abigail::tools_utils::FILE_TYPE_XML_CORPUS: 1006 case abigail::tools_utils::FILE_TYPE_XML_CORPUS:
@@ -904,6 +1011,11 @@ main(int argc, char* argv[])
904 assert(ctxt); 1011 assert(ctxt);
905 set_suppressions(*ctxt, opts); 1012 set_suppressions(*ctxt, opts);
906 c1 = abigail::xml_reader::read_corpus_from_input(*ctxt); 1013 c1 = abigail::xml_reader::read_corpus_from_input(*ctxt);
1014 if (!c1)
1015 return handle_error(c1_status, /*ctxt=*/0,
1016 argv[0], opts.file1,
1017 /*debug_info_dir1=*/0,
1018 /*debug_info_dir2=*/0);
907 } 1019 }
908 break; 1020 break;
909 case abigail::tools_utils::FILE_TYPE_XML_CORPUS_GROUP: 1021 case abigail::tools_utils::FILE_TYPE_XML_CORPUS_GROUP:
@@ -914,11 +1026,21 @@ main(int argc, char* argv[])
914 assert(ctxt); 1026 assert(ctxt);
915 set_suppressions(*ctxt, opts); 1027 set_suppressions(*ctxt, opts);
916 g1 = abigail::xml_reader::read_corpus_group_from_input(*ctxt); 1028 g1 = abigail::xml_reader::read_corpus_group_from_input(*ctxt);
1029 if (!g1)
1030 return handle_error(c1_status, /*ctxt=*/0,
1031 argv[0], opts.file1,
1032 /*debug_info_dir1=*/0,
1033 /*debug_info_dir2=*/0);
917 } 1034 }
918 break; 1035 break;
919 case abigail::tools_utils::FILE_TYPE_ZIP_CORPUS: 1036 case abigail::tools_utils::FILE_TYPE_ZIP_CORPUS:
920#ifdef WITH_ZIP_ARCHIVE 1037#ifdef WITH_ZIP_ARCHIVE
921 c1 = abigail::xml_reader::read_corpus_from_file(opts.file1); 1038 c1 = abigail::xml_reader::read_corpus_from_file(opts.file1);
1039 if (!c1)
1040 return handle_error(c1_status, /*ctxt=*/0,
1041 argv[0], opts.file1,
1042 /*debug_info_dir1=*/0,
1043 /*debug_info_dir2=*/0);
922#endif //WITH_ZIP_ARCHIVE 1044#endif //WITH_ZIP_ARCHIVE
923 break; 1045 break;
924 case abigail::tools_utils::FILE_TYPE_RPM: 1046 case abigail::tools_utils::FILE_TYPE_RPM:
@@ -955,6 +1077,11 @@ main(int argc, char* argv[])
955 set_suppressions(*ctxt, opts); 1077 set_suppressions(*ctxt, opts);
956 1078
957 c2 = abigail::dwarf_reader::read_corpus_from_elf(*ctxt, c2_status); 1079 c2 = abigail::dwarf_reader::read_corpus_from_elf(*ctxt, c2_status);
1080 if (!c2)
1081 return handle_error(c2_status, ctxt.get(),
1082 argv[0], opts.file2,
1083 /*debug_info_dir1=*/0,
1084 /*debug_info_dir2=*/&di_dir2);
958 } 1085 }
959 break; 1086 break;
960 case abigail::tools_utils::FILE_TYPE_XML_CORPUS: 1087 case abigail::tools_utils::FILE_TYPE_XML_CORPUS:
@@ -965,6 +1092,11 @@ main(int argc, char* argv[])
965 assert(ctxt); 1092 assert(ctxt);
966 set_suppressions(*ctxt, opts); 1093 set_suppressions(*ctxt, opts);
967 c2 = abigail::xml_reader::read_corpus_from_input(*ctxt); 1094 c2 = abigail::xml_reader::read_corpus_from_input(*ctxt);
1095 if (!c2)
1096 return handle_error(c2_status, /*ctxt=*/0,
1097 argv[0], opts.file2,
1098 /*debug_info_dir1=*/0,
1099 /*debug_info_dir2=*/0);
968 } 1100 }
969 break; 1101 break;
970 case abigail::tools_utils::FILE_TYPE_XML_CORPUS_GROUP: 1102 case abigail::tools_utils::FILE_TYPE_XML_CORPUS_GROUP:
@@ -975,11 +1107,21 @@ main(int argc, char* argv[])
975 assert(ctxt); 1107 assert(ctxt);
976 set_suppressions(*ctxt, opts); 1108 set_suppressions(*ctxt, opts);
977 g2 = abigail::xml_reader::read_corpus_group_from_input(*ctxt); 1109 g2 = abigail::xml_reader::read_corpus_group_from_input(*ctxt);
1110 if (!g2)
1111 return handle_error(c2_status, /*ctxt=*/0,
1112 argv[0], opts.file2,
1113 /*debug_info_dir1=*/0,
1114 /*debug_info_dir2=*/0);
978 } 1115 }
979 break; 1116 break;
980 case abigail::tools_utils::FILE_TYPE_ZIP_CORPUS: 1117 case abigail::tools_utils::FILE_TYPE_ZIP_CORPUS:
981#ifdef WITH_ZIP_ARCHIVE 1118#ifdef WITH_ZIP_ARCHIVE
982 c2 = abigail::xml_reader::read_corpus_from_file(opts.file2); 1119 c2 = abigail::xml_reader::read_corpus_from_file(opts.file2);
1120 if (!c2)
1121 return handle_error(c2_status, /*ctxt=*/0,
1122 argv[0], opts.file2,
1123 /*debug_info_dir1=*/0,
1124 /*debug_info_dir2=*/0);
983#endif //WITH_ZIP_ARCHIVE 1125#endif //WITH_ZIP_ARCHIVE
984 break; 1126 break;
985 case abigail::tools_utils::FILE_TYPE_RPM: 1127 case abigail::tools_utils::FILE_TYPE_RPM:
@@ -990,70 +1132,6 @@ main(int argc, char* argv[])
990 break; 1132 break;
991 } 1133 }
992 1134
993 if (!t1 && !c1 && !g1)
994 {
995 emit_prefix(argv[0], cerr)
996 << "failed to read input file " << opts.file1 << "\n";
997 if (!(c1_status & abigail::dwarf_reader::STATUS_OK))
998 {
999 if (c1_status
1000 & abigail::dwarf_reader::STATUS_DEBUG_INFO_NOT_FOUND)
1001 {
1002 emit_prefix(argv[0], cerr) <<
1003 "could not find the debug info\n";
1004 if (di_dir1 == 0)
1005 emit_prefix(argv[0], cerr)
1006 << " Maybe you should consider using the "
1007 "--debug-info-dir1 option to tell me about the "
1008 "root directory of the debuginfo? "
1009 "(e.g, --debug-info-dir1 /usr/lib/debug)\n";
1010 else
1011 emit_prefix(argv[0], cerr)
1012 << "Maybe the root path to the debug information '"
1013 << di_dir1 << "' is wrong?\n";
1014 }
1015 if (c1_status
1016 & abigail::dwarf_reader::STATUS_NO_SYMBOLS_FOUND)
1017 emit_prefix(argv[0], cerr)
1018 << "could not find the ELF symbols in the file '"
1019 << opts.file1
1020 << "'\n";
1021 return abigail::tools_utils::ABIDIFF_ERROR;
1022 }
1023 }
1024
1025 if (!t2 && !c2 && !g2)
1026 {
1027 emit_prefix(argv[0], cerr)
1028 << "failed to read input file " << opts.file2 << "\n";
1029 if (!(c2_status & abigail::dwarf_reader::STATUS_OK))
1030 {
1031 if (c2_status
1032 & abigail::dwarf_reader::STATUS_DEBUG_INFO_NOT_FOUND)
1033 {
1034 emit_prefix(argv[0], cerr) <<
1035 "could not find the debug info\n";
1036 if (di_dir2 == 0)
1037 emit_prefix(argv[0], cerr)
1038 << " Maybe you should consider using the "
1039 "--debug-info-dir1 option to tell me about the "
1040 "root directory of the debuginfo? "
1041 "(e.g, --debug-info-dir1 /usr/lib/debug)\n";
1042 else
1043 emit_prefix(argv[0], cerr)
1044 << "Maybe the root path to the debug information '"
1045 << di_dir2 << "' is wrong?\n";
1046 }
1047 if (c2_status
1048 & abigail::dwarf_reader::STATUS_NO_SYMBOLS_FOUND)
1049 emit_prefix(argv[0], cerr)
1050 << "could not find the ELF symbols in the file '"
1051 << opts.file2
1052 << "'\n";
1053 return abigail::tools_utils::ABIDIFF_ERROR;
1054 }
1055 }
1056
1057 if (!!c1 != !!c2 1135 if (!!c1 != !!c2
1058 || !!t1 != !!t2 1136 || !!t1 != !!t2
1059 || !!g1 != !!g2) 1137 || !!g1 != !!g2)
diff --git a/tools/abipkgdiff.cc b/tools/abipkgdiff.cc
index c2315eae..6eea1598 100644
--- a/tools/abipkgdiff.cc
+++ b/tools/abipkgdiff.cc
@@ -1139,6 +1139,7 @@ compare(const elf_file& elf1,
1139 1139
1140 corpus1 = read_corpus_from_elf(*c, c1_status); 1140 corpus1 = read_corpus_from_elf(*c, c1_status);
1141 1141
1142 bool bail_out = false;
1142 if (!(c1_status & abigail::dwarf_reader::STATUS_OK)) 1143 if (!(c1_status & abigail::dwarf_reader::STATUS_OK))
1143 { 1144 {
1144 if (opts.verbose) 1145 if (opts.verbose)
@@ -1147,27 +1148,59 @@ compare(const elf_file& elf1,
1147 << elf1.path 1148 << elf1.path
1148 << "' properly\n"; 1149 << "' properly\n";
1149 1150
1150 if (detailed_error_status) 1151 if (detailed_error_status)
1151 *detailed_error_status = c1_status; 1152 *detailed_error_status = c1_status;
1152 1153
1153 return abigail::tools_utils::ABIDIFF_ERROR; 1154 bail_out = true;
1154 } 1155 }
1155 }
1156 1156
1157 if (opts.fail_if_no_debug_info 1157 if (opts.fail_if_no_debug_info || opts.verbose)
1158 && (c1_status & abigail::dwarf_reader::STATUS_DEBUG_INFO_NOT_FOUND)) 1158 {
1159 { 1159 bool debug_info_error = false;
1160 emit_prefix("abipkgdiff", cerr) << "Could not find debug info file"; 1160 if (c1_status & abigail::dwarf_reader::STATUS_DEBUG_INFO_NOT_FOUND)
1161 if (di_dir1 && strcmp(di_dir1, "")) 1161 {
1162 emit_prefix("abipkgdiff", cerr) << " under " << di_dir1 << "\n"; 1162 if (opts.verbose)
1163 else 1163 emit_prefix("abipkgdiff", cerr)
1164 emit_prefix("abipkgdiff", cerr) << "\n"; 1164 << "while reading file" << elf1.path << "\n";
1165
1166 emit_prefix("abipkgdiff", cerr) << "Could not find debug info file";
1167 if (di_dir1 && strcmp(di_dir1, ""))
1168 cerr << " under " << di_dir1 << "\n";
1169 else
1170 cerr << "\n";
1165 1171
1166 if (detailed_error_status) 1172 if (detailed_error_status)
1167 *detailed_error_status = c1_status; 1173 *detailed_error_status = c1_status;
1174 debug_info_error = true;
1175 }
1176
1177 if (c1_status & abigail::dwarf_reader::STATUS_ALT_DEBUG_INFO_NOT_FOUND)
1178 {
1179 if (opts.verbose)
1180 emit_prefix("abipkgdiff", cerr)
1181 << "while reading file" << elf1.path << "\n";
1182
1183 emit_prefix("abipkgdiff", cerr)
1184 << "Could not find alternate debug info file";
1185 string alt_di_path;
1186 abigail::dwarf_reader::refers_to_alt_debug_info(*c, alt_di_path);
1187 if (!alt_di_path.empty())
1188 cerr << ": " << alt_di_path << "\n";
1189 else
1190 cerr << "\n";
1191
1192 if (detailed_error_status)
1193 *detailed_error_status = c1_status;
1194 debug_info_error = true;
1195 }
1168 1196
1197 if (debug_info_error)
1198 bail_out = true;
1199 }
1200
1201 if (bail_out)
1169 return abigail::tools_utils::ABIDIFF_ERROR; 1202 return abigail::tools_utils::ABIDIFF_ERROR;
1170 } 1203 }
1171 1204
1172 if (opts.verbose) 1205 if (opts.verbose)
1173 emit_prefix("abipkgdiff", cerr) 1206 emit_prefix("abipkgdiff", cerr)
@@ -1192,6 +1225,7 @@ compare(const elf_file& elf1,
1192 1225
1193 corpus2 = read_corpus_from_elf(*c, c2_status); 1226 corpus2 = read_corpus_from_elf(*c, c2_status);
1194 1227
1228 bool bail_out = false;
1195 if (!(c2_status & abigail::dwarf_reader::STATUS_OK)) 1229 if (!(c2_status & abigail::dwarf_reader::STATUS_OK))
1196 { 1230 {
1197 if (opts.verbose) 1231 if (opts.verbose)
@@ -1203,26 +1237,56 @@ compare(const elf_file& elf1,
1203 if (detailed_error_status) 1237 if (detailed_error_status)
1204 *detailed_error_status = c2_status; 1238 *detailed_error_status = c2_status;
1205 1239
1206 return abigail::tools_utils::ABIDIFF_ERROR; 1240 bail_out = true;
1207 } 1241 }
1208 }
1209 1242
1210 if (opts.fail_if_no_debug_info 1243 if (opts.fail_if_no_debug_info || opts.verbose)
1211 && (c2_status & abigail::dwarf_reader::STATUS_DEBUG_INFO_NOT_FOUND)) 1244 {
1212 { 1245 bool debug_info_error = false;
1213 emit_prefix("abipkgdiff", cerr) 1246 if (c2_status & abigail::dwarf_reader::STATUS_DEBUG_INFO_NOT_FOUND)
1214 << "Could not find debug info file"; 1247 {
1215 if (di_dir1 && strcmp(di_dir2, "")) 1248 if (opts.verbose)
1216 emit_prefix("abipkgdiff", cerr) 1249 emit_prefix("abipkgdiff", cerr)
1217 << " under " << di_dir2 << "\n"; 1250 << "while reading file" << elf2.path << "\n";
1218 else 1251
1219 emit_prefix("abipkgdiff", cerr) << "\n"; 1252 emit_prefix("abipkgdiff", cerr) << "Could not find debug info file";
1253 if (di_dir2 && strcmp(di_dir2, ""))
1254 cerr << " under " << di_dir2 << "\n";
1255 else
1256 cerr << "\n";
1220 1257
1221 if (detailed_error_status) 1258 if (detailed_error_status)
1222 *detailed_error_status = c2_status; 1259 *detailed_error_status = c2_status;
1260 debug_info_error = true;
1261 }
1262
1263 if (c2_status & abigail::dwarf_reader::STATUS_ALT_DEBUG_INFO_NOT_FOUND)
1264 {
1265 if (opts.verbose)
1266 emit_prefix("abipkgdiff", cerr)
1267 << "while reading file" << elf2.path << "\n";
1268
1269 emit_prefix("abipkgdiff", cerr)
1270 << "Could not find alternate debug info file";
1271 string alt_di_path;
1272 abigail::dwarf_reader::refers_to_alt_debug_info(*c, alt_di_path);
1273 if (!alt_di_path.empty())
1274 cerr << ": " << alt_di_path << "\n";
1275 else
1276 cerr << "\n";
1277
1278 if (detailed_error_status)
1279 *detailed_error_status = c2_status;
1280 debug_info_error = true;
1281 }
1223 1282
1283 if (debug_info_error)
1284 bail_out = true;
1285 }
1286
1287 if (bail_out)
1224 return abigail::tools_utils::ABIDIFF_ERROR; 1288 return abigail::tools_utils::ABIDIFF_ERROR;
1225 } 1289 }
1226 1290
1227 if (opts.verbose) 1291 if (opts.verbose)
1228 emit_prefix("abipkgdiff", cerr) 1292 emit_prefix("abipkgdiff", cerr)