forked from premiere/premiere-libtorrent
fix debug buffer build. add new Jamfile feature for it. attempt to make it build on windows
This commit is contained in:
parent
f99be2455a
commit
f382876832
|
@ -15,6 +15,6 @@ time_limit: 180
|
||||||
|
|
||||||
features:
|
features:
|
||||||
- variant=release asserts=production invariant-checks=off debug-iterators=off debug-symbols=on
|
- variant=release asserts=production invariant-checks=off debug-iterators=off debug-symbols=on
|
||||||
- encryption=openssl statistics=on logging=verbose disk-stats=on dht=logging request-log=on
|
- encryption=openssl statistics=on logging=verbose disk-stats=on dht=logging request-log=on allocator=debug
|
||||||
- ipv6=off dht=off extensions=off logging=none deprecated-functions=off
|
- ipv6=off dht=off extensions=off logging=none deprecated-functions=off
|
||||||
|
|
||||||
|
|
5
Jamfile
5
Jamfile
|
@ -349,9 +349,14 @@ feature.compose <extensions>off : <define>TORRENT_DISABLE_EXTENSION ;
|
||||||
feature asio-debugging : off on : composite propagated link-incompatible ;
|
feature asio-debugging : off on : composite propagated link-incompatible ;
|
||||||
feature.compose <asio-debugging>on : <define>TORRENT_ASIO_DEBUGGING ;
|
feature.compose <asio-debugging>on : <define>TORRENT_ASIO_DEBUGGING ;
|
||||||
|
|
||||||
|
# deprecated use allocator=pool instead
|
||||||
feature pool-allocators : on off : composite propagated link-incompatible ;
|
feature pool-allocators : on off : composite propagated link-incompatible ;
|
||||||
feature.compose <pool-allocators>off : <define>TORRENT_DISABLE_POOL_ALLOCATOR ;
|
feature.compose <pool-allocators>off : <define>TORRENT_DISABLE_POOL_ALLOCATOR ;
|
||||||
|
|
||||||
|
feature allocator : pool system debug : composite ;
|
||||||
|
feature.compose <allocator>system : <define>TORRENT_DISABLE_POOL_ALLOCATOR ;
|
||||||
|
feature.compose <allocator>debug : <define>TORRENT_DISABLE_POOL_ALLOCATOR <define>TORRENT_DEBUG_BUFFERS ;
|
||||||
|
|
||||||
feature piece-allocator : valloc memalign posix_memalign : composite propagated ;
|
feature piece-allocator : valloc memalign posix_memalign : composite propagated ;
|
||||||
feature.compose <piece-allocator>memalign : <define>TORRENT_USE_MEMALIGN=1 ;
|
feature.compose <piece-allocator>memalign : <define>TORRENT_USE_MEMALIGN=1 ;
|
||||||
feature.compose <piece-allocator>posix_memalign : <define>TORRENT_USE_POSIX_MEMALIGN=1 ;
|
feature.compose <piece-allocator>posix_memalign : <define>TORRENT_USE_POSIX_MEMALIGN=1 ;
|
||||||
|
|
|
@ -298,11 +298,13 @@ Build features:
|
||||||
| | connections. The shipped public domain SHA-1 |
|
| | connections. The shipped public domain SHA-1 |
|
||||||
| | implementation is used. |
|
| | implementation is used. |
|
||||||
+--------------------------+----------------------------------------------------+
|
+--------------------------+----------------------------------------------------+
|
||||||
| ``pool-allocators`` | * ``on`` - default, uses pool allocators for send |
|
| ``allocator`` | * ``pool`` - default, uses pool allocators for |
|
||||||
| | buffers. |
|
| | send buffers. |
|
||||||
| | * ``off`` - uses ``malloc()`` and ``free()`` |
|
| | * ``system`` - uses ``malloc()`` and ``free()`` |
|
||||||
| | instead. Might be useful to debug buffer issues |
|
| | instead. Might be useful to debug buffer issues |
|
||||||
| | with tools like electric fence or libgmalloc. |
|
| | with tools like electric fence or libgmalloc. |
|
||||||
|
| | * ``debug`` - instruments buffer usage to catch |
|
||||||
|
| | bugs in libtorrent. |
|
||||||
+--------------------------+----------------------------------------------------+
|
+--------------------------+----------------------------------------------------+
|
||||||
| ``link`` | * ``static`` - builds libtorrent as a static |
|
| ``link`` | * ``static`` - builds libtorrent as a static |
|
||||||
| | library (.a / .lib) |
|
| | library (.a / .lib) |
|
||||||
|
|
|
@ -58,7 +58,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TORRENT_DEBUG_BUFFERS
|
#ifdef TORRENT_DEBUG_BUFFERS
|
||||||
|
#ifndef TORRENT_WINDOWS
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
#include "libtorrent/size_type.hpp"
|
#include "libtorrent/size_type.hpp"
|
||||||
|
|
||||||
struct alloc_header
|
struct alloc_header
|
||||||
|
@ -71,7 +73,7 @@ struct alloc_header
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_DEBUG_BUFFERS && (defined __linux__ || (defined __APPLE__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050))
|
#if defined TORRENT_DEBUG_BUFFERS && (defined __linux__ || (defined __APPLE__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050))
|
||||||
void print_backtrace(char* out, int len);
|
void print_backtrace(char* out, int len, int max_depth = 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
|
@ -110,9 +112,19 @@ namespace libtorrent
|
||||||
h->magic = 0x1337;
|
h->magic = 0x1337;
|
||||||
#if defined __linux__ || (defined __APPLE__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)
|
#if defined __linux__ || (defined __APPLE__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)
|
||||||
print_backtrace(h->stack, sizeof(h->stack));
|
print_backtrace(h->stack, sizeof(h->stack));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TORRENT_WINDOWS
|
||||||
|
#define mprotect(buf, size, prot) VirtualProtect(buf, size, prot, NULK)
|
||||||
|
#define PROT_READ PAGE_READONLY
|
||||||
#endif
|
#endif
|
||||||
mprotect(ret, page, PROT_READ);
|
mprotect(ret, page, PROT_READ);
|
||||||
mprotect(ret + (num_pages-1) * page, page, PROT_READ);
|
mprotect(ret + (num_pages-1) * page, page, PROT_READ);
|
||||||
|
|
||||||
|
#ifdef TORRENT_WINDOWS
|
||||||
|
#undef mprotect
|
||||||
|
#undef PROT_READ
|
||||||
|
#endif
|
||||||
// fprintf(stderr, "malloc: %p head: %p tail: %p size: %d\n", ret + page, ret, ret + page + bytes, int(bytes));
|
// fprintf(stderr, "malloc: %p head: %p tail: %p size: %d\n", ret + page, ret, ret + page + bytes, int(bytes));
|
||||||
|
|
||||||
return ret + page;
|
return ret + page;
|
||||||
|
@ -141,6 +153,12 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef TORRENT_DEBUG_BUFFERS
|
#ifdef TORRENT_DEBUG_BUFFERS
|
||||||
|
|
||||||
|
#ifdef TORRENT_WINDOWS
|
||||||
|
#define mprotect(buf, size, prot) VirtualProtect(buf, size, prot, NULK)
|
||||||
|
#define PROT_READ PAGE_READONLY
|
||||||
|
#define PROT_WRITE PAGE_READWRITE
|
||||||
|
#endif
|
||||||
int page = page_size();
|
int page = page_size();
|
||||||
// make the two surrounding pages non-readable and -writable
|
// make the two surrounding pages non-readable and -writable
|
||||||
mprotect(block - page, page, PROT_READ | PROT_WRITE);
|
mprotect(block - page, page, PROT_READ | PROT_WRITE);
|
||||||
|
@ -151,6 +169,12 @@ namespace libtorrent
|
||||||
// fprintf(stderr, "free: %p head: %p tail: %p size: %d\n", block, block - page, block + h->size, int(h->size));
|
// fprintf(stderr, "free: %p head: %p tail: %p size: %d\n", block, block - page, block + h->size, int(h->size));
|
||||||
h->magic = 0;
|
h->magic = 0;
|
||||||
|
|
||||||
|
#ifdef TORRENT_WINDOWS
|
||||||
|
#undef mprotect
|
||||||
|
#undef PROT_READ
|
||||||
|
#undef PROT_WRITE
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined __linux__ || (defined __APPLE__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)
|
#if defined __linux__ || (defined __APPLE__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)
|
||||||
print_backtrace(h->stack, sizeof(h->stack));
|
print_backtrace(h->stack, sizeof(h->stack));
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue