aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorArmin Weatherwax2011-05-01 15:41:03 +0200
committerArmin Weatherwax2011-05-17 07:52:28 +0200
commit1a7e0184f81fff7126e47f50bd915790afc118a9 (patch)
treec233c3c16ccdbf68c77edfb0c49673a8bb92fcac
parentfix bug #879 context menu of line + text editors triggers select all even if ... (diff)
downloadmeta-impy-1a7e0184f81fff7126e47f50bd915790afc118a9.zip
meta-impy-1a7e0184f81fff7126e47f50bd915790afc118a9.tar.gz
meta-impy-1a7e0184f81fff7126e47f50bd915790afc118a9.tar.bz2
meta-impy-1a7e0184f81fff7126e47f50bd915790afc118a9.tar.xz
show plugin debug messages also on windows
Diffstat (limited to '')
-rwxr-xr-xlinden/indra/llplugin/llpluginclassmedia.cpp9
-rwxr-xr-xlinden/indra/llplugin/llpluginclassmedia.h5
-rwxr-xr-xlinden/indra/llplugin/llpluginprocesschild.cpp57
-rwxr-xr-xlinden/indra/llplugin/llpluginprocesschild.h6
-rw-r--r--linden/indra/newview/llviewermedia.cpp7
5 files changed, 83 insertions, 1 deletions
diff --git a/linden/indra/llplugin/llpluginclassmedia.cpp b/linden/indra/llplugin/llpluginclassmedia.cpp
index f0a44f7..31a9d1d 100755
--- a/linden/indra/llplugin/llpluginclassmedia.cpp
+++ b/linden/indra/llplugin/llpluginclassmedia.cpp
@@ -1143,6 +1143,15 @@ void LLPluginClassMedia::setBrowserUserAgent(const std::string& user_agent)
1143 sendMessage(message); 1143 sendMessage(message);
1144} 1144}
1145 1145
1146#if LL_WINDOWS
1147void LLPluginClassMedia::showConsole()
1148{
1149 LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "show_console");
1150
1151 sendMessage(message);
1152}
1153#endif
1154
1146void LLPluginClassMedia::crashPlugin() 1155void LLPluginClassMedia::crashPlugin()
1147{ 1156{
1148 LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "crash"); 1157 LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "crash");
diff --git a/linden/indra/llplugin/llpluginclassmedia.h b/linden/indra/llplugin/llpluginclassmedia.h
index 0004971..098312d 100755
--- a/linden/indra/llplugin/llpluginclassmedia.h
+++ b/linden/indra/llplugin/llpluginclassmedia.h
@@ -229,6 +229,11 @@ public:
229 std::string getMediaName() const { return mMediaName; }; 229 std::string getMediaName() const { return mMediaName; };
230 std::string getMediaDescription() const { return mMediaDescription; }; 230 std::string getMediaDescription() const { return mMediaDescription; };
231 231
232 #if LL_WINDOWS
233 //Open a debug console for this plugin.
234 void showConsole();
235 #endif
236
232 // Crash the plugin. If you use this outside of a testbed, you will be punished. 237 // Crash the plugin. If you use this outside of a testbed, you will be punished.
233 void crashPlugin(); 238 void crashPlugin();
234 239
diff --git a/linden/indra/llplugin/llpluginprocesschild.cpp b/linden/indra/llplugin/llpluginprocesschild.cpp
index 0d95cac..168236e 100755
--- a/linden/indra/llplugin/llpluginprocesschild.cpp
+++ b/linden/indra/llplugin/llpluginprocesschild.cpp
@@ -42,6 +42,14 @@
42#include "llpluginmessagepipe.h" 42#include "llpluginmessagepipe.h"
43#include "llpluginmessageclasses.h" 43#include "llpluginmessageclasses.h"
44 44
45#if LL_WINDOWS
46#include <windows.h>
47#include <fcntl.h>
48#include <io.h>
49#include <iostream>
50#include <fstream>
51#endif
52
45static const F32 HEARTBEAT_SECONDS = 1.0f; 53static const F32 HEARTBEAT_SECONDS = 1.0f;
46static const F32 PLUGIN_IDLE_SECONDS = 1.0f / 100.0f; // Each call to idle will give the plugin this much time. 54static const F32 PLUGIN_IDLE_SECONDS = 1.0f / 100.0f; // Each call to idle will give the plugin this much time.
47 55
@@ -420,6 +428,12 @@ void LLPluginProcessChild::receiveMessageRaw(const std::string &message)
420 { 428 {
421 mSleepTime = parsed.getValueReal("time"); 429 mSleepTime = parsed.getValueReal("time");
422 } 430 }
431 #if LL_WINDOWS
432 else if(message_name == "show_console")
433 {
434 createConsole();
435 }
436 #endif
423 else if(message_name == "crash") 437 else if(message_name == "crash")
424 { 438 {
425 // Crash the plugin 439 // Crash the plugin
@@ -569,3 +583,46 @@ void LLPluginProcessChild::deliverQueuedMessages()
569 } 583 }
570 } 584 }
571} 585}
586
587#if LL_WINDOWS
588void LLPluginProcessChild::createConsole()
589{
590 const S32 MAX_CONSOLE_LINES = 500;
591
592 int h_con_handle;
593 long l_std_handle;
594
595 CONSOLE_SCREEN_BUFFER_INFO coninfo;
596 FILE *fp;
597
598 // allocate a console for this app
599 AllocConsole();
600
601 // set the screen buffer to be big enough to let us scroll text
602 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
603 coninfo.dwSize.Y = MAX_CONSOLE_LINES;
604 SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
605
606 // redirect unbuffered STDOUT to the console
607 l_std_handle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
608 h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT);
609 fp = _fdopen( h_con_handle, "w" );
610 *stdout = *fp;
611 setvbuf( stdout, NULL, _IONBF, 0 );
612
613 // redirect unbuffered STDIN to the console
614 l_std_handle = (long)GetStdHandle(STD_INPUT_HANDLE);
615 h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT);
616 fp = _fdopen( h_con_handle, "r" );
617 *stdin = *fp;
618 setvbuf( stdin, NULL, _IONBF, 0 );
619
620 // redirect unbuffered STDERR to the console
621 l_std_handle = (long)GetStdHandle(STD_ERROR_HANDLE);
622 h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT);
623 fp = _fdopen( h_con_handle, "w" );
624 *stderr = *fp;
625 setvbuf( stderr, NULL, _IOFBF, 1024 ); //Assigning a buffer improves speed a LOT, esp on vista/win7
626 //_IOLBF is borked.
627}
628#endif \ No newline at end of file
diff --git a/linden/indra/llplugin/llpluginprocesschild.h b/linden/indra/llplugin/llpluginprocesschild.h
index 5d643d7..6d864bb 100755
--- a/linden/indra/llplugin/llpluginprocesschild.h
+++ b/linden/indra/llplugin/llpluginprocesschild.h
@@ -76,7 +76,11 @@ public:
76 76
77 // Inherited from LLPluginInstanceMessageListener 77 // Inherited from LLPluginInstanceMessageListener
78 /* virtual */ void receivePluginMessage(const std::string &message); 78 /* virtual */ void receivePluginMessage(const std::string &message);
79 79
80#if LL_WINDOWS
81 void createConsole();
82#endif
83
80private: 84private:
81 85
82 enum EState 86 enum EState
diff --git a/linden/indra/newview/llviewermedia.cpp b/linden/indra/newview/llviewermedia.cpp
index c228468..84fd0ba 100644
--- a/linden/indra/newview/llviewermedia.cpp
+++ b/linden/indra/newview/llviewermedia.cpp
@@ -547,6 +547,13 @@ LLPluginClassMedia* LLViewerMediaImpl::newSourceFromMediaType(std::string media_
547 547
548 if (media_source->init(launcher_name, plugin_name, gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins"))) 548 if (media_source->init(launcher_name, plugin_name, gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins")))
549 { 549 {
550 #if LL_WINDOWS
551 if (gSavedSettings.getBOOL("ShowConsoleWindow"))
552 {
553 media_source->showConsole();
554 }
555 #endif
556
550 return media_source; 557 return media_source;
551 } 558 }
552 else 559 else