summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorcallum <none@none>2012-02-10 14:02:09 -0800
committercallum <none@none>2012-02-10 14:02:09 -0800
commit6c3d44449032e386c2b4163c3635f1fe6934e5d7 (patch)
treed44ea235c3a3f78a2e232d9aea4892bdc6026954 /indra
parented137f40d137dd78d0ec916ca91814cf5534a9f6 (diff)
EXP-1889 FIX As a Second Life viewer developer, I would like a tool that helps me find memory leaks.
Diffstat (limited to 'indra')
-rw-r--r--indra/cmake/VisualLeakDetector.cmake15
-rw-r--r--indra/newview/CMakeLists.txt1
-rw-r--r--indra/newview/app_settings/settings.xml35
-rw-r--r--indra/newview/llappviewerwin32.cpp12
-rw-r--r--indra/newview/llviewermenu.cpp47
-rw-r--r--indra/newview/skins/default/xui/en/menu_viewer.xml10
6 files changed, 106 insertions, 14 deletions
diff --git a/indra/cmake/VisualLeakDetector.cmake b/indra/cmake/VisualLeakDetector.cmake
new file mode 100644
index 0000000000..d3ba554e46
--- /dev/null
+++ b/indra/cmake/VisualLeakDetector.cmake
@@ -0,0 +1,15 @@
+# -*- cmake -*-
+
+if (VIEWER)
+
+ set(INCLUDE_VLD_CMAKE OFF CACHE BOOL "Build the Windows viewer with Visual Leak Detector turned on or off")
+
+ if (INCLUDE_VLD_CMAKE)
+
+ if (WINDOWS)
+ add_definitions(-DINCLUDE_VLD=1)
+ endif (WINDOWS)
+
+ endif (INCLUDE_VLD_CMAKE)
+
+endif (VIEWER)
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 69bf1f15a1..66361c8fbf 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -41,6 +41,7 @@ include(UnixInstall)
include(LLKDU)
include(ViewerMiscLibs)
include(LLLogin)
+include(VisualLeakDetector)
include(GLOD)
include(CMakeCopyIfDifferent)
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index ee8c15752b..caeaf71484 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9619,18 +9619,29 @@
<key>Value</key>
<integer>1</integer>
</map>
- <key>ShowConsoleWindow</key>
- <map>
- <key>Comment</key>
- <string>Show log in separate OS window</string>
- <key>Persist</key>
- <integer>1</integer>
- <key>Type</key>
- <string>Boolean</string>
- <key>Value</key>
- <integer>0</integer>
- </map>
- <key>NavBarShowCoordinates</key>
+ <key>ShowConsoleWindow</key>
+ <map>
+ <key>Comment</key>
+ <string>Show log in separate OS window</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>0</integer>
+ </map>
+ <key>EnableVisualLeakDetector</key>
+ <map>
+ <key>Comment</key>
+ <string>EnableVisualLeakDetector</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>0</integer>
+ </map>
+ <key>NavBarShowCoordinates</key>
<map>
<key>Comment</key>
<string>Show coordinates in navigation bar</string>
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index 6931b55c4c..bad60a9757 100644
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -26,6 +26,10 @@
#include "llviewerprecompiledheaders.h"
+#ifdef INCLUDE_VLD
+#include "vld.h"
+#endif
+
#include "llappviewerwin32.h"
#include "llmemtype.h"
@@ -105,6 +109,14 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
+#ifdef INCLUDE_VLD
+ // only works for debug builds (hard coded into vld.h)
+ #ifdef _DEBUG
+ // start with Visual Leak Detector turned off
+ VLDGlobalDisable();
+ #endif // _DEBUG
+#endif // INCLUDE_VLD
+
LLMemType mt1(LLMemType::MTYPE_STARTUP);
const S32 MAX_HEAPS = 255;
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 12aed8f448..37cf916423 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -25,6 +25,11 @@
*/
#include "llviewerprecompiledheaders.h"
+
+#ifdef INCLUDE_VLD
+#include "vld.h"
+#endif
+
#include "llviewermenu.h"
// linden library includes
@@ -214,7 +219,7 @@ void near_sit_down_point(BOOL success, void *);
void velocity_interpolate( void* );
-
+void handle_visual_leak_detector_toggle(void*);
void handle_rebake_textures(void*);
BOOL check_admin_override(void*);
void handle_admin_override_toggle(void*);
@@ -2018,6 +2023,15 @@ class LLAdvancedToggleViewAdminOptions : public view_listener_t
}
};
+class LLAdvancedToggleVisualLeakDetector : public view_listener_t
+{
+ bool handleEvent(const LLSD& userdata)
+ {
+ handle_visual_leak_detector_toggle(NULL);
+ return true;
+ }
+};
+
class LLAdvancedCheckViewAdminOptions : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
@@ -3444,6 +3458,35 @@ void handle_admin_override_toggle(void*)
show_debug_menus();
}
+void handle_visual_leak_detector_toggle(void*)
+{
+ static bool vld_enabled = false;
+
+ if ( vld_enabled )
+ {
+#ifdef INCLUDE_VLD
+ // only works for debug builds (hard coded into vld.h)
+#ifdef _DEBUG
+ // start with Visual Leak Detector turned off
+ VLDDisable();
+#endif // _DEBUG
+#endif // INCLUDE_VLD
+ vld_enabled = false;
+ }
+ else
+ {
+#ifdef INCLUDE_VLD
+ // only works for debug builds (hard coded into vld.h)
+ #ifdef _DEBUG
+ // start with Visual Leak Detector turned off
+ VLDEnable();
+ #endif // _DEBUG
+#endif // INCLUDE_VLD
+
+ vld_enabled = true;
+ };
+}
+
void handle_god_mode(void*)
{
gAgent.requestEnterGodMode();
@@ -8237,6 +8280,8 @@ void initialize_menus()
view_listener_t::addMenu(new LLAdvancedEnableViewAdminOptions(), "Advanced.EnableViewAdminOptions");
view_listener_t::addMenu(new LLAdvancedToggleViewAdminOptions(), "Advanced.ToggleViewAdminOptions");
view_listener_t::addMenu(new LLAdvancedCheckViewAdminOptions(), "Advanced.CheckViewAdminOptions");
+ view_listener_t::addMenu(new LLAdvancedToggleVisualLeakDetector(), "Advanced.ToggleVisualLeakDetector");
+
view_listener_t::addMenu(new LLAdvancedRequestAdminStatus(), "Advanced.RequestAdminStatus");
view_listener_t::addMenu(new LLAdvancedLeaveAdminStatus(), "Advanced.LeaveAdminStatus");
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index cd8550b00d..6443e432fe 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -3261,7 +3261,15 @@
<menu_item_call.on_click
function="Advanced.CompressImage" />
</menu_item_call>
- <menu_item_check
+
+ <menu_item_call
+ label="Enable Visual Leak Detector"
+ name="Enable Visual Leak Detector">
+ <menu_item_call.on_click
+ function="Advanced.ToggleVisualLeakDetector" />
+ </menu_item_call>
+
+ <menu_item_check
label="Output Debug Minidump"
name="Output Debug Minidump">
<menu_item_check.on_check