From Craig Silverstein: Better handling of ODR violations which are
authorIan Lance Taylor <iant@google.com>
Wed, 28 Nov 2007 18:01:06 +0000 (18:01 +0000)
committerIan Lance Taylor <iant@google.com>
Wed, 28 Nov 2007 18:01:06 +0000 (18:01 +0000)
not in a function.

gold/dwarf_reader.cc
gold/dwarf_reader.h
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in
gold/testsuite/debug_msg.sh

index af694494d7e8c6e890b9f418ea95394b1ce2132a..f3a50c66d2f1e6e63dc5d10fa283ef732328b0ee 100644 (file)
@@ -421,7 +421,7 @@ Sized_dwarf_line_info<size, big_endian>::process_one_opcode(
             // This means that the current byte is the one immediately
             // after a set of instructions.  Record the current line
             // for up to one less than the current address.
-            lsm->address -= 1;
+            lsm->line_num = -1;
             lsm->end_sequence = true;
             *len = oplen;
             return true;
@@ -606,6 +606,120 @@ Sized_dwarf_line_info<size, big_endian>::input_is_relobj()
   return this->symtab_buffer_ != NULL;
 }
 
+// Given an Offset_to_lineno_entry vector, and an offset, figure out
+// if the offset points into a function according to the vector (see
+// comments below for the algorithm).  If it does, return an iterator
+// into the vector that points to the line-number that contains that
+// offset.  If not, it returns vector::end().
+
+static std::vector<Offset_to_lineno_entry>::const_iterator
+offset_to_iterator(const std::vector<Offset_to_lineno_entry>* offsets,
+                   off_t offset)
+{
+  const Offset_to_lineno_entry lookup_key = { offset, 0, 0, 0 };
+
+  // lower_bound() returns the smallest offset which is >= lookup_key.
+  // If no offset in offsets is >= lookup_key, returns end().
+  std::vector<Offset_to_lineno_entry>::const_iterator it
+      = std::lower_bound(offsets->begin(), offsets->end(), lookup_key);
+
+  // This code is easiest to understand with a concrete example.
+  // Here's a possible offsets array:
+  // {{offset = 3211, header_num = 0, file_num = 1, line_num = 16},  // 0
+  //  {offset = 3224, header_num = 0, file_num = 1, line_num = 20},  // 1
+  //  {offset = 3226, header_num = 0, file_num = 1, line_num = 22},  // 2
+  //  {offset = 3231, header_num = 0, file_num = 1, line_num = 25},  // 3
+  //  {offset = 3232, header_num = 0, file_num = 1, line_num = -1},  // 4
+  //  {offset = 3232, header_num = 0, file_num = 1, line_num = 65},  // 5
+  //  {offset = 3235, header_num = 0, file_num = 1, line_num = 66},  // 6
+  //  {offset = 3236, header_num = 0, file_num = 1, line_num = -1},  // 7
+  //  {offset = 5764, header_num = 0, file_num = 1, line_num = 47},  // 8
+  //  {offset = 5765, header_num = 0, file_num = 1, line_num = 48},  // 9
+  //  {offset = 5767, header_num = 0, file_num = 1, line_num = 49},  // 10
+  //  {offset = 5768, header_num = 0, file_num = 1, line_num = 50},  // 11
+  //  {offset = 5773, header_num = 0, file_num = 1, line_num = -1},  // 12
+  //  {offset = 5787, header_num = 1, file_num = 1, line_num = 19},  // 13
+  //  {offset = 5790, header_num = 1, file_num = 1, line_num = 20},  // 14
+  //  {offset = 5793, header_num = 1, file_num = 1, line_num = 67},  // 15
+  //  {offset = 5793, header_num = 1, file_num = 1, line_num = -1},  // 16
+  //  {offset = 5795, header_num = 1, file_num = 1, line_num = 68},  // 17
+  //  {offset = 5798, header_num = 1, file_num = 1, line_num = -1},  // 16
+  // The entries with line_num == -1 mark the end of a function: the
+  // associated offset is one past the last instruction in the
+  // function.  This can correspond to the beginning of the next
+  // function (as is true for offset 3232); alternately, there can be
+  // a gap between the end of one function and the start of the next
+  // (as is true for the rest, most notably from 3236->5764).
+  //
+  // Case 1: lookup_key has offset == 10.  lower_bound returns
+  //         offsets[0].  Since it's not an exact match and we're
+  //         at the beginning of offsets, we return NULL.
+  // Case 2: lookup_key has offset 10000.  lower_bound returns
+  //         offset[17] (end()).  We return NULL.
+  // Case 3: lookup_key has offset == 3211.  lower_bound matches
+  //         offsets[0] exactly, and that's the entry we return.
+  // Case 4: lookup_key has offset == 3232.  lower_bound returns
+  //         offsets[4].  That's an exact match, but indicates
+  //         end-of-function.  We check if offsets[5] is also an
+  //         exact match but not end-of-function.  It is, so we
+  //         return offsets[5].
+  // Case 5: lookup_key has offset == 3214.  lower_bound returns
+  //         offsets[1].  Since it's not an exact match, we back
+  //         up to the offset that's < lookup_key, offsets[0].
+  //         We note offsets[0] is a valid entry (not end-of-function),
+  //         so that's the entry we return.
+  // Case 6: lookup_key has offset == 4000.  lower_bound returns
+  //         offsets[8].  Since it's not an exact match, we back
+  //         up to offsets[7].  Since offsets[7] indicates
+  //         end-of-function, we know lookup_key is between
+  //         functions, so we return NULL (not a valid offset).
+  // Case 7: lookup_key has offset == 5794.  lower_bound returns
+  //         offsets[17].  Since it's not an exact match, we back
+  //         up to offsets[15].  Note we back up to the *first*
+  //         entry with offset 5793, not just offsets[17-1].
+  //         We note offsets[15] is a valid entry, so we return it.
+  //         If offsets[15] had had line_num == -1, we would have
+  //         checked offsets[16].  The reason for this is that
+  //         15 and 16 can be in an arbitrary order, since we sort
+  //         only by offset.  (Note it doesn't help to use line_number
+  //         as a secondary sort key, since sometimes we want the -1
+  //         to be first and sometimes we want it to be last.)
+
+  // This deals with cases (1) and (2).
+  if ((it == offsets->begin() && offset < it->offset)
+      || it == offsets->end())
+    return offsets->end();
+
+  // This deals with cases (3) and (4).
+  if (offset == it->offset)
+    {
+      while (it != offsets->end()
+             && it->offset == offset
+             && it->line_num == -1)
+        ++it;
+      if (it == offsets->end() || it->offset != offset)
+        return offsets->end();
+      else
+        return it;
+    }
+
+  // This handles the first part of case (7) -- we back up to the
+  // *first* entry that has the offset that's behind us.
+  gold_assert(it != offsets->begin());
+  std::vector<Offset_to_lineno_entry>::const_iterator range_end = it;
+  --it;
+  const off_t range_value = it->offset;
+  while (it != offsets->begin() && (it-1)->offset == range_value)
+    --it;
+
+  // This handles cases (5), (6), and (7): if any entry in the
+  // equal_range [it, range_end) has a line_num != -1, it's a valid
+  // match.  If not, we're not in a function.
+  for (; it != range_end; ++it)
+    if (it->line_num != -1)
+      return it;
+  return offsets->end();
+}
 
 // Return a string for a file name and line number.
 
