merge from upstream

This commit is contained in:
Malcolm Noyes
2014-01-09 07:15:11 +00:00
11 changed files with 124 additions and 30 deletions

View File

@@ -30,7 +30,6 @@
// running under the debugger or has a debugger attached post facto).
INTERNAL_CATCH_INLINE bool isDebuggerActive(){
int junk;
int mib[4];
struct kinfo_proc info;
size_t size;
@@ -51,8 +50,10 @@
// Call sysctl.
size = sizeof(info);
junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
assert(junk == 0);
if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0) != 0 ) {
std::cerr << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl;
return false;
}
// We're being debugged if the P_TRACED flag is set.

View File

@@ -79,6 +79,24 @@ namespace Detail {
}
};
// For display purposes only.
// Does not consider endian-ness
template<typename T>
std::string rawMemoryToString( T value ) {
union {
T typedValue;
unsigned char bytes[sizeof(T)];
};
typedValue = value;
std::ostringstream oss;
oss << "0x";
for( unsigned char* cp = bytes; cp < bytes+sizeof(T); ++cp )
oss << std::hex << std::setw(2) << std::setfill('0') << (unsigned int)*cp;
return oss.str();
}
} // end namespace Detail
template<typename T>
@@ -94,13 +112,18 @@ struct StringMaker<T*> {
static std::string convert( U* p ) {
if( !p )
return INTERNAL_CATCH_STRINGIFY( NULL );
std::ostringstream oss;
#ifdef _MSC_VER
oss << "0x" << p;
#else
oss << p;
#endif
return oss.str();
else
return Detail::rawMemoryToString( p );
}
};
template<typename R, typename C>
struct StringMaker<R C::*> {
static std::string convert( R C::* p ) {
if( !p )
return INTERNAL_CATCH_STRINGIFY( NULL );
else
return Detail::rawMemoryToString( p );
}
};

View File

@@ -14,7 +14,7 @@ namespace Catch {
// These numbers are maintained by a script
template <typename T>
const T LibraryVersionInfo<T>::value( 1, 0, 23, "master" );
const T LibraryVersionInfo<T>::value( 1, 0, 25, "master" );
}
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED