tags 497633 + patch thanks [Petter Reinholdtsen] > Would you be willing to do an update of the package in Lenny to flip > the DEBUG flag and reduce the noise?
Apparently the DEBUG flag do not exist in version 0.8.4. :( Anyway, here is an untested patch I hope should fix the issue. It wrapps all output to cout with #ifdef protection, to avoid printing anything in the non-debugging case. I am unable to test this, as building 0.8.4-2 in Lenny causes a segfault when configure is running: checking if more special flags are required for pthreads... no checking for the Boost Version... checking for boost header... checking for Boost libraries... -lboost_thread-gcc42-mt-1_34_1 -lboost_date_time-gcc42-1_34_1 configure: creating ./config.status Segmentation fault Have not investigated this issue so far. Happy hacking, -- Petter Reinholdtsen
--- gnash-0.8.4.orig/plugin/plugin.cpp +++ gnash-0.8.4/plugin/plugin.cpp @@ -47,6 +47,15 @@ http://www.gnu.org/software/gnash</a>. \ Compatible Shockwave Flash "FLASH_VERSION +// Define the following to make the plugin verbose +// WARNING: will write to .xsession_errors ! +// Values: +// 1: fatal errors (errors preventing the plugin from working as it should) +// 2: informational messages +// +#define GNASH_PLUGIN_DEBUG 1 + + #include <sys/param.h> #include "plugin.h" //Fixes Warning on redef of MIN/MAX #include <csignal> @@ -139,11 +148,15 @@ { if ( plugInitialized ) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "NS_PluginInitialize called, but ignored (we already initialized)" << endl; +#endif return NPERR_NO_ERROR; } +#if GNASH_PLUGIN_DEBUG > 1 cout << "NS_PluginInitialize call ---------------------------------------------------" << endl; +#endif #ifdef HAVE_XPCOM if(!cookieManager) { @@ -155,7 +168,9 @@ (reinterpret_cast<void **>(&serviceManager))); if (err != NPERR_NO_ERROR || !serviceManager) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "Failed to get the service manager" << endl; +#endif return NPERR_GENERIC_ERROR; } nsresult rv; @@ -163,10 +178,14 @@ NS_GET_IID (nsICookieManager), reinterpret_cast<void **>(&cookieManager)); if (NS_FAILED (rv) || !cookieManager) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "Failed to get CookieManager" << endl; +#endif return NPERR_GENERIC_ERROR; } +#if GNASH_PLUGIN_DEBUG > 1 cout << "[XPCOM] - CookieManager retrieved." << endl; +#endif } #endif // HAVE_XPCOM @@ -189,13 +208,17 @@ if (err != NPERR_NO_ERROR || !supportsXEmbed) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "NPAPI ERROR: No xEmbed support in this browser!" +#endif << endl; return NPERR_INCOMPATIBLE_VERSION_ERROR; } else { +#if GNASH_PLUGIN_DEBUG > 1 cout << "xEmbed supported in this browser" << endl; +#endif } err = CallNPN_GetValueProc(NPNFuncs.getvalue, NULL, @@ -208,14 +231,18 @@ */ if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "NPAPI ERROR: No GTK2 support in this browser!" " Have version " << (int)toolkit << endl; +#endif return NPERR_INCOMPATIBLE_VERSION_ERROR; } else { +#if GNASH_PLUGIN_DEBUG > 1 cout << "GTK2 supported in this browser" << endl; +#endif } /* @@ -224,7 +251,9 @@ char* opts = std::getenv("GNASH_OPTIONS"); if (opts != NULL) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "GNASH_OPTIONS : " << opts << endl; +#endif // Should the plugin wait for gdb to be attached? if ( strstr(opts, "waitforgdb") ) @@ -266,7 +295,9 @@ { cerr << "WARNING: NPAPI plugin could not append to the GNASHRC env variable" << endl; } +#if GNASH_PLUGIN_DEBUG > 1 else cout << "NOTE: NPAPI plugin set GNASHRC to " << newGnashRc << endl; +#endif } while (0); @@ -290,7 +321,9 @@ #if 0 if (!plugInitialized) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "Plugin already shut down" << endl; +#endif return; } @@ -413,10 +446,14 @@ /// \brief Destructor nsPluginInstance::~nsPluginInstance() { +#if GNASH_PLUGIN_DEBUG > 1 cout << "plugin instance destruction" << endl; +#endif if ( _ichan ) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "shutting down input chan " << _ichan << endl; +#endif GError *error = NULL; g_io_channel_shutdown (_ichan, TRUE, &error); g_io_channel_unref (_ichan); @@ -428,7 +465,9 @@ // TODO: unlink the cookie jar if ( ! _cookieFile.empty() ) { +#if GNASH_PLUGIN_DEBUG > 1 cout << " ~nsPluginInstance: file " << _cookieFile << " should be unlinked!" << endl; +#endif } } @@ -442,17 +481,21 @@ { if(!aWindow) { +#if GNASH_PLUGIN_DEBUG > 1 cout << __PRETTY_FUNCTION__ << " ERROR: Window handle was bogus!" << endl; +#endif return FALSE; } else { +#if GNASH_PLUGIN_DEBUG > 1 cout << "X origin: = " << aWindow->x << ", Y Origin = " << aWindow->y << ", Width = " << aWindow->width << ", Height = " << aWindow->height << ", WindowID = " << aWindow->window << ", this = " << static_cast<void*>(this) << endl; +#endif } #if 0 @@ -461,7 +504,9 @@ bool gdb = true; while (gdb) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "Waiting for GDB for pid " << getpid() << endl; +#endif sleep(5); } #endif @@ -477,7 +522,9 @@ void nsPluginInstance::shut() { +#if GNASH_PLUGIN_DEBUG > 1 cout << "Shutting down" << endl; +#endif if (_childpid > 0) { @@ -487,7 +534,9 @@ kill(_childpid, SIGTERM); int status; waitpid(_childpid, &status, 0); +#if GNASH_PLUGIN_DEBUG > 1 cout << "Child process exited with status " << status << endl; +#endif } _childpid = 0; @@ -505,7 +554,9 @@ { if(!aWindow) { +#if GNASH_PLUGIN_DEBUG > 1 cout << __FUNCTION__ << ": ERROR: Window handle was bogus!" << endl; +#endif return NPERR_INVALID_PARAM; #if 0 } @@ -542,7 +593,9 @@ nsPluginInstance::WriteStatus(char *msg) const { NPN_Status(_instance, msg); +#if GNASH_PLUGIN_DEBUG > 1 cout << msg << endl; +#endif return NPERR_NO_ERROR; } @@ -569,7 +622,9 @@ { _swf_url = stream->url; +#if GNASH_PLUGIN_DEBUG > 1 cout << __FUNCTION__ << ": The full URL is " << _swf_url << endl; +#endif #ifdef WRITE_FILE size_t start, end; @@ -578,7 +633,9 @@ start = _swf_url.rfind("/", end) + 1; fname = "/tmp/"; fname += _swf_url.substr(start, end - start); +#if GNASH_PLUGIN_DEBUG > 1 cout << "The Flash movie name is: " << fname << endl; +#endif _filefd = open(fname.c_str(), O_CREAT | O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); @@ -674,7 +731,9 @@ { if ( cond & G_IO_HUP ) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "Player request channel hang up" << endl; +#endif g_source_remove(_ichanWatchId); return false; } @@ -682,7 +741,9 @@ assert(cond & G_IO_IN); int inputfd = g_io_channel_unix_get_fd(iochan); +#if GNASH_PLUGIN_DEBUG > 1 cout << "Checking player requests on fd " << inputfd << endl; +#endif do { @@ -693,21 +754,31 @@ switch ( status ) { case G_IO_STATUS_ERROR: +#if GNASH_PLUGIN_DEBUG > 1 cout << "Error reading request line: " << error->message << endl; +#endif g_error_free(error); return false; case G_IO_STATUS_EOF: +#if GNASH_PLUGIN_DEBUG > 1 cout << "EOF (error:" << error << ")" << endl; +#endif return false; case G_IO_STATUS_AGAIN: +#if GNASH_PLUGIN_DEBUG > 1 cout << "Read again (error:" << error << ")" << endl; +#endif break; case G_IO_STATUS_NORMAL: // process request +#if GNASH_PLUGIN_DEBUG > 1 cout << "Normal read: " << request << " (error:" << error << ")" << endl; +#endif break; default: +#if GNASH_PLUGIN_DEBUG > 1 cout << "Abnormal status " << status << " (error:" << error << ")" << endl; +#endif return false; } @@ -727,7 +798,9 @@ { if ( linelen < 4 ) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "Invalid player request (too short): " << buf << endl; +#endif return false; } @@ -736,7 +809,9 @@ char* target = buf+4; if ( ! *target ) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "No target found after GET request" << endl; +#endif return false; } char* url = target; @@ -748,11 +823,15 @@ } else { +#if GNASH_PLUGIN_DEBUG > 1 cout << "No colon found after GETURL target string" << endl; +#endif return false; } +#if GNASH_PLUGIN_DEBUG > 1 cout << "Asked to get URL '" << url << "' in target '" << target << "'" << endl; +#endif NPN_GetURL(_instance, url, target); return true; @@ -761,7 +840,9 @@ { char* command = buf+7; if ( ! *command ) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "No command found after INVOKE request" << endl; +#endif return false; } char* arg = command; @@ -770,7 +851,9 @@ *arg='\0'; ++arg; } else { +#if GNASH_PLUGIN_DEBUG > 1 cout << "No colon found after INVOKE command string" << endl; +#endif return false; } @@ -782,13 +865,17 @@ // TODO: check if _self is a good target for this static const char* tgt = "_self"; +#if GNASH_PLUGIN_DEBUG > 1 cout << "Calling NPN_GetURL(" << jsurl.str() << ", '" << tgt << "');" << endl; +#endif NPN_GetURL(_instance, jsurl.str().c_str(), tgt); return true; } else { +#if GNASH_PLUGIN_DEBUG > 1 cout << "Unknown player request: '" << buf << "'" << endl; +#endif return false; } } @@ -851,14 +938,18 @@ nsPluginInstance::dumpCookies() { if ( ! _cookieFile.empty() ) { +#if GNASH_PLUGIN_DEBUG > 1 cout << " dumpCookies: file " << _cookieFile << " should be unlinked!" << endl; +#endif } _cookieFile.clear(); // Linking problems... //#ifdef HAVE_XPCOM #if 0 +#if GNASH_PLUGIN_DEBUG > 1 cout << "[XPCOM] trying to dump cookies" << endl; +#endif nsCOMPtr<nsISimpleEnumerator> cookie_e; nsresult rv = cookieManager->GetEnumerator(getter_AddRefs(cookie_e)); @@ -874,10 +965,14 @@ const char *tmpname = tmpnam(tmpnamebuf); fout.open(tmpname, ios::out | ios::trunc); if(!fout.is_open()) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "not opened!!" << endl; +#endif continue; } else { +#if GNASH_PLUGIN_DEBUG > 1 cout << "opened cookie store: " << tmpname << endl; +#endif } res = TRUE; _cookieFile = tmpname; // assign ? @@ -894,32 +989,44 @@ nsCString host; if(NS_FAILED(cookie->GetHost(host))) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "[XPCOM] cookie without host ... ommitting" << endl; +#endif continue; } nsCString path; if(NS_FAILED(cookie->GetPath(path))) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "[XPCOM] cookie without path ... ommitting" << endl; +#endif continue; } PRBool isSecure; if(NS_FAILED(cookie->GetIsSecure(&isSecure))) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "[XPCOM] cookie without isSecure ... ommitting" << endl; +#endif continue; } PRUint64 expires; if(NS_FAILED(cookie->GetExpires(&expires))) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "[XPCOM] cookie without expires ... ommitting" << endl; +#endif continue; } nsCString name; if(NS_FAILED(cookie->GetName(name))) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "[XPCOM] cookie without name ... ommitting" << endl; +#endif continue; } nsCString value; if(NS_FAILED(cookie->GetValue(value))) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "[XPCOM] cookie without value ... ommitting" << endl; +#endif continue; } @@ -953,9 +1060,13 @@ c++; } fout.close(); +#if GNASH_PLUGIN_DEBUG > 1 cout << "[XPCOM] dump finished (" << c << " cookies in total)" << endl; +#endif } else { +#if GNASH_PLUGIN_DEBUG > 1 cout << "[XPCOM] WARNING: Cookie feature disabled" << endl; +#endif } #endif // HAVE_XPCOM @@ -983,7 +1094,9 @@ const char* pageurl = getCurrentPageURL(); if (!pageurl) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "Could not get current page URL!" << endl; +#endif } struct stat procstats; @@ -991,7 +1104,9 @@ // See if the file actually exists, otherwise we can't spawn it if (stat(procname.c_str(), &procstats) == -1) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "Invalid path to standalone executable: " << procname << endl; +#endif return; } @@ -1004,14 +1119,18 @@ int ret = pipe(p2c_pipe); if (ret == -1) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "ERROR: parent to child pipe() failed: " << strerror(errno) << endl; +#endif } _streamfd = p2c_pipe[1]; ret = pipe(c2p_pipe); if (ret == -1) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "ERROR: child to parent pipe() failed: " << strerror(errno) << endl; +#endif } @@ -1112,7 +1231,9 @@ // If the fork failed, childpid is -1. So print out an error message. if (_childpid == -1) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "ERROR: dup2() failed: " << strerror(errno) << endl; +#endif return; } @@ -1125,7 +1246,9 @@ ret = close (p2c_pipe[0]); if (ret == -1) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "ERROR: p2c_pipe[0] close() failed: " << strerror(errno) +#endif << endl; } @@ -1133,14 +1256,18 @@ ret = close (c2p_pipe[1]); if (ret == -1) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "ERROR: c2p_pipe[1] close() failed: " << strerror(errno) +#endif << endl; } +#if GNASH_PLUGIN_DEBUG > 1 cout << "Forked successfully, child process PID is " << _childpid << endl; +#endif _ichan = g_io_channel_unix_new(c2p_pipe[0]); g_io_channel_set_close_on_unref(_ichan, true); @@ -1158,7 +1285,9 @@ ret = close (p2c_pipe[1]); if (ret == -1) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "ERROR: close() failed: " << strerror(errno) << endl; +#endif } // close standard input and direct read-fd1 to standard input @@ -1166,7 +1295,9 @@ if (ret == -1) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "ERROR: dup2() failed: " << strerror(errno) << endl; +#endif } // Close all of the browser's file descriptors that we just @@ -1191,7 +1322,9 @@ } } +#if GNASH_PLUGIN_DEBUG > 1 cout << "Closed " << closed << " files." << endl; +#endif /* @@ -1199,6 +1332,7 @@ */ +#if GNASH_PLUGIN_DEBUG > 1 cout << "Starting process: "; for (int i = 0; argv[i] != 0; ++i) @@ -1206,6 +1340,7 @@ cout << argv[i] << " "; } cout << endl; +#endif /* For debugging the plugin (GNASH_OPTIONS=waitforgdb) @@ -1257,7 +1392,9 @@ if (!NPVARIANT_IS_OBJECT(vDoc)) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "Can't get window object" << endl; +#endif return NULL; } @@ -1269,7 +1406,9 @@ NPN_ReleaseObject(npDoc); if (!NPVARIANT_IS_OBJECT(vLoc)) { +#if GNASH_PLUGIN_DEBUG > 1 cout <<"Can't get window.location object" << endl; +#endif return NULL; } NPObject* npLoc = NPVARIANT_TO_OBJECT(vLoc); @@ -1280,7 +1419,9 @@ NPN_ReleaseObject(npLoc); if (!NPVARIANT_IS_STRING(vProp)) { +#if GNASH_PLUGIN_DEBUG > 1 cout << "Can't get window.location.href object" << endl; +#endif return NULL; } const NPString& propValue = NPVARIANT_TO_STRING(vProp);