build with gcc/mingw on appveyor (#722)

enable gcc/mingw builds on appveyor. Some mingw tests crash currently, they need debugging and are currently disabled.
This commit is contained in:
Arvid Norberg 2016-05-15 13:28:22 -04:00
parent 1e7e01c671
commit 44a668db62
14 changed files with 247 additions and 143 deletions

11
Jamfile
View File

@ -83,9 +83,7 @@ rule linking ( properties * )
result += <library>/libsimulator//simulator ;
}
# dbghelp doesn't appear to exist in mingw
if <target-os>windows in $(properties)
&& ! <toolset>gcc in $(properties)
&& ( <variant>debug in $(properties)
|| <asserts>on in $(properties)
|| <asserts>production in $(properties)
@ -298,6 +296,13 @@ rule building ( properties * )
result += <cflags>/bigobj ;
}
if <toolset>gcc in $(properties)
&& <target-os>windows in $(properties)
{
# allow larger .obj files in GCC
result += <cflags>-Wa,-mbig-obj ;
}
if ( <variant>debug in $(properties)
&& ( <toolset>clang in $(properties)
|| <toolset>gcc in $(properties)
@ -455,7 +460,7 @@ feature mutable-torrents : on off : composite propagated link-incompatible ;
feature.compose <mutable-torrents>off : <define>TORRENT_DISABLE_MUTABLE_TORRENTS ;
feature crypto : built-in openssl gcrypt : composite propagated ;
feature.compose <crypto>openssl : <define>TORRENT_USE_OPENSSL ;
feature.compose <crypto>openssl : <define>TORRENT_USE_OPENSSL <define>OPENSSL_NO_SSL2 ;
feature.compose <crypto>gcrypt : <define>TORRENT_USE_GCRYPT ;
feature character-set : unicode ansi : composite propagated link-incompatible ;

View File

@ -24,13 +24,11 @@ environment:
model: 64
linkflags: '"/LIBPATH:C:\\openssl-1.0.1p-vs2015\\lib"'
include: '"c:\\openssl-1.0.1p-vs2015\\include"'
# mingw and boost.random don't like each other. Comment this back in once there
# is support
# - variant: test_debug
# compiler: gcc
# linkflags: '"-LC:\\OpenSSL-Win32\\lib"'
- variant: test_debug
compiler: gcc
model: 64
include: '"c:\\OpenSSL-Win64\\include"'
linkflags: '"-LC:\\OpenSSL-Win64\\lib"'
install:
- if defined sim ( git submodule update --init --recursive )
@ -56,11 +54,10 @@ install:
- echo %BOOST_ROOT%
- echo %BOOST_BUILD_PATH%
- set PATH=%PATH%;%BOOST_BUILD_PATH%\src\engine\bin.ntx86
- 'echo using msvc : 12.0 ; >%HOMEDRIVE%%HOMEPATH%/user-config.jam'
- 'echo using msvc : 14.0 ; >>%HOMEDRIVE%%HOMEPATH%/user-config.jam'
- ps: '"using msvc : 14.0 ;`nusing gcc : : : <cxxflags>-std=c++11 ;`n" | Set-Content $env:HOMEDRIVE\$env:HOMEPATH\user-config.jam'
- type %HOMEDRIVE%%HOMEPATH%\user-config.jam
- cd %ROOT_DIRECTORY%
- set PATH=%PATH%;c:\Mingw\bin
- set PATH=c:\msys64\mingw64\bin;%PATH%
- g++ --version
- python --version
- echo %ROOT_DIRECTORY%
@ -94,7 +91,8 @@ build_script:
test_script:
- cd %ROOT_DIRECTORY%\test
- b2.exe --hash -j2 address-model=%model% win-tests %compiler% variant=%variant% link=shared linkflags=%linkflags% include=%include%
# mingw tests crash currently. needs resolving
- if not %compiler% == gcc ( b2.exe --hash -j2 address-model=%model% win-tests %compiler% variant=%variant% link=shared linkflags=%linkflags% include=%include% )
- cd %ROOT_DIRECTORY%\bindings\python
# 64 bit python module builds don't work
- if %model% == 32 ( python test.py )

View File

@ -41,13 +41,14 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/file_pool.hpp"
#include "libtorrent/hex.hpp" // for from_hex
#include <boost/bind.hpp>
#include <functional>
#ifdef TORRENT_WINDOWS
#include <direct.h> // for _getcwd
#endif
using namespace libtorrent;
using namespace std::placeholders;
int load_file(std::string const& filename, std::vector<char>& v, libtorrent::error_code& ec, int limit = 8000000)
{
@ -369,7 +370,7 @@ int main(int argc, char* argv[])
error_code ec;
set_piece_hashes(t, branch_path(full_path)
, boost::bind(&print_progress, _1, t.num_pieces()), ec);
, std::bind(&print_progress, _1, t.num_pieces()), ec);
if (ec)
{
fprintf(stderr, "%s\n", ec.message().c_str());

View File

@ -159,8 +159,11 @@ std::string const& piece_bar(libtorrent::bitfield const& p, int width)
double piece = 0;
// we print two blocks at a time, so calculate the color in pair
#ifndef _WIN32
int color[2];
int last_color[2] = { -1, -1};
#endif
for (int i = 0; i < width; ++i, piece += piece_per_char)
{
int num_pieces = 0;
@ -169,9 +172,10 @@ std::string const& piece_bar(libtorrent::bitfield const& p, int width)
for (int k = int(piece); k < end; ++k, ++num_pieces)
if (p[k]) ++num_have;
int const c = int(std::ceil(num_have / float((std::max)(num_pieces, 1)) * (table_size - 1)));
color[i & 1] = c;
#ifndef _WIN32
color[i & 1] = c;
if ((i & 1) == 1)
{
// now, print color[0] and [1]

View File

@ -31,12 +31,22 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include <boost/make_shared.hpp>
#include "libtorrent/entry.hpp"
#include "libtorrent/bencode.hpp"
#include "libtorrent/session.hpp"
#include "libtorrent/torrent_info.hpp"
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
#endif
#include <boost/make_shared.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
int main(int argc, char* argv[])
{
using namespace libtorrent;

View File

@ -42,7 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <string>
std::string demangle(char const* name);
TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth = 0);
TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth = 0, void* ctx = nullptr);
#endif
// this is to disable the warning of conditional expressions

View File

@ -37,21 +37,16 @@ POSSIBILITY OF SUCH DAMAGE.
#define _FILE_OFFSET_BITS 64
#if !defined _MSC_VER || _MSC_VER >= 1600
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
#endif
#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS 1
#endif
#endif
#include <boost/config.hpp>
#include <boost/asio/detail/config.hpp>
#include <boost/version.hpp>
#include <boost/detail/endian.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <stdio.h> // for snprintf
#include <limits.h> // for IOV_MAX
#include <cinttypes> // for PRId64 et.al.
#include "libtorrent/export.hpp"
@ -67,29 +62,12 @@ POSSIBILITY OF SUCH DAMAGE.
#define BOOST_ASIO_SEPARATE_COMPILATION
#endif
#ifndef _MSC_VER
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS 1
#if defined __MINGW64__ || defined __MINGW32__
// GCC warns on format codes that are incompatible with glibc, which the windows
// format codes are. So we need to disable those for mingw targets
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wformat-extra-args"
#endif
#include <inttypes.h> // for PRId64 et.al.
#endif
#ifndef PRId64
// MinGW uses microsofts runtime
#if defined _MSC_VER || defined __MINGW32__
#define PRId64 "I64d"
#define PRIu64 "I64u"
#define PRIx64 "I64x"
#define PRIu32 "u"
#else
#define PRId64 "lld"
#define PRIu64 "llu"
#define PRIx64 "llx"
#define PRIu32 "u"
#endif
#endif
#include "libtorrent/aux_/disable_warnings_pop.hpp"
// ======= GCC =========
@ -255,7 +233,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
// ==== MINGW ===
#elif defined __MINGW32__
#elif defined __MINGW32__ || defined __MINGW64__
#define TORRENT_MINGW
#define TORRENT_WINDOWS
#ifndef TORRENT_USE_ICONV

View File

@ -53,6 +53,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cstring>
#include <stdlib.h>
#include <stdarg.h>
#include <array>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
@ -124,7 +125,7 @@ std::string demangle(char const* name) { return name; }
#if TORRENT_USE_EXECINFO
#include <execinfo.h>
TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth)
TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth, void*)
{
void* stack[50];
int size = backtrace(stack, 50);
@ -141,8 +142,7 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth)
free(symbols);
}
// visual studio 9 and up appears to support this
#elif defined WIN32 && _MSC_VER >= 1500
#elif defined WIN32
#include "windows.h"
#include "libtorrent/utf8.hpp"
@ -150,35 +150,56 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth)
#include "winbase.h"
#include "dbghelp.h"
TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth)
TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth
, void* ctx)
{
typedef USHORT (WINAPI *RtlCaptureStackBackTrace_t)(
__in ULONG FramesToSkip,
__in ULONG FramesToCapture,
__out PVOID *BackTrace,
__out_opt PULONG BackTraceHash);
static RtlCaptureStackBackTrace_t RtlCaptureStackBackTrace = 0;
if (RtlCaptureStackBackTrace == 0)
CONTEXT context_record;
if (ctx)
{
// we don't actually have to free this library, everyone has it loaded
HMODULE lib = LoadLibrary(TEXT("kernel32.dll"));
RtlCaptureStackBackTrace = (RtlCaptureStackBackTrace_t)GetProcAddress(lib, "RtlCaptureStackBackTrace");
if (RtlCaptureStackBackTrace == 0)
{
out[0] = 0;
return;
}
context_record = *static_cast<CONTEXT*>(ctx);
}
else
{
// use the current thread's context
RtlCaptureContext(&context_record);
}
int i;
void* stack[50];
int size = CaptureStackBackTrace(0, 50, stack, 0);
int size = 0;
std::array<void*, 50> stack;
SYMBOL_INFO* symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR), 1);
symbol->MaxNameLen = MAX_SYM_NAME;
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
STACKFRAME64 stack_frame;
memset(&stack_frame, 0, sizeof(stack_frame));
#if defined(_WIN64)
int const machine_type = IMAGE_FILE_MACHINE_AMD64;
stack_frame.AddrPC.Offset = context_record.Rip;
stack_frame.AddrFrame.Offset = context_record.Rbp;
stack_frame.AddrStack.Offset = context_record.Rsp;
#else
int const machine_type = IMAGE_FILE_MACHINE_I386;
stack_frame.AddrPC.Offset = context_record.Eip;
stack_frame.AddrFrame.Offset = context_record.Ebp;
stack_frame.AddrStack.Offset = context_record.Esp;
#endif
stack_frame.AddrPC.Mode = AddrModeFlat;
stack_frame.AddrFrame.Mode = AddrModeFlat;
stack_frame.AddrStack.Mode = AddrModeFlat;
while (StackWalk64(machine_type,
GetCurrentProcess(),
GetCurrentThread(),
&stack_frame,
&context_record,
nullptr,
&SymFunctionTableAccess64,
&SymGetModuleBase64,
nullptr) && size < stack.size())
{
stack[size++] = reinterpret_cast<void*>(stack_frame.AddrPC.Offset);
}
struct symbol_bundle : SYMBOL_INFO
{
wchar_t name[MAX_SYM_NAME];
};
HANDLE p = GetCurrentProcess();
static bool sym_initialized = false;
@ -187,24 +208,52 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth)
sym_initialized = true;
SymInitialize(p, NULL, true);
}
for (i = 0; i < size && len > 0; ++i)
SymRefreshModuleList(p);
for (int i = 0; i < size && len > 0; ++i)
{
int ret;
if (SymFromAddr(p, uintptr_t(stack[i]), 0, symbol))
ret = snprintf(out, len, "%d: %s\n", i, symbol->Name);
else
ret = snprintf(out, len, "%d: <unknown>\n", i);
DWORD_PTR frame_ptr = reinterpret_cast<DWORD_PTR>(stack[i]);
DWORD64 displacement = 0;
symbol_bundle symbol;
symbol.MaxNameLen = MAX_SYM_NAME;
symbol.SizeOfStruct = sizeof(SYMBOL_INFO);
BOOL const has_symbol = SymFromAddr(p, frame_ptr, &displacement, &symbol);
DWORD line_displacement = 0;
IMAGEHLP_LINE64 line = {};
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
BOOL const has_line = SymGetLineFromAddr64(GetCurrentProcess(), frame_ptr,
&line_displacement, &line);
int ret = snprintf(out, len, "%2d: %p", i, stack[i]);
out += ret; len -= ret; if (len <= 0) break;
if (has_symbol)
{
ret = snprintf(out, len, " %s +%-4" PRId64 " "
, i, stack[i], demangle(symbol.Name), displacement);
out += ret; len -= ret; if (len <= 0) break;
}
if (has_line)
{
ret = snprintf(out, len, " %s:%d"
, line.FileName, line.LineNumber);
out += ret; len -= ret; if (len <= 0) break;
}
ret = snprintf(out, len, "\n");
out += ret;
len -= ret;
if (i == max_depth && max_depth > 0) break;
}
free(symbol);
}
#else
TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth)
TORRENT_EXPORT void print_backtrace(char* out, int len, int /*max_depth*/, void* /* ctx */)
{
out[0] = 0;
strncat(out, "<not supported>", len);

View File

@ -63,24 +63,12 @@ POSSIBILITY OF SUCH DAMAGE.
#define DEBUG_DISK_THREAD 0
#if __cplusplus >= 201103L || defined __clang__
#if DEBUG_DISK_THREAD
#define DLOG(...) debug_log(__VA_ARGS__)
#else
#define DLOG(...) do {} while(false)
#endif
#else
#if DEBUG_DISK_THREAD
#define DLOG debug_log
#else
#define DLOG TORRENT_WHILE_0 debug_log
#endif
#endif // cplusplus
namespace libtorrent
{
@ -97,12 +85,10 @@ namespace libtorrent
#define TORRENT_PIECE_ASSERT_FAIL(piece) do {} TORRENT_WHILE_0
#endif // TORRENT_USE_ASSERTS
namespace {
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
#endif
#if DEBUG_DISK_THREAD
void debug_log(char const* fmt, ...)
{
@ -135,6 +121,9 @@ namespace libtorrent
#endif
}
#endif // DEBUG_DISK_THREAD
int file_flags_for_job(disk_io_job* j
, bool const coalesce_buffers)
{
@ -144,10 +133,6 @@ namespace libtorrent
return ret;
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
} // anonymous namespace
// ------- disk_io_thread ------

View File

@ -64,6 +64,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/alloca.hpp"
#include "libtorrent/allocator.hpp" // page_size
#include "libtorrent/file.hpp"
#include "libtorrent/error_code.hpp"
#include <cstring>
#include <vector>
@ -1591,11 +1592,11 @@ namespace libtorrent
overlapped_t ol;
if (ol.ol.hEvent == NULL) return false;
#ifdef TORRENT_MINGW
#ifndef FSCTL_QUERY_ALLOCATED_RANGES
typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
LARGE_INTEGER FileOffset;
LARGE_INTEGER Length;
} FILE_ALLOCATED_RANGE_BUFFER, *PFILE_ALLOCATED_RANGE_BUFFER;
} FILE_ALLOCATED_RANGE_BUFFER;
#define FSCTL_QUERY_ALLOCATED_RANGES ((0x9 << 16) | (1 << 14) | (51 << 2) | 3)
#endif
FILE_ALLOCATED_RANGE_BUFFER in;
@ -1653,7 +1654,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
#ifdef TORRENT_MINGW
typedef struct _FILE_SET_SPARSE_BUFFER {
BOOLEAN SetSparse;
} FILE_SET_SPARSE_BUFFER, *PFILE_SET_SPARSE_BUFFER;
} FILE_SET_SPARSE_BUFFER;
#endif
DWORD temp;
FILE_SET_SPARSE_BUFFER b;
@ -1680,6 +1681,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
namespace {
#if !TORRENT_USE_PREADV
void gather_copy(file::iovec_t const* bufs, int num_bufs, char* dst)
{
std::size_t offset = 0;
@ -1700,7 +1702,6 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
}
}
#if !TORRENT_USE_PREADV
bool coalesce_read_buffers(file::iovec_t const*& bufs, int& num_bufs
, file::iovec_t* tmp)
{
@ -1834,7 +1835,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
return ret;
#endif
#endif // USE_PREADV
}
} // anonymous namespace
@ -2247,11 +2248,11 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
{
#ifdef TORRENT_WINDOWS
#ifdef TORRENT_MINGW
#ifndef FSCTL_QUERY_ALLOCATED_RANGES
typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
LARGE_INTEGER FileOffset;
LARGE_INTEGER Length;
} FILE_ALLOCATED_RANGE_BUFFER, *PFILE_ALLOCATED_RANGE_BUFFER;
} FILE_ALLOCATED_RANGE_BUFFER;
#define FSCTL_QUERY_ALLOCATED_RANGES ((0x9 << 16) | (1 << 14) | (51 << 2) | 3)
#endif // TORRENT_MINGW

