some cleanup of TORRENT_DEBUG defines (#863)

some cleanup of TORRENT_DEBUG defines
This commit is contained in:
Arvid Norberg 2016-06-27 22:28:51 -04:00 committed by GitHub
parent f7515edc8b
commit a675682b6c
10 changed files with 47 additions and 55 deletions

14
Jamfile
View File

@ -113,7 +113,8 @@ rule linking ( properties * )
} }
if <target-os>windows in $(properties) if <target-os>windows in $(properties)
&& ( <asserts>on in $(properties) && ( <define>TORRENT_DEBUG
|| <asserts>on in $(properties)
|| <asserts>production in $(properties) || <asserts>production in $(properties)
|| <pool-allocators>debug in $(properties) || <pool-allocators>debug in $(properties)
|| <allocator>debug in $(properties) || <allocator>debug in $(properties)
@ -338,7 +339,7 @@ rule building ( properties * )
result += <cflags>-ftrapv ; result += <cflags>-ftrapv ;
} }
if ( <variant>debug in $(properties) if ( <asserts>production in $(properties)
|| <asserts>on in $(properties) ) || <asserts>on in $(properties) )
{ {
result += <source>src/assert.cpp ; result += <source>src/assert.cpp ;
@ -422,10 +423,10 @@ feature memory-optimization : off on : composite propagated link-incompatible ;
feature.compose <memory-optimization>on : <define>TORRENT_OPTIMIZE_MEMORY_USAGE ; feature.compose <memory-optimization>on : <define>TORRENT_OPTIMIZE_MEMORY_USAGE ;
feature asserts : auto on off production system : composite propagated ; feature asserts : auto on off production system : composite propagated ;
feature.compose <asserts>on : <define>TORRENT_RELEASE_ASSERTS=1 ; feature.compose <asserts>on : <define>TORRENT_USE_ASSERTS=1 ;
feature.compose <asserts>production : <define>TORRENT_PRODUCTION_ASSERTS=1 <define>TORRENT_RELEASE_ASSERTS=1 ; feature.compose <asserts>production : <define>TORRENT_USE_ASSERTS=1 <define>TORRENT_PRODUCTION_ASSERTS=1 ;
feature.compose <asserts>system : <define>TORRENT_USE_ASSERTS=1 <define>TORRENT_USE_SYSTEM_ASSERTS=1 ;
feature.compose <asserts>off : <define>TORRENT_USE_ASSERTS=0 ; feature.compose <asserts>off : <define>TORRENT_USE_ASSERTS=0 ;
feature.compose <asserts>system : <define>TORRENT_USE_SYSTEM_ASSERTS=1 ;
feature windows-version : vista win7 xp : composite propagated link-incompatible ; feature windows-version : vista win7 xp : composite propagated link-incompatible ;
feature.compose <windows-version>vista : <define>_WIN32_WINNT=0x0600 ; feature.compose <windows-version>vista : <define>_WIN32_WINNT=0x0600 ;
@ -528,19 +529,16 @@ variant test_debug : debug
<allocator>debug <allocator>debug
<invariant-checks>full <boost-link>shared <invariant-checks>full <boost-link>shared
<export-extra>on <debug-iterators>on <threading>multi <asserts>on <export-extra>on <debug-iterators>on <threading>multi <asserts>on
<define>TORRENT_DEBUG
; ;
variant test_barebones : debug variant test_barebones : debug
: <ipv6>off <dht>off <extensions>off <logging>off <boost-link>shared : <ipv6>off <dht>off <extensions>off <logging>off <boost-link>shared
<deprecated-functions>off <invariant-checks>off <deprecated-functions>off <invariant-checks>off
<export-extra>on <debug-iterators>on <threading>multi <asserts>on <export-extra>on <debug-iterators>on <threading>multi <asserts>on
<define>TORRENT_DEBUG
; ;
variant test_arm : debug variant test_arm : debug
: <ipv6>off <dht>off <extensions>off <logging>off : <ipv6>off <dht>off <extensions>off <logging>off
<deprecated-functions>off <invariant-checks>off <deprecated-functions>off <invariant-checks>off
<export-extra>on <asserts>on <export-extra>on <asserts>on
<define>TORRENT_DEBUG
; ;
# required for openssl on windows # required for openssl on windows

View File

@ -52,7 +52,7 @@ namespace libtorrent { namespace aux
template <std::size_t Size> template <std::size_t Size>
struct handler_storage struct handler_storage
{ {
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
handler_storage() handler_storage()
: used(false) : used(false)
{} {}
@ -96,7 +96,7 @@ namespace libtorrent { namespace aux
{ {
TORRENT_UNUSED(size); TORRENT_UNUSED(size);
TORRENT_ASSERT(size <= Size); TORRENT_ASSERT(size <= Size);
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
TORRENT_ASSERT(!ctx->storage.used); TORRENT_ASSERT(!ctx->storage.used);
ctx->storage.used = true; ctx->storage.used = true;
#endif #endif
@ -112,7 +112,7 @@ namespace libtorrent { namespace aux
TORRENT_ASSERT(size <= Size); TORRENT_ASSERT(size <= Size);
TORRENT_ASSERT(ptr == &ctx->storage.bytes); TORRENT_ASSERT(ptr == &ctx->storage.bytes);
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ctx->storage.used = false; ctx->storage.used = false;
#endif #endif
} }

View File

@ -222,7 +222,7 @@ namespace libtorrent
if (in == end) if (in == end)
{ {
err = true; err = true;
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
return; return;
@ -242,7 +242,7 @@ namespace libtorrent
ret = entry(entry::int_t); ret = entry(entry::int_t);
char* end_pointer; char* end_pointer;
ret.integer() = strtoll(val.c_str(), &end_pointer, 10); ret.integer() = strtoll(val.c_str(), &end_pointer, 10);
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
if (end_pointer == val.c_str()) if (end_pointer == val.c_str())
@ -265,7 +265,7 @@ namespace libtorrent
bdecode_recursive(in, end, e, err, depth + 1); bdecode_recursive(in, end, e, err, depth + 1);
if (err) if (err)
{ {
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
return; return;
@ -273,13 +273,13 @@ namespace libtorrent
if (in == end) if (in == end)
{ {
err = true; err = true;
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
return; return;
} }
} }
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
TORRENT_ASSERT(*in == 'e'); TORRENT_ASSERT(*in == 'e');
@ -298,7 +298,7 @@ namespace libtorrent
bdecode_recursive(in, end, key, err, depth + 1); bdecode_recursive(in, end, key, err, depth + 1);
if (err || key.type() != entry::string_t) if (err || key.type() != entry::string_t)
{ {
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
return; return;
@ -307,7 +307,7 @@ namespace libtorrent
bdecode_recursive(in, end, e, err, depth + 1); bdecode_recursive(in, end, e, err, depth + 1);
if (err) if (err)
{ {
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
return; return;
@ -315,13 +315,13 @@ namespace libtorrent
if (in == end) if (in == end)
{ {
err = true; err = true;
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
return; return;
} }
} }
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
TORRENT_ASSERT(*in == 'e'); TORRENT_ASSERT(*in == 'e');
@ -336,7 +336,7 @@ namespace libtorrent
std::string len_s = read_until(in, end, ':', err); std::string len_s = read_until(in, end, ':', err);
if (err) if (err)
{ {
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
return; return;
@ -348,7 +348,7 @@ namespace libtorrent
read_string(in, end, len, ret.string(), err); read_string(in, end, len, ret.string(), err);
if (err) if (err)
{ {
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
return; return;
@ -357,12 +357,12 @@ namespace libtorrent
else else
{ {
err = true; err = true;
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
return; return;
} }
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
ret.m_type_queried = false; ret.m_type_queried = false;
#endif #endif
} }
@ -421,9 +421,7 @@ namespace libtorrent
entry e; entry e;
bool err = false; bool err = false;
detail::bdecode_recursive(start, end, e, err, 0); detail::bdecode_recursive(start, end, e, err, 0);
#ifdef TORRENT_DEBUG
TORRENT_ASSERT(e.m_type_queried == false); TORRENT_ASSERT(e.m_type_queried == false);
#endif
if (err) return entry(); if (err) return entry();
return e; return e;
} }

View File

@ -473,7 +473,7 @@ POSSIBILITY OF SUCH DAMAGE.
// builds have asserts if they are explicitly enabled by // builds have asserts if they are explicitly enabled by
// the release_asserts macro. // the release_asserts macro.
#ifndef TORRENT_USE_ASSERTS #ifndef TORRENT_USE_ASSERTS
#if defined TORRENT_DEBUG || defined TORRENT_RELEASE_ASSERTS #if defined TORRENT_DEBUG
#define TORRENT_USE_ASSERTS 1 #define TORRENT_USE_ASSERTS 1
#else #else
#define TORRENT_USE_ASSERTS 0 #define TORRENT_USE_ASSERTS 0

View File

@ -678,7 +678,7 @@ namespace libtorrent
void max_out_request_queue(int s); void max_out_request_queue(int s);
int max_out_request_queue() const; int max_out_request_queue() const;
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
bool piece_failed; bool piece_failed;
#endif #endif

View File

@ -583,7 +583,7 @@ namespace libtorrent
storage_interface* get_storage_impl() { return m_storage.get(); } storage_interface* get_storage_impl() { return m_storage.get(); }
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
void assert_torrent_refcount() const; void assert_torrent_refcount() const;
#endif #endif
private: private:

View File

@ -45,10 +45,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/performance_counters.hpp" #include "libtorrent/performance_counters.hpp"
#include "libtorrent/aux_/time.hpp" #include "libtorrent/aux_/time.hpp"
#ifdef TORRENT_DEBUG
#include "libtorrent/random.hpp"
#endif
/* /*
The disk cache mimics ARC (adaptive replacement cache). The disk cache mimics ARC (adaptive replacement cache).
@ -562,7 +558,7 @@ void block_cache::try_evict_one_volatile()
if (pe->ok_to_evict()) if (pe->ok_to_evict())
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
for (int j = 0; j < pe->blocks_in_piece; ++j) for (int j = 0; j < pe->blocks_in_piece; ++j)
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe); TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe);
#endif #endif
@ -605,7 +601,7 @@ void block_cache::try_evict_one_volatile()
if (pe->ok_to_evict()) if (pe->ok_to_evict())
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
for (int j = 0; j < pe->blocks_in_piece; ++j) for (int j = 0; j < pe->blocks_in_piece; ++j)
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe); TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe);
#endif #endif
@ -1079,7 +1075,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore)
if (pe->ok_to_evict()) if (pe->ok_to_evict())
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
for (int j = 0; j < pe->blocks_in_piece; ++j) for (int j = 0; j < pe->blocks_in_piece; ++j)
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe); TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe);
#endif #endif
@ -1119,7 +1115,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore)
if (pe->ok_to_evict()) if (pe->ok_to_evict())
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
for (int j = 0; j < pe->blocks_in_piece; ++j) for (int j = 0; j < pe->blocks_in_piece; ++j)
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe); TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe);
#endif #endif
@ -1152,7 +1148,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore)
if (pe->ok_to_evict()) if (pe->ok_to_evict())
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
for (int j = 0; j < pe->blocks_in_piece; ++j) for (int j = 0; j < pe->blocks_in_piece; ++j)
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe); TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe);
#endif #endif
@ -1198,7 +1194,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore)
if (pe->ok_to_evict()) if (pe->ok_to_evict())
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
for (int j = 0; j < pe->blocks_in_piece; ++j) for (int j = 0; j < pe->blocks_in_piece; ++j)
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe); TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe);
#endif #endif

View File

@ -1484,7 +1484,7 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
// the caller must increment the torrent refcount before // the caller must increment the torrent refcount before
// issuing an async disk request // issuing an async disk request
storage->assert_torrent_refcount(); storage->assert_torrent_refcount();
@ -1604,7 +1604,7 @@ namespace libtorrent
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
// the caller must increment the torrent refcount before // the caller must increment the torrent refcount before
// issuing an async disk request // issuing an async disk request
storage->assert_torrent_refcount(); storage->assert_torrent_refcount();
@ -1711,7 +1711,7 @@ namespace libtorrent
void disk_io_thread::async_hash(piece_manager* storage, int piece, int flags void disk_io_thread::async_hash(piece_manager* storage, int piece, int flags
, boost::function<void(disk_io_job const*)> handler, void* requester) , boost::function<void(disk_io_job const*)> handler, void* requester)
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
// the caller must increment the torrent refcount before // the caller must increment the torrent refcount before
// issuing an async disk request // issuing an async disk request
storage->assert_torrent_refcount(); storage->assert_torrent_refcount();
@ -1756,7 +1756,7 @@ namespace libtorrent
void disk_io_thread::async_move_storage(piece_manager* storage, std::string const& p, int flags void disk_io_thread::async_move_storage(piece_manager* storage, std::string const& p, int flags
, boost::function<void(disk_io_job const*)> handler) , boost::function<void(disk_io_job const*)> handler)
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
// the caller must increment the torrent refcount before // the caller must increment the torrent refcount before
// issuing an async disk request // issuing an async disk request
storage->assert_torrent_refcount(); storage->assert_torrent_refcount();
@ -1785,7 +1785,7 @@ namespace libtorrent
, int const options , int const options
, boost::function<void(disk_io_job const*)> handler) , boost::function<void(disk_io_job const*)> handler)
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
// the caller must increment the torrent refcount before // the caller must increment the torrent refcount before
// issuing an async disk request // issuing an async disk request
storage->assert_torrent_refcount(); storage->assert_torrent_refcount();
@ -1838,7 +1838,7 @@ namespace libtorrent
, std::vector<std::string>& links , std::vector<std::string>& links
, boost::function<void(disk_io_job const*)> handler) , boost::function<void(disk_io_job const*)> handler)
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
// the caller must increment the torrent refcount before // the caller must increment the torrent refcount before
// issuing an async disk request // issuing an async disk request
storage->assert_torrent_refcount(); storage->assert_torrent_refcount();
@ -1860,7 +1860,7 @@ namespace libtorrent
void disk_io_thread::async_rename_file(piece_manager* storage, int index, std::string const& name void disk_io_thread::async_rename_file(piece_manager* storage, int index, std::string const& name
, boost::function<void(disk_io_job const*)> handler) , boost::function<void(disk_io_job const*)> handler)
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
// the caller must increment the torrent refcount before // the caller must increment the torrent refcount before
// issuing an async disk request // issuing an async disk request
storage->assert_torrent_refcount(); storage->assert_torrent_refcount();
@ -1913,7 +1913,7 @@ namespace libtorrent
void disk_io_thread::async_cache_piece(piece_manager* storage, int piece void disk_io_thread::async_cache_piece(piece_manager* storage, int piece
, boost::function<void(disk_io_job const*)> handler) , boost::function<void(disk_io_job const*)> handler)
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
// the caller must increment the torrent refcount before // the caller must increment the torrent refcount before
// issuing an async disk request // issuing an async disk request
storage->assert_torrent_refcount(); storage->assert_torrent_refcount();
@ -1930,7 +1930,7 @@ namespace libtorrent
void disk_io_thread::async_finalize_file(piece_manager* storage, int file void disk_io_thread::async_finalize_file(piece_manager* storage, int file
, boost::function<void(disk_io_job const*)> handler) , boost::function<void(disk_io_job const*)> handler)
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
// the caller must increment the torrent refcount before // the caller must increment the torrent refcount before
// issuing an async disk request // issuing an async disk request
storage->assert_torrent_refcount(); storage->assert_torrent_refcount();
@ -1948,7 +1948,7 @@ namespace libtorrent
void disk_io_thread::async_flush_piece(piece_manager* storage, int piece void disk_io_thread::async_flush_piece(piece_manager* storage, int piece
, boost::function<void(disk_io_job const*)> handler) , boost::function<void(disk_io_job const*)> handler)
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
// the caller must increment the torrent refcount before // the caller must increment the torrent refcount before
// issuing an async disk request // issuing an async disk request
storage->assert_torrent_refcount(); storage->assert_torrent_refcount();
@ -1974,7 +1974,7 @@ namespace libtorrent
, std::vector<std::uint8_t> const& prios , std::vector<std::uint8_t> const& prios
, boost::function<void(disk_io_job const*)> handler) , boost::function<void(disk_io_job const*)> handler)
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
// the caller must increment the torrent refcount before // the caller must increment the torrent refcount before
// issuing an async disk request // issuing an async disk request
storage->assert_torrent_refcount(); storage->assert_torrent_refcount();
@ -2030,7 +2030,7 @@ namespace libtorrent
void disk_io_thread::async_clear_piece(piece_manager* storage, int index void disk_io_thread::async_clear_piece(piece_manager* storage, int index
, boost::function<void(disk_io_job const*)> handler) , boost::function<void(disk_io_job const*)> handler)
{ {
#ifdef TORRENT_DEBUG #ifndef TORRENT_DISABLE_INVARIANT_CHECKS
// the caller must increment the torrent refcount before // the caller must increment the torrent refcount before
// issuing an async disk request // issuing an async disk request
storage->assert_torrent_refcount(); storage->assert_torrent_refcount();

View File

@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <functional> #include <functional>
#include <cstdint> #include <cstdint>
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
#include <set> #include <set>
#endif #endif
@ -226,7 +226,7 @@ namespace libtorrent
, static_cast<void*>(m_peer_info) , static_cast<void*>(m_peer_info)
, print_endpoint(local_ep).c_str()); , print_endpoint(local_ep).c_str());
#endif #endif
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
piece_failed = false; piece_failed = false;
#endif #endif
std::fill(m_peer_id.begin(), m_peer_id.end(), 0); std::fill(m_peer_id.begin(), m_peer_id.end(), 0);
@ -5444,7 +5444,7 @@ namespace libtorrent
, channels + c, max_channels - c); , channels + c, max_channels - c);
} }
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
// make sure we don't have duplicates // make sure we don't have duplicates
std::set<bandwidth_channel*> unique_classes; std::set<bandwidth_channel*> unique_classes;
for (int i = 0; i < c; ++i) for (int i = 0; i < c; ++i)

View File

@ -1488,7 +1488,7 @@ namespace libtorrent
piece_manager::~piece_manager() piece_manager::~piece_manager()
{} {}
#ifdef TORRENT_DEBUG #if TORRENT_USE_ASSERTS
void piece_manager::assert_torrent_refcount() const void piece_manager::assert_torrent_refcount() const
{ {
if (!m_torrent) return; if (!m_torrent) return;