No longer support DEBUG_CURLIO when libcwd isn't installed.

This commit is contained in:
Aleric Inglewood
2014-08-25 17:58:45 +02:00
parent b8d999066d
commit 8c6d51cb71
15 changed files with 32 additions and 124 deletions

View File

@@ -373,7 +373,7 @@ void AIEngine::setMaxCount(F32 StateMachineMaxTime)
sMaxCount = calc_clock_frequency() * StateMachineMaxTime / 1000; sMaxCount = calc_clock_frequency() * StateMachineMaxTime / 1000;
} }
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
char const* AIStateMachine::event_str(event_type event) char const* AIStateMachine::event_str(event_type event)
{ {
switch(event) switch(event)

View File

@@ -197,7 +197,7 @@ class AIStateMachine : public LLThreadSafeRefCount
bool mDebugAdvanceStatePending; // True while advance_state() was called by not handled yet. bool mDebugAdvanceStatePending; // True while advance_state() was called by not handled yet.
bool mDebugRefCalled; // True when ref() is called (or will be called within the critial area of mMultiplexMutex). bool mDebugRefCalled; // True when ref() is called (or will be called within the critial area of mMultiplexMutex).
#endif #endif
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
protected: protected:
bool mSMDebug; // Print debug output only when true. bool mSMDebug; // Print debug output only when true.
#endif #endif
@@ -210,7 +210,7 @@ class AIStateMachine : public LLThreadSafeRefCount
mThreadId(AIThreadID::none), mDebugLastState(bs_killed), mDebugShouldRun(false), mDebugAborted(false), mDebugContPending(false), mThreadId(AIThreadID::none), mDebugLastState(bs_killed), mDebugShouldRun(false), mDebugAborted(false), mDebugContPending(false),
mDebugSetStatePending(false), mDebugAdvanceStatePending(false), mDebugRefCalled(false), mDebugSetStatePending(false), mDebugAdvanceStatePending(false), mDebugRefCalled(false),
#endif #endif
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
mSMDebug(debug), mSMDebug(debug),
#endif #endif
mRuntime(0) mRuntime(0)
@@ -295,7 +295,7 @@ class AIStateMachine : public LLThreadSafeRefCount
// Return stringified state, for debugging purposes. // Return stringified state, for debugging purposes.
char const* state_str(base_state_type state); char const* state_str(base_state_type state);
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
char const* event_str(event_type event); char const* event_str(event_type event);
#endif #endif

View File

@@ -182,7 +182,7 @@ class AIStateMachineThreadBase : public AIStateMachine {
protected: protected:
AIStateMachineThreadBase(CWD_ONLY(bool debug)) AIStateMachineThreadBase(CWD_ONLY(bool debug))
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
: AIStateMachine(debug) : AIStateMachine(debug)
#endif #endif
{ } { }
@@ -222,7 +222,7 @@ class AIStateMachineThread : public AIStateMachineThreadBase {
public: public:
// Constructor. // Constructor.
AIStateMachineThread(CWD_ONLY(bool debug)) AIStateMachineThread(CWD_ONLY(bool debug))
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
: AIStateMachineThreadBase(debug) : AIStateMachineThreadBase(debug)
#endif #endif
{ {

View File

@@ -77,7 +77,7 @@ class AITimer : public AIStateMachine {
public: public:
AITimer(CWD_ONLY(bool debug = false)) : AITimer(CWD_ONLY(bool debug = false)) :
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
AIStateMachine(debug), AIStateMachine(debug),
#endif #endif
mInterval(0) { DoutEntering(dc::statemachine(mSMDebug), "AITimer(void) [" << (void*)this << "]"); } mInterval(0) { DoutEntering(dc::statemachine(mSMDebug), "AITimer(void) [" << (void*)this << "]"); }

View File

@@ -28,97 +28,16 @@
#ifndef CWDEBUG #ifndef CWDEBUG
#ifdef DEBUG_CURLIO #ifdef DEBUG_CURLIO
#error DEBUG_CURLIO is not supported without libcwd.
// If CWDEBUG is not defined, but DEBUG_CURLIO is, then replace // In order to use DEBUG_CURLIO you must install and use libcwd.
// some of the cwd macro's with something that generates viewer // Download libcwd:
// specific debug output. Note that this generates a LOT of // git clone https://github.com/CarloWood/libcwd.git
// output and should not normally be defined. #endif
#include <string>
#include "llpreprocessor.h"
namespace debug {
namespace libcwd {
struct buf2str {
buf2str(char const* buf, int size) : mBuf(buf), mSize(size) { }
char const* mBuf;
int mSize;
};
struct libcwd_do_type {
void on() const { }
};
extern LL_COMMON_API libcwd_do_type const libcw_do;
} // namespace libcwd
enum print_thread_id_t { print_thread_id };
inline void init() { }
struct Indent {
int M_indent;
static ll_thread_local int S_indentation;
enum LL_COMMON_API print_nt { print };
LL_COMMON_API Indent(int indent);
LL_COMMON_API ~Indent();
};
extern LL_COMMON_API std::ostream& operator<<(std::ostream& os, libcwd::buf2str const& b2s);
extern LL_COMMON_API std::ostream& operator<<(std::ostream& os, Indent::print_nt);
extern LL_COMMON_API std::ostream& operator<<(std::ostream& os, print_thread_id_t);
namespace dc {
struct fake_channel {
int mOn;
char const* mLabel;
fake_channel(int on, char const* label) : mOn(on), mLabel(label) { }
fake_channel(void) : mOn(0) { }
fake_channel& operator()(bool) { return *this; }
fake_channel const& operator()(bool) const { return *this; }
bool is_on() const { return !!mOn; }
bool is_off() const { return !mOn; }
void on() const { }
void off() const { }
};
extern LL_COMMON_API fake_channel const warning;
extern LL_COMMON_API fake_channel const curl;
extern LL_COMMON_API fake_channel const curlio;
extern LL_COMMON_API fake_channel const curltr;
extern LL_COMMON_API fake_channel const statemachine;
extern LL_COMMON_API fake_channel const notice;
extern LL_COMMON_API fake_channel const snapshot;
} // namespace dc
} // namespace debug
#define LIBCWD_DEBUG_CHANNELS debug
#define LibcwDoutScopeBegin(a, b, c) do { using namespace debug; using namespace debug::libcwd; llinfos_nf << print_thread_id << (c).mLabel << ": " << Indent::print;
#define LibcwDoutStream llcont
#define LibcwDoutScopeEnd llcont << llendl; } while(0)
#define Debug(x) do { using namespace debug; using namespace debug::libcwd; x; } while(0)
#define Dout(a, b) do { using namespace debug; using namespace debug::libcwd; if ((a).mOn) { llinfos_nf << print_thread_id << (a).mLabel << ": " << Indent::print << b << llendl; } } while(0)
#define DoutEntering(a, b) \
int __slviewer_debug_indentation = 2; \
{ \
using namespace debug; \
using namespace debug::libcwd; \
if ((a).mOn) \
llinfos_nf << print_thread_id << (a).mLabel << ": " << Indent::print << "Entering " << b << llendl; \
else \
__slviewer_debug_indentation = 0; \
} \
debug::Indent __slviewer_debug_indent(__slviewer_debug_indentation);
#else // !DEBUG_CURLIO
#define Debug(x) #define Debug(x)
#define Dout(a, b) #define Dout(a, b)
#define DoutEntering(a, b) #define DoutEntering(a, b)
#endif // !DEBUG_CURLIO
#ifndef DOXYGEN // No need to document this. See http://libcwd.sourceforge.net/ for more info. #ifndef DOXYGEN // No need to document this. See http://libcwd.sourceforge.net/ for more info.
#include <iostream> #include <iostream>

View File

@@ -527,7 +527,7 @@ namespace AICurlPrivate {
using AICurlInterface::Stats; using AICurlInterface::Stats;
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
// CURLOPT_DEBUGFUNCTION function. // CURLOPT_DEBUGFUNCTION function.
extern int debug_callback(CURL*, curl_infotype infotype, char* buf, size_t size, void* user_ptr); extern int debug_callback(CURL*, curl_infotype infotype, char* buf, size_t size, void* user_ptr);
#endif #endif
@@ -1181,7 +1181,7 @@ void CurlEasyRequest::set_timeout_opts(void)
void CurlEasyRequest::create_timeout_object(void) void CurlEasyRequest::create_timeout_object(void)
{ {
ThreadSafeBufferedCurlEasyRequest* lockobj = NULL; ThreadSafeBufferedCurlEasyRequest* lockobj = NULL;
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
lockobj = static_cast<BufferedCurlEasyRequest*>(this)->get_lockobj(); lockobj = static_cast<BufferedCurlEasyRequest*>(this)->get_lockobj();
#endif #endif
mTimeout = new curlthread::HTTPTimeout(mTimeoutPolicy, lockobj); mTimeout = new curlthread::HTTPTimeout(mTimeoutPolicy, lockobj);
@@ -1352,7 +1352,7 @@ void BufferedCurlEasyRequest::aborted(U32 http_status, std::string const& reason
} }
} }
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
static AIPerServicePtr sConnections[64]; static AIPerServicePtr sConnections[64];
void BufferedCurlEasyRequest::connection_established(int connectionnr) void BufferedCurlEasyRequest::connection_established(int connectionnr)

View File

@@ -250,7 +250,7 @@ void AICurlEasyRequestStateMachine::finish_impl(void)
} }
AICurlEasyRequestStateMachine::AICurlEasyRequestStateMachine(CWD_ONLY(bool debug)) : AICurlEasyRequestStateMachine::AICurlEasyRequestStateMachine(CWD_ONLY(bool debug)) :
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
AIStateMachine(debug), AIStateMachine(debug),
#endif #endif
mTotalDelayTimeout(AIHTTPTimeoutPolicy::getDebugSettingsCurlTimeout().getTotalDelay()) mTotalDelayTimeout(AIHTTPTimeoutPolicy::getDebugSettingsCurlTimeout().getTotalDelay())

View File

@@ -320,7 +320,7 @@ class CurlEasyRequest : public CurlEasyHandle {
LLPointer<curlthread::HTTPTimeout> mTimeout;// Timeout administration object associated with last created CurlSocketInfo. LLPointer<curlthread::HTTPTimeout> mTimeout;// Timeout administration object associated with last created CurlSocketInfo.
bool mTimeoutIsOrphan; // Set to true when mTimeout is not (yet) associated with a CurlSocketInfo. bool mTimeoutIsOrphan; // Set to true when mTimeout is not (yet) associated with a CurlSocketInfo.
bool mIsHttps; // Set if the url starts with "https:". bool mIsHttps; // Set if the url starts with "https:".
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
public: public:
bool mDebugIsHeadOrGetMethod; bool mDebugIsHeadOrGetMethod;
#endif #endif
@@ -342,7 +342,7 @@ class CurlEasyRequest : public CurlEasyHandle {
// This class may only be created as base class of BufferedCurlEasyRequest. // This class may only be created as base class of BufferedCurlEasyRequest.
// Throws AICurlNoEasyHandle. // Throws AICurlNoEasyHandle.
CurlEasyRequest(void) : mHeaders(NULL), mHandleEventsTarget(NULL), mContentLength(0), mResult(CURLE_FAILED_INIT), mTimeoutPolicy(NULL), mTimeoutIsOrphan(false) CurlEasyRequest(void) : mHeaders(NULL), mHandleEventsTarget(NULL), mContentLength(0), mResult(CURLE_FAILED_INIT), mTimeoutPolicy(NULL), mTimeoutIsOrphan(false)
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
, mDebugIsHeadOrGetMethod(false) , mDebugIsHeadOrGetMethod(false)
#endif #endif
{ applyDefaultOptions(); } { applyDefaultOptions(); }
@@ -475,7 +475,7 @@ class BufferedCurlEasyRequest : public CurlEasyRequest {
// Return true if any data was received. // Return true if any data was received.
bool received_data(void) const { return mTotalRawBytes > 0; } bool received_data(void) const { return mTotalRawBytes > 0; }
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
// Connection accounting for debug purposes. // Connection accounting for debug purposes.
void connection_established(int connectionnr); void connection_established(int connectionnr);
void connection_closed(int connectionnr); void connection_closed(int connectionnr);

View File

@@ -730,7 +730,7 @@ bool MergeIterator::next(curl_socket_t& fd_out, int& ev_bitmask_out)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// CurlSocketInfo // CurlSocketInfo
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
#undef AI_CASE_RETURN #undef AI_CASE_RETURN
#define AI_CASE_RETURN(x) case x: return #x; #define AI_CASE_RETURN(x) case x: return #x;
static char const* action_str(int action) static char const* action_str(int action)
@@ -2373,7 +2373,7 @@ int BufferedCurlEasyRequest::curlProgressCallback(void* user_data, double dltota
return 0; return 0;
} }
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
int debug_callback(CURL* handle, curl_infotype infotype, char* buf, size_t size, void* user_ptr) int debug_callback(CURL* handle, curl_infotype infotype, char* buf, size_t size, void* user_ptr)
{ {
BufferedCurlEasyRequest* request = (BufferedCurlEasyRequest*)user_ptr; BufferedCurlEasyRequest* request = (BufferedCurlEasyRequest*)user_ptr;
@@ -2441,7 +2441,6 @@ int debug_callback(CURL* handle, curl_infotype infotype, char* buf, size_t size,
} }
#endif #endif
#ifdef CWDEBUG
using namespace ::libcwd; using namespace ::libcwd;
std::ostringstream marker; std::ostringstream marker;
marker << (void*)request->get_lockobj() << ' '; marker << (void*)request->get_lockobj() << ' ';
@@ -2450,14 +2449,6 @@ int debug_callback(CURL* handle, curl_infotype infotype, char* buf, size_t size,
if (!debug::channels::dc::curlio.is_on()) if (!debug::channels::dc::curlio.is_on())
debug::channels::dc::curlio.on(); debug::channels::dc::curlio.on();
LibcwDoutScopeBegin(LIBCWD_DEBUGCHANNELS, libcw_do, dc::curlio|cond_nonewline_cf(infotype == CURLINFO_TEXT)) LibcwDoutScopeBegin(LIBCWD_DEBUGCHANNELS, libcw_do, dc::curlio|cond_nonewline_cf(infotype == CURLINFO_TEXT))
#else
if (infotype == CURLINFO_TEXT)
{
while (size > 0 && (buf[size - 1] == '\r' || buf[size - 1] == '\n'))
--size;
}
LibcwDoutScopeBegin(LIBCWD_DEBUGCHANNELS, libcw_do, dc::curlio)
#endif
switch (infotype) switch (infotype)
{ {
case CURLINFO_TEXT: case CURLINFO_TEXT:
@@ -2535,12 +2526,10 @@ int debug_callback(CURL* handle, curl_infotype infotype, char* buf, size_t size,
else else
LibcwDoutStream << size << " bytes"; LibcwDoutStream << size << " bytes";
LibcwDoutScopeEnd; LibcwDoutScopeEnd;
#ifdef CWDEBUG
libcw_do.pop_marker(); libcw_do.pop_marker();
#endif
return 0; return 0;
} }
#endif // defined(CWDEBUG) || defined(DEBUG_CURLIO) #endif // CWDEBUG
} // namespace AICurlPrivate } // namespace AICurlPrivate

View File

@@ -86,7 +86,7 @@ public:
#include "aihttptimeout.h" #include "aihttptimeout.h"
// If this is set, treat dc::curlio as off in the assertion below. // If this is set, treat dc::curlio as off in the assertion below.
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
bool gCurlIo; bool gCurlIo;
#endif #endif
@@ -180,7 +180,7 @@ void HTTPTimeout::upload_finished(void)
// ^ ^ ^ ^ ^ ^ ^ ^ // ^ ^ ^ ^ ^ ^ ^ ^
// | | | | | | | | // | | | | | | | |
bool HTTPTimeout::data_received(size_t n/*,*/ bool HTTPTimeout::data_received(size_t n/*,*/
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
ASSERT_ONLY_COMMA(bool upload_error_status) ASSERT_ONLY_COMMA(bool upload_error_status)
#else #else
ASSERT_ONLY_COMMA(bool) ASSERT_ONLY_COMMA(bool)

View File

@@ -91,14 +91,14 @@ class HTTPTimeout : public LLRefCount {
static F64 const sClockWidth_10ms; // Time between two clock ticks in 10 ms units. static F64 const sClockWidth_10ms; // Time between two clock ticks in 10 ms units.
static F64 const sClockWidth_40ms; // Time between two clock ticks in 40 ms units. static F64 const sClockWidth_40ms; // Time between two clock ticks in 40 ms units.
static U64 sTime_10ms; // Time since the epoch in 10 ms units. static U64 sTime_10ms; // Time since the epoch in 10 ms units.
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
ThreadSafeBufferedCurlEasyRequest* mLockObj; ThreadSafeBufferedCurlEasyRequest* mLockObj;
#endif #endif
public: public:
HTTPTimeout(AIHTTPTimeoutPolicy const* policy, ThreadSafeBufferedCurlEasyRequest* lock_obj) : HTTPTimeout(AIHTTPTimeoutPolicy const* policy, ThreadSafeBufferedCurlEasyRequest* lock_obj) :
mPolicy(policy), mNothingReceivedYet(true), mLowSpeedOn(false), mLastBytesSent(false), mBeingRedirected(false), mUploadFinished(false), mStalled((U64)-1) mPolicy(policy), mNothingReceivedYet(true), mLowSpeedOn(false), mLastBytesSent(false), mBeingRedirected(false), mUploadFinished(false), mStalled((U64)-1)
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
, mLockObj(lock_obj) , mLockObj(lock_obj)
#endif #endif
{ } { }
@@ -127,7 +127,7 @@ class HTTPTimeout : public LLRefCount {
// Called from BufferedCurlEasyRequest::processOutput if a timeout occurred. // Called from BufferedCurlEasyRequest::processOutput if a timeout occurred.
void print_diagnostics(CurlEasyRequest const* curl_easy_request, char const* eff_url); void print_diagnostics(CurlEasyRequest const* curl_easy_request, char const* eff_url);
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
void* get_lockobj(void) const { return mLockObj; } void* get_lockobj(void) const { return mLockObj; }
#endif #endif
@@ -146,7 +146,7 @@ class HTTPTimeout : public LLRefCount {
} // namespace curlthread } // namespace curlthread
} // namespace AICurlPrivate } // namespace AICurlPrivate
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
extern bool gCurlIo; extern bool gCurlIo;
#endif #endif

View File

@@ -149,7 +149,7 @@ void AIServiceBar::draw()
start += LLFontGL::getFontMonospace()->getWidth(text); start += LLFontGL::getFontMonospace()->getWidth(text);
} }
start = mHTTPView->updateColumn(mc_col, start); start = mHTTPView->updateColumn(mc_col, start);
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
text = llformat(" | %d,%d,%d/%d", total_added, event_polls, established_connections, concurrent_connections); text = llformat(" | %d,%d,%d/%d", total_added, event_polls, established_connections, concurrent_connections);
#else #else
text = llformat(" | %d/%d", total_added, concurrent_connections); text = llformat(" | %d/%d", total_added, concurrent_connections);

View File

@@ -1432,7 +1432,7 @@ void LLMeshUploadThread::preStart()
AIMeshUpload::AIMeshUpload(LLMeshUploadThread::instance_list& data, LLVector3& scale, bool upload_textures, bool upload_skin, bool upload_joints, std::string const& upload_url, bool do_upload, AIMeshUpload::AIMeshUpload(LLMeshUploadThread::instance_list& data, LLVector3& scale, bool upload_textures, bool upload_skin, bool upload_joints, std::string const& upload_url, bool do_upload,
LLHandle<LLWholeModelFeeObserver> const& fee_observer, LLHandle<LLWholeModelUploadObserver> const& upload_observer) : LLHandle<LLWholeModelFeeObserver> const& fee_observer, LLHandle<LLWholeModelUploadObserver> const& upload_observer) :
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
AIStateMachine(false), AIStateMachine(false),
#endif #endif
mMeshUpload(new AIStateMachineThread<LLMeshUploadThread>(CWD_ONLY(false))), mWholeModelUploadURL(upload_url) mMeshUpload(new AIStateMachineThread<LLMeshUploadThread>(CWD_ONLY(false))), mWholeModelUploadURL(upload_url)

View File

@@ -59,7 +59,7 @@ class AIFetchInventoryFolder : public AIStateMachine {
public: public:
AIFetchInventoryFolder(CWD_ONLY(bool debug = false)) : AIFetchInventoryFolder(CWD_ONLY(bool debug = false)) :
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
AIStateMachine(debug), AIStateMachine(debug),
#endif #endif
mCreate(false), mFetchContents(false), mExists(false), mCreated(false) mCreate(false), mFetchContents(false), mExists(false), mCreated(false)

View File

@@ -61,7 +61,7 @@ char const* AIFilePicker::state_str_impl(state_type run_state) const
} }
AIFilePicker::AIFilePicker(CWD_ONLY(bool debug)) : AIFilePicker::AIFilePicker(CWD_ONLY(bool debug)) :
#if defined(CWDEBUG) || defined(DEBUG_CURLIO) #ifdef CWDEBUG
AIStateMachine(debug), AIStateMachine(debug),
#endif #endif
mPluginManager(NULL), mCanceled(false) mPluginManager(NULL), mCanceled(false)