From 8c6d51cb7197d02a40c62b4d7ae38317815c0bcd Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Mon, 25 Aug 2014 17:58:45 +0200 Subject: [PATCH] No longer support DEBUG_CURLIO when libcwd isn't installed. --- indra/aistatemachine/aistatemachine.cpp | 2 +- indra/aistatemachine/aistatemachine.h | 6 +- indra/aistatemachine/aistatemachinethread.h | 4 +- indra/aistatemachine/aitimer.h | 2 +- indra/cwdebug/debug.h | 91 +------------------ indra/llmessage/aicurl.cpp | 6 +- .../aicurleasyrequeststatemachine.cpp | 2 +- indra/llmessage/aicurlprivate.h | 6 +- indra/llmessage/aicurlthread.cpp | 17 +--- indra/llmessage/aihttptimeout.cpp | 4 +- indra/llmessage/aihttptimeout.h | 8 +- indra/newview/aihttpview.cpp | 2 +- indra/newview/llmeshrepository.cpp | 2 +- .../statemachine/aifetchinventoryfolder.h | 2 +- indra/newview/statemachine/aifilepicker.cpp | 2 +- 15 files changed, 32 insertions(+), 124 deletions(-) diff --git a/indra/aistatemachine/aistatemachine.cpp b/indra/aistatemachine/aistatemachine.cpp index fcdb2d9c8..83eddcd95 100644 --- a/indra/aistatemachine/aistatemachine.cpp +++ b/indra/aistatemachine/aistatemachine.cpp @@ -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) diff --git a/indra/aistatemachine/aistatemachine.h b/indra/aistatemachine/aistatemachine.h index a9ac33d68..aab482327 100644 --- a/indra/aistatemachine/aistatemachine.h +++ b/indra/aistatemachine/aistatemachine.h @@ -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 diff --git a/indra/aistatemachine/aistatemachinethread.h b/indra/aistatemachine/aistatemachinethread.h index d2ca65c8d..2891cbb77 100644 --- a/indra/aistatemachine/aistatemachinethread.h +++ b/indra/aistatemachine/aistatemachinethread.h @@ -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 { diff --git a/indra/aistatemachine/aitimer.h b/indra/aistatemachine/aitimer.h index a8aeb8ca6..3ee510007 100644 --- a/indra/aistatemachine/aitimer.h +++ b/indra/aistatemachine/aitimer.h @@ -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 << "]"); } diff --git a/indra/cwdebug/debug.h b/indra/cwdebug/debug.h index 58e0c6ac9..93a037c92 100644 --- a/indra/cwdebug/debug.h +++ b/indra/cwdebug/debug.h @@ -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 -#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 diff --git a/indra/llmessage/aicurl.cpp b/indra/llmessage/aicurl.cpp index 99683e0c5..3f832bde8 100644 --- a/indra/llmessage/aicurl.cpp +++ b/indra/llmessage/aicurl.cpp @@ -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(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) diff --git a/indra/llmessage/aicurleasyrequeststatemachine.cpp b/indra/llmessage/aicurleasyrequeststatemachine.cpp index 2642bb92c..6b7bcf654 100644 --- a/indra/llmessage/aicurleasyrequeststatemachine.cpp +++ b/indra/llmessage/aicurleasyrequeststatemachine.cpp @@ -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()) diff --git a/indra/llmessage/aicurlprivate.h b/indra/llmessage/aicurlprivate.h index be3d90e7d..b27e8def3 100644 --- a/indra/llmessage/aicurlprivate.h +++ b/indra/llmessage/aicurlprivate.h @@ -320,7 +320,7 @@ class CurlEasyRequest : public CurlEasyHandle { LLPointer 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); diff --git a/indra/llmessage/aicurlthread.cpp b/indra/llmessage/aicurlthread.cpp index 19f190b6b..655815870 100644 --- a/indra/llmessage/aicurlthread.cpp +++ b/indra/llmessage/aicurlthread.cpp @@ -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 diff --git a/indra/llmessage/aihttptimeout.cpp b/indra/llmessage/aihttptimeout.cpp index f79e2a450..c41dc6575 100644 --- a/indra/llmessage/aihttptimeout.cpp +++ b/indra/llmessage/aihttptimeout.cpp @@ -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) diff --git a/indra/llmessage/aihttptimeout.h b/indra/llmessage/aihttptimeout.h index 1af96c9c7..9d894d16b 100644 --- a/indra/llmessage/aihttptimeout.h +++ b/indra/llmessage/aihttptimeout.h @@ -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 diff --git a/indra/newview/aihttpview.cpp b/indra/newview/aihttpview.cpp index d3de57171..7e97f9768 100644 --- a/indra/newview/aihttpview.cpp +++ b/indra/newview/aihttpview.cpp @@ -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); diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index d23739622..4d51734dc 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -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 const& fee_observer, LLHandle const& upload_observer) : -#if defined(CWDEBUG) || defined(DEBUG_CURLIO) +#ifdef CWDEBUG AIStateMachine(false), #endif mMeshUpload(new AIStateMachineThread(CWD_ONLY(false))), mWholeModelUploadURL(upload_url) diff --git a/indra/newview/statemachine/aifetchinventoryfolder.h b/indra/newview/statemachine/aifetchinventoryfolder.h index d95fd5ca1..59419fc86 100644 --- a/indra/newview/statemachine/aifetchinventoryfolder.h +++ b/indra/newview/statemachine/aifetchinventoryfolder.h @@ -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) diff --git a/indra/newview/statemachine/aifilepicker.cpp b/indra/newview/statemachine/aifilepicker.cpp index a17ebc864..6754142e4 100644 --- a/indra/newview/statemachine/aifilepicker.cpp +++ b/indra/newview/statemachine/aifilepicker.cpp @@ -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)