]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Ignore CU compilation directory in directory table comparison.
authorRoland McGrath <roland@redhat.com>
Wed, 18 Aug 2010 17:56:52 +0000 (10:56 -0700)
committerRoland McGrath <roland@redhat.com>
Wed, 18 Aug 2010 17:56:52 +0000 (10:56 -0700)
libdw/ChangeLog
libdw/c++/dwarf_data
libdw/c++/subr.hh

index 13492f9df2b9860ad2869926f38c71dddc716296..3d234088be5078d116d6fe2137a9ef5bf1332c84 100644 (file)
@@ -1,3 +1,9 @@
+2010-08-18  Roland McGrath  <roland@redhat.com>
+
+       * c++/subr.hh (subr::container_tail_equal): New function.
+       * c++/dwarf_data (dwarf_data::directory_table::operator==): Use it
+       to ignore the compilation directory (first table element).
+
 2010-07-21  Roland McGrath  <roland@redhat.com>
 
        * c++/dwarf_ref_maker (dwarf_ref_maker::seen): Add copy constructor
index 134ff8e3ecaad6e6da6646e154bc48be7657e39a..daf0aa2c67d45e66c9f85b8104061e8be3c22173 100644 (file)
@@ -1,5 +1,5 @@
 /* elfutils::dwarf_data -- internal DWARF data representations in -*- C++ -*-
-   Copyright (C) 2009 Red Hat, Inc.
+   Copyright (C) 2009-2010 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -318,7 +318,11 @@ namespace elfutils
       template<typename table>
       inline bool operator== (const table &other) const
       {
-       return size () == other.size () && subr::container_equal (*this, other);
+       /* We ignore the first element, the compilation directory.
+          This is actually part of the CU, not part of the line info.
+          The directory table itself matches regardless.  */
+       return (size () == other.size ()
+               && subr::container_tail_equal (*this, other, 1));
       }
       template<typename table>
       inline bool operator!= (const table &other) const
index bd7464d3cff0ef882cbf00e2515c29f658fdc3fd..fda1f29545714526b5318ab39fd719c065403740 100644 (file)
@@ -282,12 +282,22 @@ namespace elfutils
     }
 
     template<typename t1, typename t2, typename pred_type>
-    inline bool container_equal (const t1 &a, const t2 &b, pred_type pred)
+    inline bool container_equal (const t1 &a, const t2 &b, pred_type pred,
+                                typename t1::size_type skip = 0)
     {
       typename t1::const_iterator first1 = a.begin ();
       typename t1::const_iterator last1 = a.end ();
       typename t2::const_iterator first2 = b.begin ();
       typename t2::const_iterator last2 = b.end ();
+      while (skip-- > 0)
+       {
+         if (first1 == last1)
+           return first2 == last2;
+         if (first2 == last2)
+           return first1 == last1;
+         ++first1;
+         ++first2;
+       }
       return container_equal (first1, last1, first2, last2, pred);
     }
 
@@ -297,6 +307,13 @@ namespace elfutils
       return container_equal (a, b, deref_equal_to<t1, t2> ());
     }
 
+    template<typename t1, typename t2>
+    inline bool container_tail_equal (const t1 &a, const t2 &b,
+                                     typename t1::size_type skip = 0)
+    {
+      return container_equal (a, b, deref_equal_to<t1, t2> (), skip);
+    }
+
     template<typename iter>
     inline typename iter::difference_type length (iter i, const iter &end)
     {