@@ -617,7 +731,6 @@ Sized_dwarf_line_info<size, big_endian>::do_addr2line(unsigned int shndx,
   if (this->data_valid_ == false)
     return "";
 
-  const Offset_to_lineno_entry lookup_key = { offset, 0, 0, 0 };
   const std::vector<Offset_to_lineno_entry>* offsets;
   // If we do not have reloc information, then our input is a .so or
   // some similar data structure where all the information is held in
@@ -630,17 +743,9 @@ Sized_dwarf_line_info<size, big_endian>::do_addr2line(unsigned int shndx,
     return "";
 
   typename std::vector<Offset_to_lineno_entry>::const_iterator it
-      = std::lower_bound(offsets->begin(), offsets->end(), lookup_key);
-
-  // If we found an exact match, great, otherwise find the last entry
-  // before the passed-in offset.
-  if (it == offsets->end() || it->offset > offset)
-    {
-      if (it == offsets->begin())
-        return "";
-      --it;
-      gold_assert(it->offset < offset);
-    }
+      = offset_to_iterator(offsets, offset);
+  if (it == offsets->end())
+    return "";
 
   // Convert the file_num + line_num into a string.
   std::string ret;
index 4ce65b054b4c7777cccb9d87cec0be60cf09fd04..48ded84965e2f293ee63b1674a23e9d08dd6341f 100644 (file)
@@ -38,6 +38,19 @@ template<int size, bool big_endian>
 class Track_relocs;
 struct LineStateMachine;
 
+// We can't do better than to keep the offsets in a sorted vector.
+// Here, offset is the key, and file_num/line_num is the value.
+struct Offset_to_lineno_entry
+{
+  off_t offset;
+  int header_num;  // which file-list to use (i.e. which .o file are we in)
+  int file_num;    // a pointer into files_
+  int line_num;    // the line number in the source file
+  // Offsets are unique within a section, so that's a sufficient sort key.
+  bool operator<(const Offset_to_lineno_entry& that) const
+  { return this->offset < that.offset; }
+};
+
 // This class is used to read the line information from the debugging
 // section of an object file.
 
@@ -173,18 +186,6 @@ class Sized_dwarf_line_info : public Dwarf_line_info
   Reloc_map;
   Reloc_map reloc_map_;
 
-  // We can't do better than to keep the offsets in a sorted vector.
-  // Here, offset is the key, and file_num/line_num is the value.
-  struct Offset_to_lineno_entry
-  {
-    off_t offset;
-    int header_num;  // which file-list to use (i.e. which .o file are we in)
-    int file_num;    // a pointer into files_
-    int line_num;    // the line number in the source file
-    // Offsets are unique within a section, so that's a sufficient sort key.
-    bool operator<(const Offset_to_lineno_entry& that) const
-    { return this->offset < that.offset; }
-  };
   // We have a vector of offset->lineno entries for every input section.
   typedef Unordered_map<unsigned int, std::vector<Offset_to_lineno_entry> >
   Lineno_map;
index 622f4fca72001b8bd3c78b734412121110e088ed..1b0da6e945c7e0e443899731f59d8aec19950e0b 100644 (file)
@@ -32,7 +32,8 @@ if NATIVE_LINKER
 
 TESTS += debug_msg.sh undef_symbol.sh
 
-check_DATA += debug_msg.err undef_symbol.err
+check_DATA += debug_msg.err debug_msg_so.err debug_msg_ndebug.err
+check_DATA += undef_symbol.err
 
 NATIVE_PROGS = \
        constructor_test \
@@ -133,11 +134,46 @@ debug_msg.err: debug_msg.o odr_violation1.o odr_violation2.o gcctestdir/ld
        @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o "2>$@"
        @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o 2>$@; \
        then \
-         echo 1>&2 "Link of debug_msg.o should have failed"; \
+         echo 1>&2 "Link of debug_msg should have failed"; \
          rm -f $@; \
          exit 1; \
        fi
 
+# See if we can also detect problems when we're linking .so's, not .o's.
+debug_msg.so: debug_msg.cc
+       $(CXXCOMPILE) -O0 -g -shared -w -o $@ $(srcdir)/debug_msg.cc
+odr_violation1.so: odr_violation1.cc
+       $(CXXCOMPILE) -O0 -g -shared -w -o $@ $(srcdir)/odr_violation1.cc
+odr_violation2.so: odr_violation2.cc
+       $(CXXCOMPILE) -O0 -g -shared -w -o $@ $(srcdir)/odr_violation2.cc
+debug_msg_so.err: debug_msg.so odr_violation1.so odr_violation2.so gcctestdir/ld
+       @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so "2>$@"
+       @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so 2>$@; \
+       then \
+         echo 1>&2 "Link of debug_msg_so should have failed"; \
+         rm -f $@; \
+         exit 1; \
+       fi
+
+
+# We also want to make sure we do something reasonable when there's no
+# debug info available.  For the best test, we use .so's.
+debug_msg_ndebug.so: debug_msg.cc
+       $(CXXCOMPILE) -O0 -g0 -shared -w -o $@ $(srcdir)/debug_msg.cc
+odr_violation1_ndebug.so: odr_violation1.cc
+       $(CXXCOMPILE) -O0 -g0 -shared -w -o $@ $(srcdir)/odr_violation1.cc
+odr_violation2_ndebug.so: odr_violation2.cc
+       $(CXXCOMPILE) -O0 -g0 -shared -w -o $@ $(srcdir)/odr_violation2.cc
+debug_msg_ndebug.err: debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so gcctestdir/ld
+       @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_ndebug debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so "2>$@"
+       @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_ndebug debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so 2>$@; \
+       then \
+         echo 1>&2 "Link of debug_msg_ndebug should have failed"; \
+         rm -f $@; \
+         exit 1; \
+       fi
+
+
 undef_symbol.o: undef_symbol.cc
        $(CXXCOMPILE) -O0 -g -c -fPIC $<
 undef_symbol.so: undef_symbol.o
index 00d72892312587f2086525472e7218afdfb39d00..f908dc3deb1f06ee77aa9e672ea52ddfe59cf8bd 100644 (file)
@@ -43,7 +43,10 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_1 = debug_msg.sh undef_symbol.sh
-@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_2 = debug_msg.err undef_symbol.err
+@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_2 = debug_msg.err \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_so.err \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_ndebug.err \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ undef_symbol.err
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_3 = \
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared_1_nonpic_test \
 @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared_2_nonpic_test \
@@ -1219,7 +1222,40 @@ uninstall-am: uninstall-info-am
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o "2>$@"
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg debug_msg.o odr_violation1.o odr_violation2.o 2>$@; \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ then \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@   echo 1>&2 "Link of debug_msg.o should have failed"; \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@   echo 1>&2 "Link of debug_msg should have failed"; \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@   rm -f $@; \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@   exit 1; \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ fi
+
+# See if we can also detect problems when we're linking .so's, not .o's.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@debug_msg.so: debug_msg.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -g -shared -w -o $@ $(srcdir)/debug_msg.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@odr_violation1.so: odr_violation1.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -g -shared -w -o $@ $(srcdir)/odr_violation1.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@odr_violation2.so: odr_violation2.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -g -shared -w -o $@ $(srcdir)/odr_violation2.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@debug_msg_so.err: debug_msg.so odr_violation1.so odr_violation2.so gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so "2>$@"
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_so debug_msg.so odr_violation1.so odr_violation2.so 2>$@; \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ then \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@   echo 1>&2 "Link of debug_msg_so should have failed"; \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@   rm -f $@; \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@   exit 1; \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ fi
+
+# We also want to make sure we do something reasonable when there's no
+# debug info available.  For the best test, we use .so's.
+@GCC_TRUE@@NATIVE_LINKER_TRUE@debug_msg_ndebug.so: debug_msg.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -g0 -shared -w -o $@ $(srcdir)/debug_msg.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@odr_violation1_ndebug.so: odr_violation1.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -g0 -shared -w -o $@ $(srcdir)/odr_violation1.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@odr_violation2_ndebug.so: odr_violation2.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -g0 -shared -w -o $@ $(srcdir)/odr_violation2.cc
+@GCC_TRUE@@NATIVE_LINKER_TRUE@debug_msg_ndebug.err: debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so gcctestdir/ld
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ @echo $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_ndebug debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so "2>$@"
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ @if $(CXXLINK) -Bgcctestdir/ -Wl,--detect-odr-violations -o debug_msg_ndebug debug_msg_ndebug.so odr_violation1_ndebug.so odr_violation2_ndebug.so 2>$@; \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ then \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@   echo 1>&2 "Link of debug_msg_ndebug should have failed"; \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@   rm -f $@; \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@   exit 1; \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ fi
index 87c8efb338b1297eb653c144d27307a9644ee5f6..014deec7f927b5956901da01d4e42143ea33fcfd 100755 (executable)
 
 check()
 {
-    if ! grep -q "$1" debug_msg.err
+    if ! grep -q "$2" "$1"
     then
-       echo "Did not find expected error:"
-       echo "   $1"
+       echo "Did not find expected error in $1:"
+       echo "   $2"
        echo ""
        echo "Actual error output below:"
-       cat debug_msg.err
+       cat "$1"
+       exit 1
+    fi
+}
+
+check_missing()
+{
+    if grep -q "$2" "$1"
+    then
+       echo "Found unexpected error in $1:"
+       echo "   $2"
+       echo ""
+       echo "Actual error output below:"
+       cat "$1"
        exit 1
     fi
 }
 
 # We don't know how the compiler might order these variables, so we
 # can't test for the actual offset from .data, hence the regexp.
-check "debug_msg.o: in function fn_array:debug_msg.cc(.data+0x[0-9a-fA-F]*): undefined reference to 'undef_fn1()'"
-check "debug_msg.o: in function fn_array:debug_msg.cc(.data+0x[0-9a-fA-F]*): undefined reference to 'undef_fn2()'"
-check "debug_msg.o: in function badref1:debug_msg.cc(.data+0x[0-9a-fA-F]*): undefined reference to 'undef_int'"
-
-check "debug_msg.o: in function Base::virtfn():${srcdir}/debug_msg.cc:50: undefined reference to 'undef_fn1()'"
-check "debug_msg.o: in function Derived::virtfn():${srcdir}/debug_msg.cc:55: undefined reference to 'undef_fn2()'"
-check "debug_msg.o: in function int testfn<int>(int):${srcdir}/debug_msg.cc:43: undefined reference to 'undef_fn1()'"
-check "debug_msg.o: in function int testfn<int>(int):${srcdir}/debug_msg.cc:44: undefined reference to 'undef_fn2()'"
-check "debug_msg.o: in function int testfn<int>(int):${srcdir}/debug_msg.cc:45: undefined reference to 'undef_int'"
-check "debug_msg.o: in function int testfn<double>(double):${srcdir}/debug_msg.cc:43: undefined reference to 'undef_fn1()'"
-check "debug_msg.o: in function int testfn<double>(double):${srcdir}/debug_msg.cc:44: undefined reference to 'undef_fn2()'"
-check "debug_msg.o: in function int testfn<double>(double):${srcdir}/debug_msg.cc:45: undefined reference to 'undef_int'"
+check debug_msg.err "debug_msg.o: in function fn_array:debug_msg.cc(.data+0x[0-9a-fA-F]*): undefined reference to 'undef_fn1()'"
+check debug_msg.err "debug_msg.o: in function fn_array:debug_msg.cc(.data+0x[0-9a-fA-F]*): undefined reference to 'undef_fn2()'"
+check debug_msg.err "debug_msg.o: in function badref1:debug_msg.cc(.data+0x[0-9a-fA-F]*): undefined reference to 'undef_int'"
+
+check debug_msg.err "debug_msg.o: in function Base::virtfn():${srcdir}/debug_msg.cc:50: undefined reference to 'undef_fn1()'"
+check debug_msg.err "debug_msg.o: in function Derived::virtfn():${srcdir}/debug_msg.cc:55: undefined reference to 'undef_fn2()'"
+check debug_msg.err "debug_msg.o: in function int testfn<int>(int):${srcdir}/debug_msg.cc:43: undefined reference to 'undef_fn1()'"
+check debug_msg.err "debug_msg.o: in function int testfn<int>(int):${srcdir}/debug_msg.cc:44: undefined reference to 'undef_fn2()'"
+check debug_msg.err "debug_msg.o: in function int testfn<int>(int):${srcdir}/debug_msg.cc:45: undefined reference to 'undef_int'"
+check debug_msg.err "debug_msg.o: in function int testfn<double>(double):${srcdir}/debug_msg.cc:43: undefined reference to 'undef_fn1()'"
+check debug_msg.err "debug_msg.o: in function int testfn<double>(double):${srcdir}/debug_msg.cc:44: undefined reference to 'undef_fn2()'"
+check debug_msg.err "debug_msg.o: in function int testfn<double>(double):${srcdir}/debug_msg.cc:45: undefined reference to 'undef_int'"
 
 # Check we detected the ODR (One Definition Rule) violation.
-check ": symbol 'Ordering::operator()(int, int)' defined in multiple places (possible ODR violation):"
-check "odr_violation1.cc:5"
-check "odr_violation2.cc:5"
+check debug_msg.err ": symbol 'Ordering::operator()(int, int)' defined in multiple places (possible ODR violation):"
+check debug_msg.err "odr_violation1.cc:5"
+check debug_msg.err "odr_violation2.cc:5"
+
+# When linking together .so's, we don't catch the line numbers, but we
+# still find all the undefined variables, and the ODR violation.
+check debug_msg_so.err "debug_msg.so: undefined reference to 'undef_fn1()'"
+check debug_msg_so.err "debug_msg.so: undefined reference to 'undef_fn2()'"
+check debug_msg_so.err "debug_msg.so: undefined reference to 'undef_int'"
+check debug_msg_so.err ": symbol 'Ordering::operator()(int, int)' defined in multiple places (possible ODR violation):"
+check debug_msg_so.err "odr_violation1.cc:5"
+check debug_msg_so.err "odr_violation2.cc:5"
+
+# These messages shouldn't need any debug info to detect:
+check debug_msg_ndebug.err "debug_msg_ndebug.so: undefined reference to 'undef_fn1()'"
+check debug_msg_ndebug.err "debug_msg_ndebug.so: undefined reference to 'undef_fn2()'"
+check debug_msg_ndebug.err "debug_msg_ndebug.so: undefined reference to 'undef_int'"
+# However, we shouldn't detect or declare any ODR violation
+check_missing debug_msg_ndebug.err "(possible ODR violation)"
 
 exit 0
This page took 0.032248 seconds and 4 git commands to generate.