diff --git a/Jamfile b/Jamfile index 992d4349b..c6a97300f 100755 --- a/Jamfile +++ b/Jamfile @@ -325,6 +325,9 @@ feature iconv : auto on off : composite propagated ; feature.compose on : TORRENT_USE_ICONV=1 ; feature.compose off : TORRENT_USE_ICONV=0 ; +feature valgrind : off on : composite propagated link-incompatible ; +feature.compose on : TORRENT_USE_VALGRIND=1 ; + feature full-stats : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_FULL_STATS ; diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 2d5caaa8d..42a544bf8 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -185,20 +185,33 @@ namespace libtorrent std::vector::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::iterator i) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 256511438..562bf467c 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -46,6 +46,10 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#ifdef TORRENT_USE_VALGRIND +#include +#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; diff --git a/test/Jamfile b/test/Jamfile index 50953ff40..d3cc95261 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -96,7 +96,7 @@ project ; feature launcher : none valgrind : composite ; -feature.compose valgrind : "valgrind --tool=memcheck -v --track-origins=yes --error-exitcode=1" ; +feature.compose valgrind : "valgrind --tool=memcheck -v --num-callers=20 --read-var-info=yes --track-origins=yes --error-exitcode=1" on ; test-suite libtorrent : [ run test_file_storage.cpp ] diff --git a/tools/parse_test_results.py b/tools/parse_test_results.py index e5f608f4b..df6a07008 100755 --- a/tools/parse_test_results.py +++ b/tools/parse_test_results.py @@ -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 += '%s\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 += '%s\n' % l elif l == '====== END OUTPUT ======' and not subtle: ret += '%s\n' % l