View File

@ -4,6 +4,13 @@
// disable warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
#pragma warning(disable: 4334)
#endif
#if defined __GNUC__ && __GNUC__ >= 5
// tommath triggers this warning alot
#pragma GCC diagnostic ignored "-Wshift-count-overflow"
#pragma GCC diagnostic ignored "-Woverflow"
#endif
#ifdef BN_ERROR_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*

View File

@ -102,7 +102,11 @@ namespace libtorrent
return;
// key is now our local key
int size = mp_unsigned_bin_size(&key);
int const size = mp_unsigned_bin_size(&key);
TORRENT_ASSERT(size >= 0);
TORRENT_ASSERT(size <= sizeof(m_dh_local_key));
if (size < 0 || size > sizeof(m_dh_local_key))
return;
memset(m_dh_local_key, 0, sizeof(m_dh_local_key) - size);
mp_to_unsigned_bin(&key
, reinterpret_cast<unsigned char*>(m_dh_local_key)

View File

@ -42,12 +42,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include "dht_server.hpp" // for stop_dht
#include "peer_server.hpp" // for stop_peer
#include "udp_tracker.hpp" // for stop_udp_tracker
#include <boost/system/system_error.hpp>
#include "libtorrent/assert.hpp"
#include "libtorrent/file.hpp"
#include <signal.h>
#ifdef WIN32
#ifdef _WIN32
#include <windows.h> // fot SetErrorMode
#include <io.h> // for _dup and _dup2
#include <process.h> // for _getpid
@ -67,7 +68,7 @@ using namespace libtorrent;
// out, such as the log
int old_stdout = -1;
int old_stderr = -1;
bool redirect_output = true;
bool redirect_output = false;
bool keep_files = false;
extern int _g_test_idx;
@ -96,6 +97,64 @@ void output_test_log_to_terminal()
} while (size > 0);
}
#ifdef _WIN32
LONG WINAPI seh_exception_handler(LPEXCEPTION_POINTERS p)
{
char stack_text[10000];
#if (defined TORRENT_DEBUG && TORRENT_USE_ASSERTS) \
|| defined TORRENT_ASIO_DEBUGGING \
|| defined TORRENT_PROFILE_CALLS \
|| defined TORRENT_RELEASE_ASSERTS \
|| defined TORRENT_DEBUG_BUFFERS
print_backtrace(stack_text, sizeof(stack_text), 30
, p->ContextRecord);
#elif defined __FUNCTION__
strcat(stack_text, __FUNCTION__);
#else
stack_text[0] = 0;
strcat(stack_text, "<stack traces disabled>");
#endif
int const code = p->ExceptionRecord->ExceptionCode;
char const* name = "<unknown exception>";
switch (code)
{
#define EXC(x) case x: name = #x; break
EXC(EXCEPTION_ACCESS_VIOLATION);
EXC(EXCEPTION_ARRAY_BOUNDS_EXCEEDED);
EXC(EXCEPTION_BREAKPOINT);
EXC(EXCEPTION_DATATYPE_MISALIGNMENT);
EXC(EXCEPTION_FLT_DENORMAL_OPERAND);
EXC(EXCEPTION_FLT_DIVIDE_BY_ZERO);
EXC(EXCEPTION_FLT_INEXACT_RESULT);
EXC(EXCEPTION_FLT_INVALID_OPERATION);
EXC(EXCEPTION_FLT_OVERFLOW);
EXC(EXCEPTION_FLT_STACK_CHECK);
EXC(EXCEPTION_FLT_UNDERFLOW);
EXC(EXCEPTION_ILLEGAL_INSTRUCTION);
EXC(EXCEPTION_IN_PAGE_ERROR);
EXC(EXCEPTION_INT_DIVIDE_BY_ZERO);
EXC(EXCEPTION_INT_OVERFLOW);
EXC(EXCEPTION_INVALID_DISPOSITION);
EXC(EXCEPTION_NONCONTINUABLE_EXCEPTION);
EXC(EXCEPTION_PRIV_INSTRUCTION);
EXC(EXCEPTION_SINGLE_STEP);
EXC(EXCEPTION_STACK_OVERFLOW);
#undef EXC
};
fprintf(stderr, "exception: (0x%x) %s caught:\n%s\n"
, code, name, stack_text);
output_test_log_to_terminal();
exit(code);
return EXCEPTION_EXECUTE_HANDLER;
}
#else
void sig_handler(int sig)
{
char stack_text[10000];
@ -112,10 +171,10 @@ void sig_handler(int sig)
stack_text[0] = 0;
strcat(stack_text, "<stack traces disabled>");
#endif
char const* sig_name = 0;
char const* name = "<unknown signal>";
switch (sig)
{
#define SIG(x) case x: sig_name = #x; break
#define SIG(x) case x: name = #x; break
SIG(SIGSEGV);
#ifdef SIGBUS
SIG(SIGBUS);
@ -130,17 +189,16 @@ void sig_handler(int sig)
#endif
#undef SIG
};
fprintf(stderr, "signal: %s caught:\n%s\n", sig_name, stack_text);
fprintf(stderr, "signal: (%d) %s caught:\n%s\n"
, sig, name, stack_text);
output_test_log_to_terminal();
#ifdef WIN32
exit(sig);
#else
exit(128 + sig);
#endif
}
#endif // _WIN32
void print_usage(char const* executable)
{
printf("%s [options] [tests...]\n"
@ -158,17 +216,6 @@ void print_usage(char const* executable)
"by -l. If no test is specified, all tests are run\n", executable);
}
#ifdef WIN32
LONG WINAPI seh_exception_handler(LPEXCEPTION_POINTERS p)
{
int sig = p->ExceptionRecord->ExceptionCode;
fprintf(stderr, "SEH exception: %u\n"
, p->ExceptionRecord->ExceptionCode);
sig_handler(sig);
exit(sig);
}
#endif
EXPORT int main(int argc, char const* argv[])
{
char const* executable = argv[0];
@ -217,15 +264,6 @@ EXPORT int main(int argc, char const* argv[])
filter = true;
}
#ifdef WIN32
// try to suppress hanging the process by windows displaying
// modal dialogs.
SetErrorMode( SEM_NOALIGNMENTFAULTEXCEPT
| SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
SetUnhandledExceptionFilter(&seh_exception_handler);
#endif
#ifdef O_NONBLOCK
// on darwin, stdout is set to non-blocking mode by default
// which sometimes causes tests to fail with EAGAIN just
@ -236,6 +274,16 @@ EXPORT int main(int argc, char const* argv[])
fcntl(fileno(stderr), F_SETFL, flags & ~O_NONBLOCK);
#endif
#ifdef _WIN32
// try to suppress hanging the process by windows displaying
// modal dialogs.
SetErrorMode( SEM_NOALIGNMENTFAULTEXCEPT
| SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
SetUnhandledExceptionFilter(&seh_exception_handler);
#else
signal(SIGSEGV, &sig_handler);
#ifdef SIGBUS
signal(SIGBUS, &sig_handler);
@ -248,6 +296,8 @@ EXPORT int main(int argc, char const* argv[])
signal(SIGSYS, &sig_handler);
#endif
#endif // _WIN32
int process_id = -1;
#ifdef _WIN32
process_id = _getpid();
@ -337,6 +387,15 @@ EXPORT int main(int argc, char const* argv[])
(*t.fun)();
#ifndef BOOST_NO_EXCEPTIONS
}
catch (boost::system::system_error const& e)
{
char buf[200];
snprintf(buf, sizeof(buf), "Terminated with system_error: (%d) [%s] \"%s\""
, e.code().value()
, e.code().category().name()
, e.code().message().c_str());
report_failure(buf, __FILE__, __LINE__);
}
catch (std::exception const& e)
{
char buf[200];

View File

@ -30,7 +30,10 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/make_shared.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <deque>
#include "make_torrent.hpp"