From: g0dil Date: Mon, 3 Sep 2007 10:38:23 +0000 (+0000) Subject: Better SENF configuration support (local_config.hh) X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=271789888cd1ae6361607616f9f4e6e460e192c4;p=senf.git Better SENF configuration support (local_config.hh) Packets: Fix PacketImpl::updateIterators implemantation (don't access invalidated iterators) Scheduler: Remove access to invalidated timerMap_ iterator Socket: BUGFIX: Fix generic WriteRange implementation git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@424 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Packets/PacketImpl.cc b/Packets/PacketImpl.cc index 8dfd75e..777fae7 100644 --- a/Packets/PacketImpl.cc +++ b/Packets/PacketImpl.cc @@ -57,7 +57,7 @@ prefix_ void senf::detail::PacketImpl::clear(PacketData * self) truncateInterpreters(n); iterator first (boost::next(begin(),self->begin_)); data_.erase(first, boost::next(begin(),self->end_)); - updateIterators(self,first,-self->size()); + updateIterators(self,self->begin_,-self->size()); } // private members @@ -73,7 +73,7 @@ prefix_ void senf::detail::PacketImpl::eraseInterpreters(interpreter_list::itera } } -prefix_ void senf::detail::PacketImpl::updateIterators(PacketData * self, iterator pos, +prefix_ void senf::detail::PacketImpl::updateIterators(PacketData * self, difference_type pos, difference_type n) { // I hate to change the PacketData representation from here, I would have preferred to let @@ -101,7 +101,7 @@ prefix_ void senf::detail::PacketImpl::updateIterators(PacketData * self, iterat // c) interpreter_list::iterator const i_end (interpreters_.end()); if (++i != i_end) - if (std::distance(begin(), pos) < difference_type(i->begin_)) + if (pos <= difference_type(i->begin_)) // pos is before the packet, it must then be before all futher packets ... for (; i != i_end; ++i) { i->begin_ += n; diff --git a/Packets/PacketImpl.cci b/Packets/PacketImpl.cci index f2293a8..0197b24 100644 --- a/Packets/PacketImpl.cci +++ b/Packets/PacketImpl.cci @@ -148,27 +148,32 @@ prefix_ senf::detail::PacketImpl::size_type senf::detail::PacketImpl::size() prefix_ void senf::detail::PacketImpl::insert(PacketData * self, iterator pos, byte v) { + difference_type ix (std::distance(begin(),pos)); data_.insert(pos,v); - updateIterators(self,pos,1); + updateIterators(self,ix,1); } prefix_ void senf::detail::PacketImpl::insert(PacketData * self, iterator pos, size_type n, byte v) { + difference_type ix (std::distance(begin(),pos)); data_.insert(pos,n,v); - updateIterators(self,pos,n); + updateIterators(self,ix,n); } prefix_ void senf::detail::PacketImpl::erase(PacketData * self, iterator pos) { + difference_type ix (std::distance(begin(),pos)); data_.erase(pos); - updateIterators(self,pos,-1); + updateIterators(self,ix,-1); } prefix_ void senf::detail::PacketImpl::erase(PacketData * self, iterator first, iterator last) { + difference_type ix (std::distance(begin(),first)); + difference_type delta (std::distance(first,last)); data_.erase(first,last); - updateIterators(self,first,-std::distance(first,last)); + updateIterators(self,ix,-delta); } /////////////////////////////////////////////////////////////////////////// diff --git a/Packets/PacketImpl.cti b/Packets/PacketImpl.cti index 2e3fada..ae6cc1e 100644 --- a/Packets/PacketImpl.cti +++ b/Packets/PacketImpl.cti @@ -37,8 +37,9 @@ template prefix_ void senf::detail::PacketImpl::insert(PacketData * self, iterator pos, ForwardIterator f, ForwardIterator l) { + difference_type ix (std::distance(begin(),pos)); data_.insert(pos,f,l); - updateIterators(self,pos,std::distance(f,l)); + updateIterators(self,ix,std::distance(f,l)); } template diff --git a/Packets/PacketImpl.hh b/Packets/PacketImpl.hh index 614eba2..ad254d6 100644 --- a/Packets/PacketImpl.hh +++ b/Packets/PacketImpl.hh @@ -121,7 +121,7 @@ namespace detail { interpreter_list interpreters_; void eraseInterpreters(interpreter_list::iterator b, interpreter_list::iterator e); - void updateIterators(PacketData * self, iterator pos, difference_type n); + void updateIterators(PacketData * self, difference_type pos, difference_type n); }; }} diff --git a/Packets/ParseArray.cti b/Packets/ParseArray.cti index 14d99cb..ee2732d 100644 --- a/Packets/ParseArray.cti +++ b/Packets/ParseArray.cti @@ -26,13 +26,6 @@ #include "ParseArray.ih" // Custom includes -#include -#if defined(_STLP_ALGORITHM) || (__GNUC__<4 && __GNUC_MINOR__<4) -#define copy_n std::copy_n -#else -#include -#define copy_n __gnu_cxx::copy_n -#endif #define prefix_ inline ///////////////////////////////cti.p/////////////////////////////////////// @@ -154,7 +147,6 @@ prefix_ void senf::detail::Parse_Array_iterator::advance(int n) i_ += n*ElementParser::fixed_bytes; } -#undef copy_n ///////////////////////////////cti.e/////////////////////////////////////// #undef prefix_ diff --git a/SConstruct b/SConstruct index ed68a67..e723e46 100644 --- a/SConstruct +++ b/SConstruct @@ -33,7 +33,7 @@ def nonemptyFile(f): except OSError: return False def checkLocalConf(target, source, env): - if nonemptyFile('SConfig') or nonemptyFile('Doxyfile.local'): + if [ True for f in env['CONFIG_FILES'] if nonemptyFile(f) ]: print print "You have made local modifications to 'SConfig' and/or 'Doxyfile.local'." print "Building a debian package would remove those files." @@ -73,8 +73,11 @@ logname = os.environ.get('LOGNAME') if not logname: logname = pwd.getpwuid(os.getuid()).pw_name +def configFilesOpts(target, source, env, for_signature): + return [ '-I%s' % os.path.split(f)[1] for f in env['CONFIG_FILES'] ] + env.Append( - CPPPATH = [ ], + CPPPATH = [ '#' ], LIBS = [ 'iberty', '$BOOSTREGEXLIB' ], DOXY_XREF_TYPES = [ 'bug', 'fixme', 'todo', 'idea' ], DOXY_HTML_XSL = '#/doclib/html-munge.xsl', @@ -83,8 +86,10 @@ env.Append( 'LOGNAME' : logname, # needed by the debian build scripts 'CONCURRENCY_LEVEL' : env.GetOption('num_jobs') or "1" }, + CONFIG_FILES = [ 'Doxyfile.local', 'SConfig', 'local_config.hh' ], + CONFIG_FILES_OPTS = configFilesOpts, CLEAN_PATTERNS = [ '*.pyc', 'semantic.cache', '.sconsign', '.sconsign.dblite' ], - BUILDPACKAGE_COMMAND = "dpkg-buildpackage -us -uc -rfakeroot -I.svn -IDoxyfile.local -ISConfig", + BUILDPACKAGE_COMMAND = "dpkg-buildpackage -us -uc -rfakeroot -I.svn $CONFIG_FILES_OPTS", ) Export('env') @@ -94,15 +99,9 @@ Export('env') if not env.GetOption('clean') and not os.path.exists("Doxyfile.local"): Execute(Touch("Doxyfile.local")) -# Create config.h -file("config.h","w").write( -"""#ifndef H_config_ -#define H_config_ 1 -// This looks stupid. However, we need this since the debian packaged Version -// of SENF is installed in a 'senf' subdirectory which the source Version is not -#define SENF_ABSOLUTE_INCLUDE_PATH(senf_relative_include_file_path) <%s/senf_relative_include_file_path> -#endif -""" % env.Dir('#').abspath) +# Create local_config.h +if not env.GetOption('clean') and not os.path.exists("local_config.hh"): + Execute(Touch("local_config.hh")) ########################################################################### # Define build targets @@ -116,6 +115,8 @@ SENFSCons.DoxyXRef(env, HTML_HEADER = '#/doclib/doxy-header-overview.html', HTML_FOOTER = '#/doclib/doxy-footer.html') +SENFSCons.InstallIncludeFiles(env, [ 'config.hh' ]) + # Build combined library 'libsenf' libsenf = env.Library( SENFSCons.LibPath('senf'), @@ -141,5 +142,3 @@ env.Clean('all', [ os.path.join(path,f) for path, subdirs, files in os.walk('.') for pattern in env['CLEAN_PATTERNS'] for f in fnmatch.filter(files,pattern) ]) - -env.Clean('all', 'config.h') diff --git a/Scheduler/Scheduler.cc b/Scheduler/Scheduler.cc index e6e8b85..09971a8 100644 --- a/Scheduler/Scheduler.cc +++ b/Scheduler/Scheduler.cc @@ -201,8 +201,8 @@ prefix_ void senf::Scheduler::process() i->second.cb(); else break; - timerMap_.erase(i); timerQueue_.pop(); + timerMap_.erase(i); } if (events <= 0) diff --git a/Socket/ClientSocketHandle.ct b/Socket/ClientSocketHandle.ct index 1b8190c..6ad4040 100644 --- a/Socket/ClientSocketHandle.ct +++ b/Socket/ClientSocketHandle.ct @@ -60,25 +60,29 @@ readfrom(Handle & handle, ForwardWritableRange & range, typename Handle::Address // senf::detail::WriteRange template -prefix_ typename boost::range_iterator::type +prefix_ typename boost::range_const_iterator::type senf::detail::WriteRange:: write(Handle & handle, ForwardReadableRange & range) { typename boost::range_size::type nwrite (boost::size(range)); + typename boost::range_const_iterator::type i (boost::begin(range)); SENF_SCOPED_BUFFER(char, buffer, nwrite); - std::copy(boost::begin(range), boost::end(range), buffer); - return handle.write(std::make_pair(buffer, buffer+nwrite)); + std::copy(i, boost::end(range), buffer); + std::advance(i, handle.write(std::make_pair(buffer, buffer+nwrite)) - buffer); + return i; } template -prefix_ typename boost::range_iterator::type +prefix_ typename boost::range_const_iterator::type senf::detail::WriteRange:: writeto(Handle & handle, ForwardReadableRange & range, typename Handle::Address const & addr) { typename boost::range_size::type nwrite (boost::size(range)); + typename boost::range_const_iterator::type i (boost::begin(range)); SENF_SCOPED_BUFFER(char, buffer, nwrite); - std::copy(boost::begin(range), boost::end(range), buffer); - return handle.writeto(std::make_pair(buffer, buffer+nwrite), addr); + std::copy(i, boost::end(range), buffer); + std::advance(i, handle.writeto(std::make_pair(buffer, buffer+nwrite), addr) - buffer); + return i; } /////////////////////////////////////////////////////////////////////////// diff --git a/Socket/ClientSocketHandle.cti b/Socket/ClientSocketHandle.cti index f584a18..b2e721f 100644 --- a/Socket/ClientSocketHandle.cti +++ b/Socket/ClientSocketHandle.cti @@ -68,13 +68,13 @@ prefix_ typename boost::range_const_iterator::type senf::detail::WriteRange:: write(Handle & handle, ForwardReadableRange & range) { - typename boost::range_const_iterator::type const i + typename boost::range_const_iterator::type i (boost::const_begin(range)); char const * const ic (reinterpret_cast(storage_iterator(i))); - return i + (handle.write(ic, - reinterpret_cast( - storage_iterator(boost::const_end(range)))) - - ic); + std::advance(i, handle.write(ic, + reinterpret_cast( + storage_iterator(boost::const_end(range)))) - ic); + return i; } template @@ -82,14 +82,13 @@ prefix_ typename boost::range_const_iterator::type senf::detail::WriteRange:: writeto(Handle & handle, ForwardReadableRange & range, typename Handle::Address const & addr) { - typename boost::range_const_iterator::type const i + typename boost::range_const_iterator::type i (boost::const_begin(range)); char const * const ic (reinterpret_cast(storage_iterator(i))); - return i + (handle.writeto(addr, - ic, - reinterpret_cast( - storage_iterator(boost::const_end(range)))) - - ic); + std::advance(i, handle.writeto(addr, ic, + reinterpret_cast( + storage_iterator(boost::const_end(range)))) - ic); + return i; } /////////////////////////////////////////////////////////////////////////// diff --git a/Socket/ClientSocketHandle.ih b/Socket/ClientSocketHandle.ih index 83f49bc..619f524 100644 --- a/Socket/ClientSocketHandle.ih +++ b/Socket/ClientSocketHandle.ih @@ -79,10 +79,10 @@ namespace detail { template struct WriteRange { - static typename boost::range_iterator::type + static typename boost::range_const_iterator::type write(Handle & handle, ForwardReadableRange & range); - static typename boost::range_iterator::type + static typename boost::range_const_iterator::type writeto(Handle & handle, ForwardReadableRange & range, typename Handle::Address const & addr); }; diff --git a/Socket/ProtocolClientSocketHandle.hh b/Socket/ProtocolClientSocketHandle.hh index c40515b..ea00e04 100644 --- a/Socket/ProtocolClientSocketHandle.hh +++ b/Socket/ProtocolClientSocketHandle.hh @@ -29,7 +29,7 @@ // Custom includes #include "ClientSocketHandle.hh" -#include "../config.h" +#include "../config.hh" #include "ProtocolClientSocketHandle.mpp" ///////////////////////////////hh.p//////////////////////////////////////// diff --git a/Socket/ProtocolServerSocketHandle.hh b/Socket/ProtocolServerSocketHandle.hh index bd9200d..49b8dc0 100644 --- a/Socket/ProtocolServerSocketHandle.hh +++ b/Socket/ProtocolServerSocketHandle.hh @@ -29,6 +29,7 @@ // Custom includes #include "ServerSocketHandle.hh" +#include "../config.hh" #include "ProtocolServerSocketHandle.mpp" ///////////////////////////////hh.p//////////////////////////////////////// diff --git a/Utils/Buffer.hh b/Utils/Buffer.hh index b61d13e..6ce84a6 100644 --- a/Utils/Buffer.hh +++ b/Utils/Buffer.hh @@ -27,31 +27,11 @@ #define HH_Buffer_ 1 // Custom includes +#include "../config.hh" //#include "Buffer.mpp" ///////////////////////////////hh.p//////////////////////////////////////// -#if !defined(SENF_BUFFER_USE_LOCALS) && !defined(SENF_BUFFER_USE_ALLOCA) && !defined(SENF_BUFFER_USE_NEW) -# -# -# if defined(__GNUC__) -# define SENF_BUFFER_USE_LOCALS 1 -# -# // Add other compilers here ... -# -# // dynamic arrays are part of C99. Which is NOT part of C++ -# // but lets try nonetheless ... -# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -# define SENF_BUFFER_USE_LOCALS 1 -# -# endif -# -# if !defined(SENF_BUFFER_USE_LOCALS) && !defined(SENF_BUFFER_USE_ALLOCA) -# define SENF_BUFFER_USE_NEW 1 -# endif -# -#endif - #if defined(SENF_BUFFER_USE_LOCALS) # define SENF_SCOPED_BUFFER(type, sym, size) \ diff --git a/Utils/IteratorTraits.ih b/Utils/IteratorTraits.ih index 780490e..9533e3d 100644 --- a/Utils/IteratorTraits.ih +++ b/Utils/IteratorTraits.ih @@ -32,21 +32,20 @@ namespace senf { - // It is not very nice that we need to specialize on the exact iterator names. - // The preprocessor guard will need to be expanded by also giving the correct - // version numbers. We need to disable it when using stlport and so on ... - // The problem is, that typedefs are not expanded when specializing ... + // It is not very nice that we need to specialize on the exact iterator names. The preprocessor + // guard will need to be expanded by also giving the correct version numbers. The problem is, + // that typedefs are not expanded when specializing ... #if defined(__GNUG__) template struct contiguous_storage_iterator< - __gnu_cxx::__normal_iterator > > + ::__gnu_cxx::__normal_iterator > > : public boost::true_type {}; template struct contiguous_storage_iterator< - __gnu_cxx::__normal_iterator > > + ::__gnu_cxx::__normal_iterator > > : public boost::true_type {}; #endif diff --git a/Utils/IteratorTraits.test.cc b/Utils/IteratorTraits.test.cc index ddfe60e..d874e22 100644 --- a/Utils/IteratorTraits.test.cc +++ b/Utils/IteratorTraits.test.cc @@ -41,7 +41,7 @@ BOOST_AUTO_UNIT_TEST(iteratorTraits) { BOOST_CHECK_EQUAL( senf::contiguous_storage_iterator::value, true ); BOOST_CHECK_EQUAL( senf::contiguous_storage_iterator::value, false ); -#ifdef __GNUG__ +#if defined(__GNUG__) && ! defined(_GLIBCXX_DEBUG) BOOST_CHECK_EQUAL( senf::contiguous_storage_iterator::iterator>::value, true); BOOST_CHECK_EQUAL( senf::contiguous_storage_iterator::value, true); #endif diff --git a/Utils/impl/membind.hh b/Utils/impl/membind.hh index 7dc1930..6b6681c 100644 --- a/Utils/impl/membind.hh +++ b/Utils/impl/membind.hh @@ -27,7 +27,7 @@ #include #include #include -#include "../../config.h" +#include "../../config.hh" template boost::function membind(R (T::* fn)(),scOBTYPE ob) diff --git a/Utils/mpl.hh b/Utils/mpl.hh index 5eee0c5..ba60083 100644 --- a/Utils/mpl.hh +++ b/Utils/mpl.hh @@ -27,6 +27,7 @@ #define HH_mpl_ 1 // Custom includes +#include "../config.hh" //#include "mpl.mpp" #include "mpl.ih" @@ -38,10 +39,6 @@ namespace mpl { /** \defgroup senfmpl Low-level template meta programming helpers */ -# ifndef SENF_MPL_RV_ALIGNMENT -# define SENF_MPL_RV_ALIGNMENT 16 -# endif - /** \brief Return-value type used to implement overload selection The senf::mpl::rv type is used together with \ref SENF_MPL_RV() to select template diff --git a/config.hh b/config.hh new file mode 100644 index 0000000..a0e1cbc --- /dev/null +++ b/config.hh @@ -0,0 +1,88 @@ +// $Id$ +// +// Copyright (C) 2007 +// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) +// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Stefan Bund +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief config public header */ + +#ifndef HH_config_ +#define HH_config_ 1 + +// Custom includes + +//#include "config.mpp" +///////////////////////////////hh.p//////////////////////////////////////// + +# include "local_config.hh" + +# ifndef SENF_ABSOLUTE_INCLUDE_PATH +# define SENF_ABSOLUTE_INCLUDE_PATH(senf_relative_include_file_path) +# endif + +# ifndef SENF_copy_n +# include +# if defined(__GNUC__) && ! defined(_STLP_ALGORITHM) && (__GNUC__>=4 || (__GNUC__==3 && __GNUC_MINOR__>=4)) +# include +# define SENF_copy_n __gnu_cxx::copy_n +# else +# define SENF_copy_n std::copy_n +# endif +# endif + +# ifndef SENF_MPL_RV_ALIGNMENT +# define SENF_MPL_RV_ALIGNMENT 16 +# endif + +# if !defined(SENF_BUFFER_USE_LOCALS) && !defined(SENF_BUFFER_USE_ALLOCA) && !defined(SENF_BUFFER_USE_NEW) +# +# if defined(__GNUC__) +# define SENF_BUFFER_USE_LOCALS 1 +# +# // Add other compilers here ... +# +# // dynamic arrays are part of C99. Which is NOT part of C++ +# // but lets try nonetheless ... +# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define SENF_BUFFER_USE_LOCALS 1 +# endif +# +# if !defined(SENF_BUFFER_USE_LOCALS) && !defined(SENF_BUFFER_USE_ALLOCA) +# define SENF_BUFFER_USE_NEW 1 +# endif +# +# endif + +///////////////////////////////hh.e//////////////////////////////////////// +//#include "config.cci" +//#include "config.ct" +//#include "config.cti" +#endif + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: diff --git a/debian/config.h b/debian/config.h deleted file mode 100644 index c30ab03..0000000 --- a/debian/config.h +++ /dev/null @@ -1,51 +0,0 @@ -// $Id$ -// -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -/** \file - \brief config public header */ - -#ifndef H_config_ -#define H_config_ 1 - -// Custom includes - -//#include "config.mpp" -///////////////////////////////hh.p//////////////////////////////////////// - -#define SENF_ABSOLUTE_INCLUDE_PATH(senf_relative_include_file_path) - -///////////////////////////////hh.e//////////////////////////////////////// -//#include "config.cci" -//#include "config.ct" -//#include "config.cti" -#endif - - -// Local Variables: -// mode: c++ -// fill-column: 100 -// comment-column: 40 -// c-file-style: "senf" -// indent-tabs-mode: nil -// ispell-local-dictionary: "american" -// compile-command: "scons -u test" -// End: diff --git a/debian/libsenf-dev.install b/debian/libsenf-dev.install index 1fc59c5..cdb869b 100644 --- a/debian/libsenf-dev.install +++ b/debian/libsenf-dev.install @@ -6,7 +6,7 @@ debian/tmp/usr/include/Scheduler usr/include/senf debian/tmp/usr/include/Socket usr/include/senf debian/tmp/usr/include/Utils usr/include/senf boost usr/include/senf -debian/config.h usr/include/senf +debian/local_config.hh usr/include/senf debian/Socket.hh usr/include/senf debian/Packets.hh usr/include/senf debian/PPI.hh usr/include/senf diff --git a/debian/local_config.hh b/debian/local_config.hh new file mode 100644 index 0000000..1ee04a4 --- /dev/null +++ b/debian/local_config.hh @@ -0,0 +1,2 @@ + +#define SENF_ABSOLUTE_INCLUDE_PATH(senf_relative_include_file_path) diff --git a/debian/rules b/debian/rules index b6a8e66..ea893a0 100755 --- a/debian/rules +++ b/debian/rules @@ -37,9 +37,10 @@ configure: configure-stamp configure-stamp: dh_testdir # # Add here commands to configure the package. - rm -f Doxyfile.local SConfig -# If needed, we could create new 'Doxyfile.local' and/or 'SConfig' files here. -# We don't remove them in 'clean' to allow building a source package from an + rm -f Doxyfile.local SConfig local_config.hh +# If needed, we could create new files 'Doxyfile.local', +# 'SConfig' and/or 'local_config.hh' here. We don't remove them +# in 'clean' to allow building a source package from an # individually configured svn working copy. touch configure-stamp diff --git a/find-sources.sh b/find-sources.sh index 32008f4..be46965 100755 --- a/find-sources.sh +++ b/find-sources.sh @@ -22,6 +22,7 @@ set -f find . \ -name .svn -prune -o \ -name doc -prune -o \ + -name debian -prune -o \ -name "*.a" -o \ -name "*.o" -o \ -name "*~" -o \ diff --git a/run-test-gdb.sh b/run-test-gdb.sh index 8d87f2a..7fa122a 100755 --- a/run-test-gdb.sh +++ b/run-test-gdb.sh @@ -8,9 +8,6 @@ # This script will run the .test.bin test driver within gdb and will # create a backtrace for every exception caught by the test driver. # -# NOTE: If your unit test (excplicitly) writes output to stderr, this -# output will be lost -# # NOTE: This works by setting a breakpoint in the std::exception # constructor. This is, where the backtrace is created from. If you do # some funky manipulations with your exceptions, the backtrace might @@ -38,8 +35,9 @@ EOF # correctly (cought before the reach the unit test driver). It will # also truncate the backtrace at the first stackframe within the unit # test subsystem since we are only interested in the user code. -gdb -batch -x .run-test-gdb.cmd ./.test.bin 2>/dev/null | perl -e ' +gdb -batch -x .run-test-gdb.cmd ./.test.bin 2>&1 | perl -e ' $mode=0; + $silent=0; while () { if ($mode==0) { if (/^$/) { @@ -49,7 +47,7 @@ gdb -batch -x .run-test-gdb.cmd ./.test.bin 2>/dev/null | perl -e ' } } elsif ($mode==1) { - if (/^Breakpoint 1, exception/) { + if (/^(Breakpoint 1, exception|Program received signal )/) { $mode=2; @l=(); } else { @@ -62,16 +60,26 @@ gdb -batch -x .run-test-gdb.cmd ./.test.bin 2>/dev/null | perl -e ' if (/^(#?[0-9]| )/) { push @l,$_ if /^#/; $l[$#l] .= $_ if @l && /^ /; - } elsif (/^Current language: auto;/) { + } elsif (/^(Current language: auto;|\[Switching to Thread)/) { ; } else { $mode=0; if (/: fatal error in /) { + print "\n"; for (@l[1..$#l]) { last if /^#[0-9]+ +0x[0-9a-f]+ in boost::unit_test::ut_detail::invoker/; - print; + if ($silent) { + unless (/at \/usr\/lib\/gcc\//) { + print; + $silent=0; + } + } else { + print unless /in \?\?/; + $silent=1 if /__gnu_debug::/; + } } print; + print "\n"; } else { redo; } diff --git a/senfscons/SENFSCons.py b/senfscons/SENFSCons.py index 373b5d6..da20141 100644 --- a/senfscons/SENFSCons.py +++ b/senfscons/SENFSCons.py @@ -245,6 +245,8 @@ def MakeEnvironment(): CPPDEFINES = [ 'NDEBUG' ]) else: env.Append(CXXFLAGS = [ '-O0', '-g', '-fno-inline' ], + # The unit-test framework is not compiled with _GLIBCXX_DEBUG so this fails. + # CPPDEFINES = [ '_GLIBCXX_DEBUG', 'BOOST_REGEX_NO_LIB' ], LINKFLAGS = [ '-g' ]) env.Append(CPPDEFINES = [ '$EXTRA_DEFINES' ],