attempt to trigger valgrind errors earlier

This commit is contained in:
Arvid Norberg 2013-10-02 21:51:30 +00:00
parent 735d8213ac
commit 64b563fd06
5 changed files with 32 additions and 6 deletions

View File

@ -325,6 +325,9 @@ feature iconv : auto on off : composite propagated ;
feature.compose <iconv>on : <define>TORRENT_USE_ICONV=1 ;
feature.compose <iconv>off : <define>TORRENT_USE_ICONV=0 ;
feature valgrind : off on : composite propagated link-incompatible ;
feature.compose <valgrind>on : <define>TORRENT_USE_VALGRIND=1 ;
feature full-stats : on off : composite propagated link-incompatible ;
feature.compose <full-stats>off : <define>TORRENT_DISABLE_FULL_STATS ;

View File

@ -185,20 +185,33 @@ namespace libtorrent
std::vector<downloading_piece>::iterator i = std::lower_bound(m_downloads.begin()
, m_downloads.end(), cmp);
TORRENT_ASSERT(i == m_downloads.end() || i->index != piece);
i = m_downloads.insert(i, downloading_piece());
downloading_piece& ret = *i;
downloading_piece ret;
ret.index = piece;
ret.info = &m_block_info[block_index];
#ifdef TORRENT_USE_VALGRIND
VALGRIND_CHECK_VALUE_IS_DEFINED(piece);
VALGRIND_CHECK_VALUE_IS_DEFINED(block_index);
#endif
for (int i = 0; i < m_blocks_per_piece; ++i)
{
ret.info[i].num_peers = 0;
ret.info[i].state = block_info::state_none;
ret.info[i].peer = 0;
#ifdef TORRENT_USE_VALGRIND
VALGRIND_CHECK_VALUE_IS_DEFINED(ret.info[i].num_peers);
VALGRIND_CHECK_VALUE_IS_DEFINED(ret.info[i].state);
VALGRIND_CHECK_VALUE_IS_DEFINED(ret.info[i].peer);
#endif
#if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS
ret.info[i].piece_index = piece;
#endif
}
return ret;
#ifdef TORRENT_USE_VALGRIND
VALGRIND_CHECK_VALUE_IS_DEFINED(ret);
#endif
i = m_downloads.insert(i, ret);
return *i;
}
void piece_picker::erase_download_piece(std::vector<downloading_piece>::iterator i)

View File

@ -46,6 +46,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/bind.hpp>
#include <boost/function_equal.hpp>
#ifdef TORRENT_USE_VALGRIND
#include <valgrind/memcheck.h>
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
@ -3919,7 +3923,11 @@ retry:
int total_job_time = cs.cumulative_job_time == 0 ? 1 : cs.cumulative_job_time;
#ifdef TORRENT_USE_VALGRIND
#define STAT_LOG(type, val) VALGRIND_CHECK_VALUE_IS_DEFINED(val); fprintf(m_stats_logger, "%" #type "\t", val)
#else
#define STAT_LOG(type, val) fprintf(m_stats_logger, "%" #type "\t", val)
#endif
STAT_LOG(f, total_milliseconds(now - m_last_log_rotation) / 1000.f);
size_type uploaded = m_stat.total_upload() - m_last_uploaded;

View File

@ -96,7 +96,7 @@ project
;
feature launcher : none valgrind : composite ;
feature.compose <launcher>valgrind : <testing.launcher>"valgrind --tool=memcheck -v --track-origins=yes --error-exitcode=1" ;
feature.compose <launcher>valgrind : <testing.launcher>"valgrind --tool=memcheck -v --num-callers=20 --read-var-info=yes --track-origins=yes --error-exitcode=1" <valgrind>on ;
test-suite libtorrent :
[ run test_file_storage.cpp ]

View File

@ -55,9 +55,11 @@ def style_output(o):
' : error LNK' in l or ': undefined reference to ' in l or \
'jump or move depends on uninitialised value(s)' in l or \
'Invalid read of size' in l or \
'Invalid write of size' in l:
'Invalid write of size' in l or \
'Use of uninitialised value of size' in l:
ret += '<span class="compile-error">%s</span>\n' % l
elif ': warning: ' in l or ') : warning C' in l:
elif ': warning: ' in l or ') : warning C' in l \
or 'Uninitialised value was created by a' in l:
ret += '<span class="compile-warning">%s</span>\n' % l
elif l == '====== END OUTPUT ======' and not subtle:
ret += '<span class="subtle">%s\n' % l