From: Roland McGrath Date: Wed, 18 Aug 2010 17:56:52 +0000 (-0700) Subject: Ignore CU compilation directory in directory table comparison. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a35a3ca62513671aa0bfb4da4607001c6fe24db;p=thirdparty%2Felfutils.git Ignore CU compilation directory in directory table comparison. --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 13492f9df..3d234088b 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,9 @@ +2010-08-18 Roland McGrath + + * 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 * c++/dwarf_ref_maker (dwarf_ref_maker::seen): Add copy constructor diff --git a/libdw/c++/dwarf_data b/libdw/c++/dwarf_data index 134ff8e3e..daf0aa2c6 100644 --- a/libdw/c++/dwarf_data +++ b/libdw/c++/dwarf_data @@ -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 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 inline bool operator!= (const table &other) const diff --git a/libdw/c++/subr.hh b/libdw/c++/subr.hh index bd7464d3c..fda1f2954 100644 --- a/libdw/c++/subr.hh +++ b/libdw/c++/subr.hh @@ -282,12 +282,22 @@ namespace elfutils } template - 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 ()); } + template + 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 (), skip); + } + template inline typename iter::difference_type length (iter i, const iter &end) {