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

View File

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

View File

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

View File

@@ -28,97 +28,16 @@
#ifndef CWDEBUG
#ifdef DEBUG_CURLIO
// If CWDEBUG is not defined, but DEBUG_CURLIO is, then replace
// some of the cwd macro's with something that generates viewer
// specific debug output. Note that this generates a LOT of
// output and should not normally be defined.
#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
#error DEBUG_CURLIO is not supported without libcwd.
// In order to use DEBUG_CURLIO you must install and use libcwd.
// Download libcwd:
// git clone https://github.com/CarloWood/libcwd.git
#endif
#define Debug(x)
#define Dout(a, b)
#define DoutEntering(a, b)
#endif // !DEBUG_CURLIO
#ifndef DOXYGEN // No need to document this. See http://libcwd.sourceforge.net/ for more info.
#include <iostream>

View File

@@ -527,7 +527,7 @@ namespace AICurlPrivate {
using AICurlInterface::Stats;
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
// CURLOPT_DEBUGFUNCTION function.
extern int debug_callback(CURL*, curl_infotype infotype, char* buf, size_t size, void* user_ptr);
#endif
@@ -1181,7 +1181,7 @@ void CurlEasyRequest::set_timeout_opts(void)
void CurlEasyRequest::create_timeout_object(void)
{
ThreadSafeBufferedCurlEasyRequest* lockobj = NULL;
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
lockobj = static_cast<BufferedCurlEasyRequest*>(this)->get_lockobj();
#endif
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];
void BufferedCurlEasyRequest::connection_established(int connectionnr)

View File

@@ -250,7 +250,7 @@ void AICurlEasyRequestStateMachine::finish_impl(void)
}
AICurlEasyRequestStateMachine::AICurlEasyRequestStateMachine(CWD_ONLY(bool debug)) :
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
AIStateMachine(debug),
#endif
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.
bool mTimeoutIsOrphan; // Set to true when mTimeout is not (yet) associated with a CurlSocketInfo.
bool mIsHttps; // Set if the url starts with "https:".
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
public:
bool mDebugIsHeadOrGetMethod;
#endif
@@ -342,7 +342,7 @@ class CurlEasyRequest : public CurlEasyHandle {
// This class may only be created as base class of BufferedCurlEasyRequest.
// Throws AICurlNoEasyHandle.
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)
#endif
{ applyDefaultOptions(); }
@@ -475,7 +475,7 @@ class BufferedCurlEasyRequest : public CurlEasyRequest {
// Return true if any data was received.
bool received_data(void) const { return mTotalRawBytes > 0; }
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
// Connection accounting for debug purposes.
void connection_established(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
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
#undef AI_CASE_RETURN
#define AI_CASE_RETURN(x) case x: return #x;
static char const* action_str(int action)
@@ -2373,7 +2373,7 @@ int BufferedCurlEasyRequest::curlProgressCallback(void* user_data, double dltota
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)
{
BufferedCurlEasyRequest* request = (BufferedCurlEasyRequest*)user_ptr;
@@ -2441,7 +2441,6 @@ int debug_callback(CURL* handle, curl_infotype infotype, char* buf, size_t size,
}
#endif
#ifdef CWDEBUG
using namespace ::libcwd;
std::ostringstream marker;
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())
debug::channels::dc::curlio.on();
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)
{
case CURLINFO_TEXT:
@@ -2535,12 +2526,10 @@ int debug_callback(CURL* handle, curl_infotype infotype, char* buf, size_t size,
else
LibcwDoutStream << size << " bytes";
LibcwDoutScopeEnd;
#ifdef CWDEBUG
libcw_do.pop_marker();
#endif
return 0;
}
#endif // defined(CWDEBUG) || defined(DEBUG_CURLIO)
#endif // CWDEBUG
} // namespace AICurlPrivate

View File

@@ -86,7 +86,7 @@ public:
#include "aihttptimeout.h"
// If this is set, treat dc::curlio as off in the assertion below.
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
bool gCurlIo;
#endif
@@ -180,7 +180,7 @@ void HTTPTimeout::upload_finished(void)
// ^ ^ ^ ^ ^ ^ ^ ^
// | | | | | | | |
bool HTTPTimeout::data_received(size_t n/*,*/
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
ASSERT_ONLY_COMMA(bool upload_error_status)
#else
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_40ms; // Time between two clock ticks in 40 ms units.
static U64 sTime_10ms; // Time since the epoch in 10 ms units.
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
ThreadSafeBufferedCurlEasyRequest* mLockObj;
#endif
public:
HTTPTimeout(AIHTTPTimeoutPolicy const* policy, ThreadSafeBufferedCurlEasyRequest* lock_obj) :
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)
#endif
{ }
@@ -127,7 +127,7 @@ class HTTPTimeout : public LLRefCount {
// Called from BufferedCurlEasyRequest::processOutput if a timeout occurred.
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; }
#endif
@@ -146,7 +146,7 @@ class HTTPTimeout : public LLRefCount {
} // namespace curlthread
} // namespace AICurlPrivate
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
extern bool gCurlIo;
#endif

View File

@@ -149,7 +149,7 @@ void AIServiceBar::draw()
start += LLFontGL::getFontMonospace()->getWidth(text);
}
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);
#else
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,
LLHandle<LLWholeModelFeeObserver> const& fee_observer, LLHandle<LLWholeModelUploadObserver> const& upload_observer) :
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
AIStateMachine(false),
#endif
mMeshUpload(new AIStateMachineThread<LLMeshUploadThread>(CWD_ONLY(false))), mWholeModelUploadURL(upload_url)

View File

@@ -59,7 +59,7 @@ class AIFetchInventoryFolder : public AIStateMachine {
public:
AIFetchInventoryFolder(CWD_ONLY(bool debug = false)) :
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
AIStateMachine(debug),
#endif
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)) :
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
#ifdef CWDEBUG
AIStateMachine(debug),
#endif
mPluginManager(NULL), mCanceled(false)