mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Improve debugging
This commit is contained in:
parent
cdafb7e27f
commit
a0da5a3120
@ -55,6 +55,8 @@ RsFileTree::fromBase64(const std::string& base64)
|
|||||||
const auto failure = [](std::error_condition ec)
|
const auto failure = [](std::error_condition ec)
|
||||||
{ return std::make_tuple(nullptr, ec); };
|
{ return std::make_tuple(nullptr, ec); };
|
||||||
|
|
||||||
|
if(base64.empty()) return failure(std::errc::invalid_argument);
|
||||||
|
|
||||||
std::error_condition ec;
|
std::error_condition ec;
|
||||||
std::vector<uint8_t> mem;
|
std::vector<uint8_t> mem;
|
||||||
if( (ec = RsBase64::decode(base64, mem)) ) return failure(ec);
|
if( (ec = RsBase64::decode(base64, mem)) ) return failure(ec);
|
||||||
|
@ -1037,8 +1037,6 @@ protected:
|
|||||||
VLQ_deserialize(
|
VLQ_deserialize(
|
||||||
const uint8_t data[], uint32_t size, uint32_t& offset, T& member )
|
const uint8_t data[], uint32_t size, uint32_t& offset, T& member )
|
||||||
{
|
{
|
||||||
uint32_t backupOffset = offset;
|
|
||||||
|
|
||||||
member = 0;
|
member = 0;
|
||||||
uint32_t offsetBackup = offset;
|
uint32_t offsetBackup = offset;
|
||||||
|
|
||||||
@ -1048,14 +1046,14 @@ protected:
|
|||||||
for (size_t i = 0; offset < size && i <= sizeof(T); ++i)
|
for (size_t i = 0; offset < size && i <= sizeof(T); ++i)
|
||||||
{
|
{
|
||||||
member |= (data[offset] & 127) << (7 * i);
|
member |= (data[offset] & 127) << (7 * i);
|
||||||
// If the next-byte flag is not set, ++ is after on purpose
|
// If the next-byte flag is not set. ++ is after on purpose
|
||||||
if(!(data[offset++] & 128))
|
if(!(data[offset++] & 128))
|
||||||
{
|
{
|
||||||
RsDbg() << __PRETTY_FUNCTION__
|
Dbg2() << __PRETTY_FUNCTION__
|
||||||
<< " size: " << size
|
<< " size: " << size
|
||||||
<< " backupOffset " << backupOffset
|
<< " backupOffset " << offsetBackup
|
||||||
<< " offset: " << offset
|
<< " offset: " << offset
|
||||||
<< " member " << member << std::endl;
|
<< " member " << member << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1064,13 +1062,14 @@ protected:
|
|||||||
* ended before we encountered the end of the number, or the number
|
* ended before we encountered the end of the number, or the number
|
||||||
* is VLQ encoded improperly */
|
* is VLQ encoded improperly */
|
||||||
RsErr() << __PRETTY_FUNCTION__ << std::errc::illegal_byte_sequence
|
RsErr() << __PRETTY_FUNCTION__ << std::errc::illegal_byte_sequence
|
||||||
|
<< " size: " << size
|
||||||
<< " offsetBackup: " << offsetBackup
|
<< " offsetBackup: " << offsetBackup
|
||||||
<< " offset: " << offset << " bytes: ";
|
<< " offset: " << offset << " bytes: ";
|
||||||
for(; offsetBackup < offset; ++offsetBackup)
|
for(; offsetBackup < offset; ++offsetBackup)
|
||||||
std::cerr << " " << std::bitset<8>(data[offsetBackup]);
|
RsErr().uStream() << " " << std::bitset<8>(data[offsetBackup]);
|
||||||
std::cerr << std::endl;
|
RsErr().uStream() << std::endl;
|
||||||
|
|
||||||
print_stacktrace();
|
print_stacktrace();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,10 @@ struct t_RsLogger
|
|||||||
{
|
{
|
||||||
inline t_RsLogger() = default;
|
inline t_RsLogger() = default;
|
||||||
|
|
||||||
typedef t_RsLogger stream_type;
|
/** On other platforms expose the type of underlying stream.
|
||||||
|
* On Android it cannot work like that so return the class type itself
|
||||||
|
* just for code compatibility with other platforms */
|
||||||
|
using stream_type = t_RsLogger;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline stream_type& operator<<(const T& val)
|
inline stream_type& operator<<(const T& val)
|
||||||
@ -68,6 +71,11 @@ struct t_RsLogger
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** On other platforms return underlying stream to write avoiding additional
|
||||||
|
* prefixes. On Android it cannot work like that so return the object itself
|
||||||
|
* just for code compatibility with other platforms */
|
||||||
|
inline stream_type& uStream() { return *this; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
};
|
};
|
||||||
@ -92,7 +100,8 @@ struct t_RsLogger
|
|||||||
{
|
{
|
||||||
inline t_RsLogger() = default;
|
inline t_RsLogger() = default;
|
||||||
|
|
||||||
typedef decltype(std::cerr) stream_type;
|
/// Expose the type of underlying stream
|
||||||
|
using stream_type = decltype(std::cerr);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline stream_type& operator<<(const T& val)
|
inline stream_type& operator<<(const T& val)
|
||||||
@ -111,6 +120,9 @@ struct t_RsLogger
|
|||||||
/// needed for manipulators and things like std::endl
|
/// needed for manipulators and things like std::endl
|
||||||
stream_type& operator<<(std::ostream& (*pf)(std::ostream&))
|
stream_type& operator<<(std::ostream& (*pf)(std::ostream&))
|
||||||
{ return std::cerr << pf; }
|
{ return std::cerr << pf; }
|
||||||
|
|
||||||
|
/// Return underlying stream to write avoiding additional prefixes
|
||||||
|
inline stream_type& uStream() const { return std::cerr; }
|
||||||
};
|
};
|
||||||
#endif // def __ANDROID__
|
#endif // def __ANDROID__
|
||||||
|
|
||||||
@ -176,16 +188,22 @@ struct RsNoDbg
|
|||||||
{
|
{
|
||||||
inline RsNoDbg() = default;
|
inline RsNoDbg() = default;
|
||||||
|
|
||||||
/**
|
/** Defined as the type itself just for code compatibility with other
|
||||||
* This match most of the types, but might be not enough for templated
|
* logging classes */
|
||||||
* types
|
using stream_type = RsNoDbg;
|
||||||
*/
|
|
||||||
|
/** This match most of the types, but might be not enough for templated
|
||||||
|
* types */
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline RsNoDbg& operator<<(const T&) { return *this; }
|
inline stream_type& operator<<(const T&) { return *this; }
|
||||||
|
|
||||||
/// needed for manipulators and things like std::endl
|
/// needed for manipulators and things like std::endl
|
||||||
inline RsNoDbg& operator<<(std::ostream& (*/*pf*/)(std::ostream&))
|
inline stream_type& operator<<(std::ostream& (*/*pf*/)(std::ostream&))
|
||||||
{ return *this; }
|
{ return *this; }
|
||||||
|
|
||||||
|
/** Return the object itself just for code compatibility with other
|
||||||
|
* logging classes */
|
||||||
|
inline stream_type& uStream() { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user