dessie linden avatar dessie linden committed 0a7a6fd Merge

reconciled .hgtags

Comments (0)

Files changed (73)

 54fd44ac92e4c61435ea33effe093a3527e18d98 2.7.1-start
 0c4d0c24278074f219e5a32e72b449e78301d11b DRTVWR-61_2.7.1-beta1
 0c4d0c24278074f219e5a32e72b449e78301d11b 2.7.1-beta1
+a9abb9633a266c8d2fe62411cfd1c86d32da72bf DRTVWR-60_2.7.1-release
+a9abb9633a266c8d2fe62411cfd1c86d32da72bf 2.7.1-release
 9f79a6ed8fdcd2f3dac33ea6b3236eeb278dccfe 2.7.2-start
 e0dc8b741eaa27dcdfbc9e956bb2579b954d15eb DRTVWR-63_2.7.2-beta1
 e0dc8b741eaa27dcdfbc9e956bb2579b954d15eb 2.7.2-beta1
 6af10678de4736222b2c3f7e010e984fb5b327de 2.7.4-start
 be963a4eef635542f9617d7f5fd22ba48fb71958 DRTVWR-67_2.7.4-beta1
 be963a4eef635542f9617d7f5fd22ba48fb71958 2.7.4-beta1
+057f319dd8eccdf63a54d99686c68cdcb31b6abc DRTVWR-66_2.7.4-release
+057f319dd8eccdf63a54d99686c68cdcb31b6abc 2.7.4-release
 a9abb9633a266c8d2fe62411cfd1c86d32da72bf DRTVWR-60_2.7.1-release
 be963a4eef635542f9617d7f5fd22ba48fb71958 DRTVWR-67_2.7.4-beta1
 be963a4eef635542f9617d7f5fd22ba48fb71958 2.7.4-beta1
 19a498fa62570f352d7d246f17e3c81cc1d82d8b 2.7.5-start
 09984bfa6cae17e0f72d02b75c1b7393c65eecfc DRTVWR-69_2.7.5-beta1
 09984bfa6cae17e0f72d02b75c1b7393c65eecfc 2.7.5-beta1
+e1ed60913230dd64269a7f7fc52cbc6004f6d52c 2.8.0-start
+502f6a5deca9365ddae57db4f1e30172668e171e 2.8.1-start
 e1ed60913230dd64269a7f7fc52cbc6004f6d52c DRTVWR-71_2.8.0-beta1
 e1ed60913230dd64269a7f7fc52cbc6004f6d52c 2.8.0-beta1

doc/contributions.txt

 	SNOW-570
 	SNOW-572
 	SNOW-575
+	STORM-1315
 	VWR-3321
 	VWR-3336
 	VWR-3903
 Alexandrea Fride
     STORM-255
 	STORM-960
+	STORM-1459
 Alissa Sabre
 	VWR-81
 	VWR-83
 	OPEN-29
 	OPEN-39
 	OPEN-39
+	OPEN-99
 	SNOW-278
 	SNOW-503
 	SNOW-510
 	STORM-899
 	STORM-1273
 	STORM-1462
+	STORM-1459
 Kage Pixel
 	VWR-11
 Ken March
 	STORM-1019
 	STORM-1095
 	STORM-1128
+	STORM-1459
 	VWR-2488
 	VWR-9557
 	VWR-10579
 	VWR-24420
 	STORM-956
 	STORM-1147
+	STORM-1325
 Thraxis Epsilon
 	SVC-371
 	VWR-383

indra/cmake/00-Common.cmake

     add_definitions(-fvisibility=hidden)
     # don't catch SIGCHLD in our base application class for the viewer - some of our 3rd party libs may need their *own* SIGCHLD handler to work.  Sigh!  The viewer doesn't need to catch SIGCHLD anyway.
     add_definitions(-DLL_IGNORE_SIGCHLD)
-    add_definitions(-march=pentium4 -mfpmath=sse)
+    if (WORD_SIZE EQUAL 32)
+      add_definitions(-march=pentium4)
+    endif (WORD_SIZE EQUAL 32)
+    add_definitions(-mfpmath=sse)
     #add_definitions(-ftree-vectorize) # THIS CRASHES GCC 3.1-3.2
     if (NOT STANDALONE)
       # this stops us requiring a really recent glibc at runtime

indra/linux_crash_logger/linux_crash_logger.cpp

  * $/LicenseInfo$
  */
 
+#include "linden_common.h"
 #include "llcrashloggerlinux.h"
 
 int main(int argc, char **argv)
 {
+	llinfos << "Starting crash reporter." << llendl;
+
 	LLCrashLoggerLinux app;
 	app.parseCommandOptions(argc, argv);
-	app.init();
+
+	if (! app.init())
+	{
+		llwarns << "Unable to initialize application." << llendl;
+		return 1;
+	}
+
 	app.mainLoop();
 	app.cleanup();
+	llinfos << "Crash reporter finished normally." << llendl;
 	return 0;
 }
-
-

indra/linux_crash_logger/llcrashloggerlinux.cpp

 
 #include "linden_common.h"
 
-#include "boost/tokenizer.hpp"
-
 #include "indra_constants.h"	// CRASH_BEHAVIOR_ASK, CRASH_SETTING_NAME
 #include "llerror.h"
 #include "llfile.h"

indra/llcommon/indra_constants.h

 const S32 MAP_SIM_PRELUDE 			= 0x00020000;
 
 // Crash reporter behavior
-const char* const CRASH_SETTINGS_FILE = "settings_crash_behavior.xml";
-const char* const CRASH_BEHAVIOR_SETTING = "CrashSubmitBehavior";
 const S32 CRASH_BEHAVIOR_ASK = 0;
 const S32 CRASH_BEHAVIOR_ALWAYS_SEND = 1;
 const S32 CRASH_BEHAVIOR_NEVER_SEND = 2;

indra/llcommon/llsys.cpp

 /** 
  * @file llsys.cpp
- * @brief Impelementation of the basic system query functions.
+ * @brief Implementation of the basic system query functions.
  *
  * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  * Second Life Viewer Source Code
  * $/LicenseInfo$
  */
 
+#if LL_WINDOWS
+#pragma warning (disable : 4355) // 'this' used in initializer list: yes, intentionally
+#endif
+
 #include "linden_common.h"
 
 #include "llsys.h"
 #endif
 
 #include "llprocessor.h"
+#include "llerrorcontrol.h"
+#include "llevents.h"
+#include "lltimer.h"
+#include "llsdserialize.h"
+#include "llsdutil.h"
+#include <boost/bind.hpp>
+#include <boost/circular_buffer.hpp>
+#include <boost/regex.hpp>
+#include <boost/foreach.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/range.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/type_traits/is_integral.hpp>
+#include <boost/type_traits/is_float.hpp>
+
+using namespace llsd;
 
 #if LL_WINDOWS
 #	define WIN32_LEAN_AND_MEAN
 #	include <winsock2.h>
 #	include <windows.h>
+#   include <psapi.h>               // GetPerformanceInfo() et al.
 #elif LL_DARWIN
 #	include <errno.h>
 #	include <sys/sysctl.h>
 #	include <sys/utsname.h>
 #	include <stdint.h>
 #	include <Carbon/Carbon.h>
+#   include <sys/wait.h>
+#   include <string.h>
+#   include <stdexcept>
 #elif LL_LINUX
 #	include <errno.h>
 #	include <sys/utsname.h>
 #	include <unistd.h>
 #	include <sys/sysinfo.h>
+#   include <stdexcept>
 const char MEMINFO_FILE[] = "/proc/meminfo";
 #elif LL_SOLARIS
 #	include <stdio.h>
 static const S32 CPUINFO_BUFFER_SIZE = 16383;
 LLCPUInfo gSysCPU;
 
+// Don't log memory info any more often than this. It also serves as our
+// framerate sample size.
+static const F32 MEM_INFO_THROTTLE = 20;
+// Sliding window of samples. We intentionally limit the length of time we
+// remember "the slowest" framerate because framerate is very slow at login.
+// If we only triggered FrameWatcher logging when the session framerate
+// dropped below the login framerate, we'd have very little additional data.
+static const F32 MEM_INFO_WINDOW = 10*60;
+
 #if LL_WINDOWS
 #ifndef DLLVERSIONINFO
 typedef struct _DllVersionInfo
 	s << "->mCPUString:  " << mCPUString << std::endl;
 }
 
+// Helper class for LLMemoryInfo: accumulate stats in the form we store for
+// LLMemoryInfo::getStatsMap().
+class Stats
+{
+public:
+	Stats():
+		mStats(LLSD::emptyMap())
+	{}
+
+	// Store every integer type as LLSD::Integer.
+	template <class T>
+	void add(const LLSD::String& name, const T& value,
+			 typename boost::enable_if<boost::is_integral<T> >::type* = 0)
+	{
+		mStats[name] = LLSD::Integer(value);
+	}
+
+	// Store every floating-point type as LLSD::Real.
+	template <class T>
+	void add(const LLSD::String& name, const T& value,
+			 typename boost::enable_if<boost::is_float<T> >::type* = 0)
+	{
+		mStats[name] = LLSD::Real(value);
+	}
+
+	// Hope that LLSD::Date values are sufficiently unambiguous.
+	void add(const LLSD::String& name, const LLSD::Date& value)
+	{
+		mStats[name] = value;
+	}
+
+	LLSD get() const { return mStats; }
+
+private:
+	LLSD mStats;
+};
+
+// Wrap boost::regex_match() with a function that doesn't throw.
+template <typename S, typename M, typename R>
+static bool regex_match_no_exc(const S& string, M& match, const R& regex)
+{
+    try
+    {
+        return boost::regex_match(string, match, regex);
+    }
+    catch (const std::runtime_error& e)
+    {
+        LL_WARNS("LLMemoryInfo") << "error matching with '" << regex.str() << "': "
+                                 << e.what() << ":\n'" << string << "'" << LL_ENDL;
+        return false;
+    }
+}
+
+// Wrap boost::regex_search() with a function that doesn't throw.
+template <typename S, typename M, typename R>
+static bool regex_search_no_exc(const S& string, M& match, const R& regex)
+{
+    try
+    {
+        return boost::regex_search(string, match, regex);
+    }
+    catch (const std::runtime_error& e)
+    {
+        LL_WARNS("LLMemoryInfo") << "error searching with '" << regex.str() << "': "
+                                 << e.what() << ":\n'" << string << "'" << LL_ENDL;
+        return false;
+    }
+}
+
 LLMemoryInfo::LLMemoryInfo()
 {
+	refresh();
 }
 
 #if LL_WINDOWS
 U32 LLMemoryInfo::getPhysicalMemoryKB() const
 {
 #if LL_WINDOWS
-	MEMORYSTATUSEX state;
-	state.dwLength = sizeof(state);
-	GlobalMemoryStatusEx(&state);
-
-	return LLMemoryAdjustKBResult((U32)(state.ullTotalPhys >> 10));
+	return LLMemoryAdjustKBResult(mStatsMap["Total Physical KB"].asInteger());
 
 #elif LL_DARWIN
 	// This might work on Linux as well.  Someone check...
 void LLMemoryInfo::getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb)
 {
 #if LL_WINDOWS
-	MEMORYSTATUSEX state;
-	state.dwLength = sizeof(state);
-	GlobalMemoryStatusEx(&state);
+	// Sigh, this shouldn't be a static method, then we wouldn't have to
+	// reload this data separately from refresh()
+	LLSD statsMap(loadStatsMap());
 
-	avail_physical_mem_kb = (U32)(state.ullAvailPhys/1024) ;
-	avail_virtual_mem_kb = (U32)(state.ullAvailVirtual/1024) ;
+	avail_physical_mem_kb = statsMap["Avail Physical KB"].asInteger();
+	avail_virtual_mem_kb  = statsMap["Avail Virtual KB"].asInteger();
+
+#elif LL_DARWIN
+	// mStatsMap is derived from vm_stat, look for (e.g.) "kb free":
+	// $ vm_stat
+	// Mach Virtual Memory Statistics: (page size of 4096 bytes)
+	// Pages free:                   462078.
+	// Pages active:                 142010.
+	// Pages inactive:               220007.
+	// Pages wired down:             159552.
+	// "Translation faults":      220825184.
+	// Pages copy-on-write:         2104153.
+	// Pages zero filled:         167034876.
+	// Pages reactivated:             65153.
+	// Pageins:                     2097212.
+	// Pageouts:                      41759.
+	// Object cache: 841598 hits of 7629869 lookups (11% hit rate)
+	avail_physical_mem_kb = -1 ;
+	avail_virtual_mem_kb = -1 ;
+
+#elif LL_LINUX
+	// mStatsMap is derived from MEMINFO_FILE:
+	// $ cat /proc/meminfo
+	// MemTotal:        4108424 kB
+	// MemFree:         1244064 kB
+	// Buffers:           85164 kB
+	// Cached:          1990264 kB
+	// SwapCached:            0 kB
+	// Active:          1176648 kB
+	// Inactive:        1427532 kB
+	// Active(anon):     529152 kB
+	// Inactive(anon):    15924 kB
+	// Active(file):     647496 kB
+	// Inactive(file):  1411608 kB
+	// Unevictable:          16 kB
+	// Mlocked:              16 kB
+	// HighTotal:       3266316 kB
+	// HighFree:         721308 kB
+	// LowTotal:         842108 kB
+	// LowFree:          522756 kB
+	// SwapTotal:       6384632 kB
+	// SwapFree:        6384632 kB
+	// Dirty:                28 kB
+	// Writeback:             0 kB
+	// AnonPages:        528820 kB
+	// Mapped:            89472 kB
+	// Shmem:             16324 kB
+	// Slab:             159624 kB
+	// SReclaimable:     145168 kB
+	// SUnreclaim:        14456 kB
+	// KernelStack:        2560 kB
+	// PageTables:         5560 kB
+	// NFS_Unstable:          0 kB
+	// Bounce:                0 kB
+	// WritebackTmp:          0 kB
+	// CommitLimit:     8438844 kB
+	// Committed_AS:    1271596 kB
+	// VmallocTotal:     122880 kB
+	// VmallocUsed:       65252 kB
+	// VmallocChunk:      52356 kB
+	// HardwareCorrupted:     0 kB
+	// HugePages_Total:       0
+	// HugePages_Free:        0
+	// HugePages_Rsvd:        0
+	// HugePages_Surp:        0
+	// Hugepagesize:       2048 kB
+	// DirectMap4k:      434168 kB
+	// DirectMap2M:      477184 kB
+	// (could also run 'free', but easier to read a file than run a program)
+	avail_physical_mem_kb = -1 ;
+	avail_virtual_mem_kb = -1 ;
 
 #else
 	//do not know how to collect available memory info for other systems.
 
 void LLMemoryInfo::stream(std::ostream& s) const
 {
+	// We want these memory stats to be easy to grep from the log, along with
+	// the timestamp. So preface each line with the timestamp and a
+	// distinctive marker. Without that, we'd have to search the log for the
+	// introducer line, then read subsequent lines, etc...
+	std::string pfx(LLError::utcTime() + " <mem> ");
+
+	// Max key length
+	size_t key_width(0);
+	BOOST_FOREACH(const MapEntry& pair, inMap(mStatsMap))
+	{
+		size_t len(pair.first.length());
+		if (len > key_width)
+		{
+			key_width = len;
+		}
+	}
+
+	// Now stream stats
+	BOOST_FOREACH(const MapEntry& pair, inMap(mStatsMap))
+	{
+		s << pfx << std::setw(key_width+1) << (pair.first + ':') << ' ';
+		LLSD value(pair.second);
+		if (value.isInteger())
+			s << std::setw(12) << value.asInteger();
+		else if (value.isReal())
+			s << std::fixed << std::setprecision(1) << value.asReal();
+		else if (value.isDate())
+			value.asDate().toStream(s);
+		else
+			s << value;           // just use default LLSD formatting
+		s << std::endl;
+	}
+}
+
+LLSD LLMemoryInfo::getStatsMap() const
+{
+	return mStatsMap;
+}
+
+LLMemoryInfo& LLMemoryInfo::refresh()
+{
+	mStatsMap = loadStatsMap();
+
+	LL_DEBUGS("LLMemoryInfo") << "Populated mStatsMap:\n";
+	LLSDSerialize::toPrettyXML(mStatsMap, LL_CONT);
+	LL_ENDL;
+
+	return *this;
+}
+
+LLSD LLMemoryInfo::loadStatsMap()
+{
+	// This implementation is derived from stream() code (as of 2011-06-29).
+	Stats stats;
+
+	// associate timestamp for analysis over time
+	stats.add("timestamp", LLDate::now());
+
 #if LL_WINDOWS
 	MEMORYSTATUSEX state;
 	state.dwLength = sizeof(state);
 	GlobalMemoryStatusEx(&state);
 
-	s << "Percent Memory use: " << (U32)state.dwMemoryLoad << '%' << std::endl;
-	s << "Total Physical KB:  " << (U32)(state.ullTotalPhys/1024) << std::endl;
-	s << "Avail Physical KB:  " << (U32)(state.ullAvailPhys/1024) << std::endl;
-	s << "Total page KB:      " << (U32)(state.ullTotalPageFile/1024) << std::endl;
-	s << "Avail page KB:      " << (U32)(state.ullAvailPageFile/1024) << std::endl;
-	s << "Total Virtual KB:   " << (U32)(state.ullTotalVirtual/1024) << std::endl;
-	s << "Avail Virtual KB:   " << (U32)(state.ullAvailVirtual/1024) << std::endl;
+	stats.add("Percent Memory use", state.dwMemoryLoad);
+	stats.add("Total Physical KB",  state.ullTotalPhys/1024);
+	stats.add("Avail Physical KB",  state.ullAvailPhys/1024);
+	stats.add("Total page KB",      state.ullTotalPageFile/1024);
+	stats.add("Avail page KB",      state.ullAvailPageFile/1024);
+	stats.add("Total Virtual KB",   state.ullTotalVirtual/1024);
+	stats.add("Avail Virtual KB",   state.ullAvailVirtual/1024);
+
+	PERFORMANCE_INFORMATION perf;
+	perf.cb = sizeof(perf);
+	GetPerformanceInfo(&perf, sizeof(perf));
+
+	SIZE_T pagekb(perf.PageSize/1024);
+	stats.add("CommitTotal KB",     perf.CommitTotal * pagekb);
+	stats.add("CommitLimit KB",     perf.CommitLimit * pagekb);
+	stats.add("CommitPeak KB",      perf.CommitPeak * pagekb);
+	stats.add("PhysicalTotal KB",   perf.PhysicalTotal * pagekb);
+	stats.add("PhysicalAvail KB",   perf.PhysicalAvailable * pagekb);
+	stats.add("SystemCache KB",     perf.SystemCache * pagekb);
+	stats.add("KernelTotal KB",     perf.KernelTotal * pagekb);
+	stats.add("KernelPaged KB",     perf.KernelPaged * pagekb);
+	stats.add("KernelNonpaged KB",  perf.KernelNonpaged * pagekb);
+	stats.add("PageSize KB",        pagekb);
+	stats.add("HandleCount",        perf.HandleCount);
+	stats.add("ProcessCount",       perf.ProcessCount);
+	stats.add("ThreadCount",        perf.ThreadCount);
+
+	PROCESS_MEMORY_COUNTERS_EX pmem;
+	pmem.cb = sizeof(pmem);
+	// GetProcessMemoryInfo() is documented to accept either
+	// PROCESS_MEMORY_COUNTERS* or PROCESS_MEMORY_COUNTERS_EX*, presumably
+	// using the redundant size info to distinguish. But its prototype
+	// specifically accepts PROCESS_MEMORY_COUNTERS*, and since this is a
+	// classic-C API, PROCESS_MEMORY_COUNTERS_EX isn't a subclass. Cast the
+	// pointer.
+	GetProcessMemoryInfo(GetCurrentProcess(), PPROCESS_MEMORY_COUNTERS(&pmem), sizeof(pmem));
+
+	stats.add("Page Fault Count",              pmem.PageFaultCount);
+	stats.add("PeakWorkingSetSize KB",         pmem.PeakWorkingSetSize/1024);
+	stats.add("WorkingSetSize KB",             pmem.WorkingSetSize/1024);
+	stats.add("QutaPeakPagedPoolUsage KB",     pmem.QuotaPeakPagedPoolUsage/1024);
+	stats.add("QuotaPagedPoolUsage KB",        pmem.QuotaPagedPoolUsage/1024);
+	stats.add("QuotaPeakNonPagedPoolUsage KB", pmem.QuotaPeakNonPagedPoolUsage/1024);
+	stats.add("QuotaNonPagedPoolUsage KB",     pmem.QuotaNonPagedPoolUsage/1024);
+	stats.add("PagefileUsage KB",              pmem.PagefileUsage/1024);
+	stats.add("PeakPagefileUsage KB",          pmem.PeakPagefileUsage/1024);
+	stats.add("PrivateUsage KB",               pmem.PrivateUsage/1024);
+
 #elif LL_DARWIN
 	uint64_t phys = 0;
 
 	size_t len = sizeof(phys);	
 	
-	if(sysctlbyname("hw.memsize", &phys, &len, NULL, 0) == 0)
+	if (sysctlbyname("hw.memsize", &phys, &len, NULL, 0) == 0)
 	{
-		s << "Total Physical KB:  " << phys/1024 << std::endl;
+		stats.add("Total Physical KB", phys/1024);
 	}
 	else
 	{
-		s << "Unable to collect memory information";
+		LL_WARNS("LLMemoryInfo") << "Unable to collect hw.memsize memory information" << LL_ENDL;
 	}
+
+	FILE* pout = popen("vm_stat 2>&1", "r");
+	if (! pout)                     // popen() couldn't run vm_stat
+	{
+		// Save errno right away.
+		int popen_errno(errno);
+		LL_WARNS("LLMemoryInfo") << "Unable to collect vm_stat memory information: ";
+		char buffer[256];
+		if (0 == strerror_r(popen_errno, buffer, sizeof(buffer)))
+		{
+			LL_CONT << buffer;
+		}
+		else
+		{
+			LL_CONT << "errno " << popen_errno;
+		}
+		LL_CONT << LL_ENDL;
+	}
+	else                            // popen() launched vm_stat
+	{
+		// Mach Virtual Memory Statistics: (page size of 4096 bytes)
+		// Pages free:					 462078.
+		// Pages active:				 142010.
+		// Pages inactive:				 220007.
+		// Pages wired down:			 159552.
+		// "Translation faults":	  220825184.
+		// Pages copy-on-write:			2104153.
+		// Pages zero filled:		  167034876.
+		// Pages reactivated:			  65153.
+		// Pageins:						2097212.
+		// Pageouts:					  41759.
+		// Object cache: 841598 hits of 7629869 lookups (11% hit rate)
+
+		// Intentionally don't pass the boost::no_except flag. These
+		// boost::regex objects are constructed with string literals, so they
+		// should be valid every time. If they become invalid, we WANT an
+		// exception, hopefully even before the dev checks in.
+		boost::regex pagesize_rx("\\(page size of ([0-9]+) bytes\\)");
+		boost::regex stat_rx("(.+): +([0-9]+)\\.");
+		boost::regex cache_rx("Object cache: ([0-9]+) hits of ([0-9]+) lookups "
+							  "\\(([0-9]+)% hit rate\\)");
+		boost::cmatch matched;
+		LLSD::Integer pagesizekb(4096/1024);
+
+		// Here 'pout' is vm_stat's stdout. Search it for relevant data.
+		char line[100];
+		line[sizeof(line)-1] = '\0';
+		while (fgets(line, sizeof(line)-1, pout))
+		{
+			size_t linelen(strlen(line));
+			// Truncate any trailing newline
+			if (line[linelen - 1] == '\n')
+			{
+				line[--linelen] = '\0';
+			}
+			LL_DEBUGS("LLMemoryInfo") << line << LL_ENDL;
+			if (regex_search_no_exc(line, matched, pagesize_rx))
+			{
+				// "Mach Virtual Memory Statistics: (page size of 4096 bytes)"
+				std::string pagesize_str(matched[1].first, matched[1].second);
+				try
+				{
+					// Reasonable to assume that pagesize will always be a
+					// multiple of 1Kb?
+					pagesizekb = boost::lexical_cast<LLSD::Integer>(pagesize_str)/1024;
+				}
+				catch (const boost::bad_lexical_cast&)
+				{
+					LL_WARNS("LLMemoryInfo") << "couldn't parse '" << pagesize_str
+											 << "' in vm_stat line: " << line << LL_ENDL;
+					continue;
+				}
+				stats.add("page size", pagesizekb);
+			}
+			else if (regex_match_no_exc(line, matched, stat_rx))
+			{
+				// e.g. "Pages free:					 462078."
+				// Strip double-quotes off certain statistic names
+				const char *key_begin(matched[1].first), *key_end(matched[1].second);
+				if (key_begin[0] == '"' && key_end[-1] == '"')
+				{
+					++key_begin;
+					--key_end;
+				}
+				LLSD::String key(key_begin, key_end);
+				LLSD::String value_str(matched[2].first, matched[2].second);
+				LLSD::Integer value(0);
+				try
+				{
+					value = boost::lexical_cast<LLSD::Integer>(value_str);
+				}
+				catch (const boost::bad_lexical_cast&)
+				{
+					LL_WARNS("LLMemoryInfo") << "couldn't parse '" << value_str
+											 << "' in vm_stat line: " << line << LL_ENDL;
+					continue;
+				}
+				// Store this statistic.
+				stats.add(key, value);
+				// Is this in units of pages? If so, convert to Kb.
+				static const LLSD::String pages("Pages ");
+				if (key.substr(0, pages.length()) == pages)
+				{
+					// Synthesize a new key with kb in place of Pages
+					LLSD::String kbkey("kb ");
+					kbkey.append(key.substr(pages.length()));
+					stats.add(kbkey, value * pagesizekb);
+				}
+			}
+			else if (regex_match_no_exc(line, matched, cache_rx))
+			{
+				// e.g. "Object cache: 841598 hits of 7629869 lookups (11% hit rate)"
+				static const char* cache_keys[] = { "cache hits", "cache lookups", "cache hit%" };
+				std::vector<LLSD::Integer> cache_values;
+				for (size_t i = 0; i < (sizeof(cache_keys)/sizeof(cache_keys[0])); ++i)
+				{
+					LLSD::String value_str(matched[i+1].first, matched[i+1].second);
+					LLSD::Integer value(0);
+					try
+					{
+						value = boost::lexical_cast<LLSD::Integer>(value_str);
+					}
+					catch (boost::bad_lexical_cast&)
+					{
+						LL_WARNS("LLMemoryInfo") << "couldn't parse '" << value_str
+												 << "' in vm_stat line: " << line << LL_ENDL;
+						continue;
+					}
+					stats.add(cache_keys[i], value);
+				}
+			}
+			else
+			{
+				LL_WARNS("LLMemoryInfo") << "unrecognized vm_stat line: " << line << LL_ENDL;
+			}
+		}
+		int status(pclose(pout));
+		if (status == -1)           // pclose() couldn't retrieve rc
+		{
+			// Save errno right away.
+			int pclose_errno(errno);
+			// The ECHILD error happens so frequently that unless filtered,
+			// the warning below spams the log file. This is too bad, because
+			// sometimes the logic above fails to produce any output derived
+			// from vm_stat, but we've been unable to observe any specific
+			// error indicating the problem.
+			if (pclose_errno != ECHILD)
+			{
+				LL_WARNS("LLMemoryInfo") << "Unable to obtain vm_stat termination code: ";
+				char buffer[256];
+				if (0 == strerror_r(pclose_errno, buffer, sizeof(buffer)))
+				{
+					LL_CONT << buffer;
+				}
+				else
+				{
+					LL_CONT << "errno " << pclose_errno;
+				}
+				LL_CONT << LL_ENDL;
+			}
+		}
+		else                        // pclose() retrieved rc; analyze
+		{
+			if (WIFEXITED(status))
+			{
+				int rc(WEXITSTATUS(status));
+				if (rc != 0)
+				{
+					LL_WARNS("LLMemoryInfo") << "vm_stat terminated with rc " << rc << LL_ENDL;
+				}
+			}
+			else if (WIFSIGNALED(status))
+			{
+				LL_WARNS("LLMemoryInfo") << "vm_stat terminated by signal " << WTERMSIG(status)
+										 << LL_ENDL;
+			}
+		}
+	}
+
 #elif LL_SOLARIS
-        U64 phys = 0;
+	U64 phys = 0;
 
-        phys = (U64)(sysconf(_SC_PHYS_PAGES)) * (U64)(sysconf(_SC_PAGESIZE)/1024);
+	phys = (U64)(sysconf(_SC_PHYS_PAGES)) * (U64)(sysconf(_SC_PAGESIZE)/1024);
 
-        s << "Total Physical KB:  " << phys << std::endl;
-#else
-	// *NOTE: This works on linux. What will it do on other systems?
-	LLFILE* meminfo = LLFile::fopen(MEMINFO_FILE,"rb");
-	if(meminfo)
+	stats.add("Total Physical KB", phys);
+
+#elif LL_LINUX
+	std::ifstream meminfo(MEMINFO_FILE);
+	if (meminfo.is_open())
 	{
-		char line[MAX_STRING];		/* Flawfinder: ignore */
-		memset(line, 0, MAX_STRING);
-		while(fgets(line, MAX_STRING, meminfo))
+		// MemTotal:		4108424 kB
+		// MemFree:			1244064 kB
+		// Buffers:			  85164 kB
+		// Cached:			1990264 kB
+		// SwapCached:			  0 kB
+		// Active:			1176648 kB
+		// Inactive:		1427532 kB
+		// ...
+		// VmallocTotal:	 122880 kB
+		// VmallocUsed:		  65252 kB
+		// VmallocChunk:	  52356 kB
+		// HardwareCorrupted:	  0 kB
+		// HugePages_Total:		  0
+		// HugePages_Free:		  0
+		// HugePages_Rsvd:		  0
+		// HugePages_Surp:		  0
+		// Hugepagesize:	   2048 kB
+		// DirectMap4k:		 434168 kB
+		// DirectMap2M:		 477184 kB
+
+		// Intentionally don't pass the boost::no_except flag. This
+		// boost::regex object is constructed with a string literal, so it
+		// should be valid every time. If it becomes invalid, we WANT an
+		// exception, hopefully even before the dev checks in.
+		boost::regex stat_rx("(.+): +([0-9]+)( kB)?");
+		boost::smatch matched;
+
+		std::string line;
+		while (std::getline(meminfo, line))
 		{
-			line[strlen(line)-1] = ' ';		 /*Flawfinder: ignore*/
-			s << line;
+			LL_DEBUGS("LLMemoryInfo") << line << LL_ENDL;
+			if (regex_match_no_exc(line, matched, stat_rx))
+			{
+				// e.g. "MemTotal:		4108424 kB"
+				LLSD::String key(matched[1].first, matched[1].second);
+				LLSD::String value_str(matched[2].first, matched[2].second);
+				LLSD::Integer value(0);
+				try
+				{
+					value = boost::lexical_cast<LLSD::Integer>(value_str);
+				}
+				catch (const boost::bad_lexical_cast&)
+				{
+					LL_WARNS("LLMemoryInfo") << "couldn't parse '" << value_str
+											 << "' in " << MEMINFO_FILE << " line: "
+											 << line << LL_ENDL;
+					continue;
+				}
+				// Store this statistic.
+				stats.add(key, value);
+			}
+			else
+			{
+				LL_WARNS("LLMemoryInfo") << "unrecognized " << MEMINFO_FILE << " line: "
+										 << line << LL_ENDL;
+			}
 		}
-		fclose(meminfo);
 	}
 	else
 	{
-		s << "Unable to collect memory information";
+		LL_WARNS("LLMemoryInfo") << "Unable to collect memory information" << LL_ENDL;
 	}
+
+#else
+	LL_WARNS("LLMemoryInfo") << "Unknown system; unable to collect memory information" << LL_ENDL;
+
 #endif
+
+	return stats.get();
 }
 
 std::ostream& operator<<(std::ostream& s, const LLOSInfo& info)
 	return s;
 }
 
+class FrameWatcher
+{
+public:
+    FrameWatcher():
+        // Hooking onto the "mainloop" event pump gets us one call per frame.
+        mConnection(LLEventPumps::instance()
+                    .obtain("mainloop")
+                    .listen("FrameWatcher", boost::bind(&FrameWatcher::tick, this, _1))),
+        // Initializing mSampleStart to an invalid timestamp alerts us to skip
+        // trying to compute framerate on the first call.
+        mSampleStart(-1),
+        // Initializing mSampleEnd to 0 ensures that we treat the first call
+        // as the completion of a sample window.
+        mSampleEnd(0),
+        mFrames(0),
+        // Both MEM_INFO_WINDOW and MEM_INFO_THROTTLE are in seconds. We need
+        // the number of integer MEM_INFO_THROTTLE sample slots that will fit
+        // in MEM_INFO_WINDOW. Round up.
+        mSamples(int((MEM_INFO_WINDOW / MEM_INFO_THROTTLE) + 0.7)),
+        // Initializing to F32_MAX means that the first real frame will become
+        // the slowest ever, which sounds like a good idea.
+        mSlowest(F32_MAX)
+    {}
+
+    bool tick(const LLSD&)
+    {
+        F32 timestamp(mTimer.getElapsedTimeF32());
+
+        // Count this frame in the interval just completed.
+        ++mFrames;
+
+        // Have we finished a sample window yet?
+        if (timestamp < mSampleEnd)
+        {
+            // no, just keep waiting
+            return false;
+        }
+
+        // Set up for next sample window. Capture values for previous frame in
+        // local variables and reset data members.
+        U32 frames(mFrames);
+        F32 sampleStart(mSampleStart);
+        // No frames yet in next window
+        mFrames = 0;
+        // which starts right now
+        mSampleStart = timestamp;
+        // and ends MEM_INFO_THROTTLE seconds in the future
+        mSampleEnd = mSampleStart + MEM_INFO_THROTTLE;
+
+        // On the very first call, that's all we can do, no framerate
+        // computation is possible.
+        if (sampleStart < 0)
+        {
+            return false;
+        }
+
+        // How long did this actually take? As framerate slows, the duration
+        // of the frame we just finished could push us WELL beyond our desired
+        // sample window size.
+        F32 elapsed(timestamp - sampleStart);
+        F32 framerate(frames/elapsed);
+
+        // Remember previous slowest framerate because we're just about to
+        // update it.
+        F32 slowest(mSlowest);
+        // Remember previous number of samples.
+        boost::circular_buffer<F32>::size_type prevSize(mSamples.size());
+
+        // Capture new framerate in our samples buffer. Once the buffer is
+        // full (after MEM_INFO_WINDOW seconds), this will displace the oldest
+        // sample. ("So they all rolled over, and one fell out...")
+        mSamples.push_back(framerate);
+
+        // Calculate the new minimum framerate. I know of no way to update a
+        // rolling minimum without ever rescanning the buffer. But since there
+        // are only a few tens of items in this buffer, rescanning it is
+        // probably cheaper (and certainly easier to reason about) than
+        // attempting to optimize away some of the scans.
+        mSlowest = framerate;       // pick an arbitrary entry to start
+        for (boost::circular_buffer<F32>::const_iterator si(mSamples.begin()), send(mSamples.end());
+             si != send; ++si)
+        {
+            if (*si < mSlowest)
+            {
+                mSlowest = *si;
+            }
+        }
+
+        // We're especially interested in memory as framerate drops. Only log
+        // when framerate drops below the slowest framerate we remember.
+        // (Should always be true for the end of the very first sample
+        // window.)
+        if (framerate >= slowest)
+        {
+            return false;
+        }
+        // Congratulations, we've hit a new low.  :-P
+
+        LL_INFOS("FrameWatcher") << ' ';
+        if (! prevSize)
+        {
+            LL_CONT << "initial framerate ";
+        }
+        else
+        {
+            LL_CONT << "slowest framerate for last " << int(prevSize * MEM_INFO_THROTTLE)
+                    << " seconds ";
+        }
+        LL_CONT << std::fixed << std::setprecision(1) << framerate << '\n'
+                << LLMemoryInfo() << LL_ENDL;
+
+        return false;
+    }
+
+private:
+    // Storing the connection in an LLTempBoundListener ensures it will be
+    // disconnected when we're destroyed.
+    LLTempBoundListener mConnection;
+    // Track elapsed time
+    LLTimer mTimer;
+    // Some of what you see here is in fact redundant with functionality you
+    // can get from LLTimer. Unfortunately the LLTimer API is missing the
+    // feature we need: has at least the stated interval elapsed, and if so,
+    // exactly how long has passed? So we have to do it by hand, sigh.
+    // Time at start, end of sample window
+    F32 mSampleStart, mSampleEnd;
+    // Frames this sample window
+    U32 mFrames;
+    // Sliding window of framerate samples
+    boost::circular_buffer<F32> mSamples;
+    // Slowest framerate in mSamples
+    F32 mSlowest;
+};
+
+// Need an instance of FrameWatcher before it does any good
+static FrameWatcher sFrameWatcher;
+
 BOOL gunzip_file(const std::string& srcfile, const std::string& dstfile)
 {
 	std::string tmpfile;

indra/llcommon/llsys.h

 //  llinfos << info << llendl;
 //
 
+#include "llsd.h"
 #include <iosfwd>
 #include <string>
 
 
 	//get the available memory infomation in KiloBytes.
 	static void getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb);
+
+	// Retrieve a map of memory statistics. The keys of the map are platform-
+	// dependent. The values are in kilobytes to try to avoid integer overflow.
+	LLSD getStatsMap() const;
+
+	// Re-fetch memory data (as reported by stream() and getStatsMap()) from the
+	// system. Normally this is fetched at construction time. Return (*this)
+	// to permit usage of the form:
+	// @code
+	// LLMemoryInfo info;
+	// ...
+	// info.refresh().getStatsMap();
+	// @endcode
+	LLMemoryInfo& refresh();
+
+private:
+	// set mStatsMap
+	static LLSD loadStatsMap();
+
+	// Memory stats for getStatsMap().
+	LLSD mStatsMap;
 };
 
 

indra/llcommon/llversionviewer.h

 
 const S32 LL_VERSION_MAJOR = 2;
 const S32 LL_VERSION_MINOR = 8;
-const S32 LL_VERSION_PATCH = 0;
+const S32 LL_VERSION_PATCH = 1;
 const S32 LL_VERSION_BUILD = 0;
 
 const char * const LL_CHANNEL = "Second Life Developer";

indra/llcrashlogger/llcrashlogger.cpp

 #include "llcrashlogger.h"
 #include "linden_common.h"
 #include "llstring.h"
-#include "indra_constants.h"	// CRASH_BEHAVIOR_ASK, CRASH_SETTING_NAME
+#include "indra_constants.h"	// CRASH_BEHAVIOR_...
 #include "llerror.h"
+#include "llerrorcontrol.h"
 #include "lltimer.h"
 #include "lldir.h"
+#include "llfile.h"
 #include "llsdserialize.h"
 #include "lliopipe.h"
 #include "llpumpio.h"
 
 	virtual void error(U32 status, const std::string& reason)
 	{
-		gBreak = true;		
+		gBreak = true;
 	}
 
 	virtual void result(const LLSD& content)
 	}
 };
 
-bool LLCrashLoggerText::mainLoop()
-{
-	std::cout << "Entering main loop" << std::endl;
-	sendCrashLogs();
-	return true;	
-}
-
-void LLCrashLoggerText::updateApplication(const std::string& message)
-{
-	LLCrashLogger::updateApplication(message);
-	std::cout << message << std::endl;
-}
-
 LLCrashLogger::LLCrashLogger() :
-	mCrashBehavior(CRASH_BEHAVIOR_ASK),
+	mCrashBehavior(CRASH_BEHAVIOR_ALWAYS_SEND),
 	mCrashInPreviousExec(false),
 	mCrashSettings("CrashSettings"),
 	mSentCrashLogs(false),
 	return mCrashInfo;
 }
 
+const char* const CRASH_SETTINGS_FILE = "settings_crash_behavior.xml";
+
 S32 LLCrashLogger::loadCrashBehaviorSetting()
 {
+	// First check user_settings (in the user's home dir)
 	std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE);
+	if (! mCrashSettings.loadFromFile(filename))
+	{
+		// Next check app_settings (in the SL program dir)
+		std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, CRASH_SETTINGS_FILE);
+		mCrashSettings.loadFromFile(filename);
+	}
 
-	mCrashSettings.loadFromFile(filename);
-		
-	S32 value = mCrashSettings.getS32(CRASH_BEHAVIOR_SETTING);
-	
-	if (value < CRASH_BEHAVIOR_ASK || CRASH_BEHAVIOR_NEVER_SEND < value) return CRASH_BEHAVIOR_ASK;
+	// If we didn't load any files above, this will return the default
+	S32 value = mCrashSettings.getS32("CrashSubmitBehavior");
 
-	return value;
+	// Whatever value we got, make sure it's valid
+	switch (value)
+	{
+	case CRASH_BEHAVIOR_NEVER_SEND:
+		return CRASH_BEHAVIOR_NEVER_SEND;
+	case CRASH_BEHAVIOR_ALWAYS_SEND:
+		return CRASH_BEHAVIOR_ALWAYS_SEND;
+	}
+
+	return CRASH_BEHAVIOR_ASK;
 }
 
 bool LLCrashLogger::saveCrashBehaviorSetting(S32 crash_behavior)
 {
-	if (crash_behavior != CRASH_BEHAVIOR_ASK && crash_behavior != CRASH_BEHAVIOR_ALWAYS_SEND) return false;
+	switch (crash_behavior)
+	{
+	case CRASH_BEHAVIOR_ASK:
+	case CRASH_BEHAVIOR_NEVER_SEND:
+	case CRASH_BEHAVIOR_ALWAYS_SEND:
+		break;
+	default:
+		return false;
+	}
 
-	mCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, crash_behavior);
+	mCrashSettings.setS32("CrashSubmitBehavior", crash_behavior);
 	std::string filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE);
-
 	mCrashSettings.saveToFile(filename, FALSE);
 
 	return true;
 bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg, int retries, int timeout)
 {
 	gBreak = false;
-	std::string status_message;
 	for(int i = 0; i < retries; ++i)
 	{
-		status_message = llformat("%s, try %d...", msg.c_str(), i+1);
+		updateApplication(llformat("%s, try %d...", msg.c_str(), i+1));
 		LLHTTPClient::post(host, data, new LLCrashLoggerResponder(), timeout);
 		while(!gBreak)
 		{
-			updateApplication(status_message);
+			updateApplication(); // No new message, just pump the IO
 		}
 		if(gSent)
 		{
 	updateApplication("Sending reports...");
 
 	std::string dump_path = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,
-															   "SecondLifeCrashReport");
+														   "SecondLifeCrashReport");
 	std::string report_file = dump_path + ".log";
 
 	std::ofstream out_file(report_file.c_str());
 {
 	gServicePump->pump();
     gServicePump->callback();
+	if (!message.empty()) llinfos << message << llendl;
 }
 
 bool LLCrashLogger::init()
 	// We assume that all the logs we're looking for reside on the current drive
 	gDirUtilp->initAppDirs("SecondLife");
 
+	LLError::initForApplication(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, ""));
+
 	// Default to the product name "Second Life" (this is overridden by the -name argument)
 	mProductName = "Second Life";
+
+	// Rename current log file to ".old"
+	std::string old_log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "crashreport.log.old");
+	std::string log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "crashreport.log");
+	LLFile::rename(log_file.c_str(), old_log_file.c_str());
+
+	// Set the log file to crashreport.log
+	LLError::logToFile(log_file);
 	
-	mCrashSettings.declareS32(CRASH_BEHAVIOR_SETTING, CRASH_BEHAVIOR_ASK, "Controls behavior when viewer crashes "
-		"(0 = ask before sending crash report, 1 = always send crash report, 2 = never send crash report)");
+	mCrashSettings.declareS32("CrashSubmitBehavior", CRASH_BEHAVIOR_ALWAYS_SEND,
+							  "Controls behavior when viewer crashes "
+							  "(0 = ask before sending crash report, "
+							  "1 = always send crash report, "
+							  "2 = never send crash report)");
 
-	llinfos << "Loading crash behavior setting" << llendl;
-	mCrashBehavior = loadCrashBehaviorSetting();
+	// llinfos << "Loading crash behavior setting" << llendl;
+	// mCrashBehavior = loadCrashBehaviorSetting();
 
 	// If user doesn't want to send, bail out
 	if (mCrashBehavior == CRASH_BEHAVIOR_NEVER_SEND)
 	gServicePump->prime(gAPRPoolp);
 	LLHTTPClient::setPump(*gServicePump);
 
-	//If we've opened the crash logger, assume we can delete the marker file if it exists	
+	//If we've opened the crash logger, assume we can delete the marker file if it exists
 	if( gDirUtilp )
 	{
-		std::string marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"SecondLife.exec_marker");
+		std::string marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,
+																 "SecondLife.exec_marker");
 		LLAPRFile::remove( marker_file );
 	}
 	

indra/llcrashlogger/llcrashlogger.h

 	bool mSentCrashLogs;
 };
 
-class LLCrashLoggerText : public LLCrashLogger
-{
-public:
-	LLCrashLoggerText(void) {}
-	~LLCrashLoggerText(void) {}
-
-	virtual bool mainLoop();
-	virtual void updateApplication(const std::string& message = LLStringUtil::null);
-};
-
-
 #endif //LLCRASHLOGGER_H

indra/llmath/CMakeLists.txt

 set(llmath_SOURCE_FILES
     llbbox.cpp
     llbboxlocal.cpp
+    llcalc.cpp
+    llcalcparser.cpp
     llcamera.cpp
     llcoordframe.cpp
     llline.cpp
     coordframe.h
     llbbox.h
     llbboxlocal.h
+    llcalc.h
+    llcalcparser.h
     llcamera.h
     llcoord.h
     llcoordframe.h

indra/llmath/llcalc.cpp

+/*
+ *  LLCalc.cpp
+ *  SecondLife
+ *
+ *  Created by Aimee Walton on 28/09/2008.
+ *  Copyright 2008 Aimee Walton.
+ *
+ */
+
+#include "linden_common.h"
+
+#include "llcalc.h"
+
+#include "llcalcparser.h"
+#include "llmath.h"
+
+
+// Variable names for use in the build floater
+const char* LLCalc::X_POS = "PX";
+const char* LLCalc::Y_POS = "PY";
+const char* LLCalc::Z_POS = "PZ";
+const char* LLCalc::X_SCALE = "SX";
+const char* LLCalc::Y_SCALE = "SY";
+const char* LLCalc::Z_SCALE = "SZ";
+const char* LLCalc::X_ROT = "RX";
+const char* LLCalc::Y_ROT = "RY";
+const char* LLCalc::Z_ROT = "RZ";
+const char* LLCalc::HOLLOW = "HLW";
+const char* LLCalc::CUT_BEGIN = "CB";
+const char* LLCalc::CUT_END = "CE";
+const char* LLCalc::PATH_BEGIN = "PB";
+const char* LLCalc::PATH_END = "PE";
+const char* LLCalc::TWIST_BEGIN = "TB";
+const char* LLCalc::TWIST_END = "TE";
+const char* LLCalc::X_SHEAR = "SHX";
+const char* LLCalc::Y_SHEAR = "SHY";
+const char* LLCalc::X_TAPER = "TPX";
+const char* LLCalc::Y_TAPER = "TPY";
+const char* LLCalc::RADIUS_OFFSET = "ROF";
+const char* LLCalc::REVOLUTIONS = "REV";
+const char* LLCalc::SKEW = "SKW";
+const char* LLCalc::X_HOLE = "HLX";
+const char* LLCalc::Y_HOLE = "HLY";
+const char* LLCalc::TEX_U_SCALE = "TSU";
+const char* LLCalc::TEX_V_SCALE = "TSV";
+const char* LLCalc::TEX_U_OFFSET = "TOU";
+const char* LLCalc::TEX_V_OFFSET = "TOV";
+const char* LLCalc::TEX_ROTATION = "TROT";
+const char* LLCalc::TEX_TRANSPARENCY = "TRNS";
+const char* LLCalc::TEX_GLOW = "GLOW";
+
+
+LLCalc* LLCalc::sInstance = NULL;
+
+LLCalc::LLCalc() : mLastErrorPos(0)
+{
+	// Init table of constants
+	mConstants["PI"] = F_PI;
+	mConstants["TWO_PI"] = F_TWO_PI;
+	mConstants["PI_BY_TWO"] = F_PI_BY_TWO;
+	mConstants["SQRT_TWO_PI"] = F_SQRT_TWO_PI;
+	mConstants["SQRT2"] = F_SQRT2;
+	mConstants["SQRT3"] = F_SQRT3;
+	mConstants["DEG_TO_RAD"] = DEG_TO_RAD;
+	mConstants["RAD_TO_DEG"] = RAD_TO_DEG;
+	mConstants["GRAVITY"] = GRAVITY;
+}
+
+LLCalc::~LLCalc()
+{
+}
+
+//static
+void LLCalc::cleanUp()
+{
+	delete sInstance;
+	sInstance = NULL;
+}
+
+//static
+LLCalc* LLCalc::getInstance()
+{
+    if (!sInstance)	sInstance = new LLCalc();
+	return sInstance;
+}
+
+void LLCalc::setVar(const std::string& name, const F32& value)
+{
+	mVariables[name] = value;
+}
+
+void LLCalc::clearVar(const std::string& name)
+{
+	mVariables.erase(name);
+}
+
+void LLCalc::clearAllVariables()
+{
+	mVariables.clear();
+}
+
+/*
+void LLCalc::updateVariables(LLSD& vars)
+{
+	LLSD::map_iterator cIt = vars.beginMap();
+	for(; cIt != vars.endMap(); cIt++)
+	{
+		setVar(cIt->first, (F32)(LLSD::Real)cIt->second);
+	}
+}
+*/
+
+bool LLCalc::evalString(const std::string& expression, F32& result)
+{
+	std::string expr_upper = expression;
+	LLStringUtil::toUpper(expr_upper);
+	
+	LLCalcParser calc(result, &mConstants, &mVariables);
+
+	mLastErrorPos = 0;
+	std::string::iterator start = expr_upper.begin();
+ 	parse_info<std::string::iterator> info;
+	
+	try
+	{
+		info = parse(start, expr_upper.end(), calc, space_p);
+		lldebugs << "Math expression: " << expression << " = " << result << llendl;
+	}
+	catch(parser_error<std::string, std::string::iterator> &e)
+	{
+		mLastErrorPos = e.where - expr_upper.begin();
+		
+		llinfos << "Calc parser exception: " << e.descriptor << " at " << mLastErrorPos << " in expression: " << expression << llendl;
+		return false;
+	}
+	
+	if (!info.full)
+	{
+		mLastErrorPos = info.stop - expr_upper.begin();
+		llinfos << "Unhandled syntax error at " << mLastErrorPos << " in expression: " << expression << llendl;
+		return false;
+	}
+	
+	return true;
+}

indra/llmath/llcalc.h

+/*
+ *  LLCalc.h
+ *  SecondLife
+ *
+ *  Created by Aimee Walton on 28/09/2008.
+ *  Copyright 2008 Aimee Walton.
+ *
+ */
+
+#ifndef LL_CALC_H
+#define LL_CALC_H
+
+#include <map>
+#include <string>
+
+class LLCalc
+{
+public:
+	LLCalc();
+	~LLCalc();
+
+	// Variable name constants
+	static const char* X_POS;
+	static const char* Y_POS;
+	static const char* Z_POS;
+	static const char* X_SCALE;
+	static const char* Y_SCALE;
+	static const char* Z_SCALE;
+	static const char* X_ROT;
+	static const char* Y_ROT;
+	static const char* Z_ROT;
+	static const char* HOLLOW;
+	static const char* CUT_BEGIN;
+	static const char* CUT_END;
+	static const char* PATH_BEGIN;
+	static const char* PATH_END;
+	static const char* TWIST_BEGIN;
+	static const char* TWIST_END;
+	static const char* X_SHEAR;
+	static const char* Y_SHEAR;
+	static const char* X_TAPER;
+	static const char* Y_TAPER;
+	static const char* RADIUS_OFFSET;
+	static const char* REVOLUTIONS;
+	static const char* SKEW;
+	static const char* X_HOLE;
+	static const char* Y_HOLE;
+	static const char* TEX_U_SCALE;
+	static const char* TEX_V_SCALE;
+	static const char* TEX_U_OFFSET;
+	static const char* TEX_V_OFFSET;
+	static const char* TEX_ROTATION;
+	static const char* TEX_TRANSPARENCY;
+	static const char* TEX_GLOW;
+
+	void	setVar(const std::string& name, const F32& value);
+	void	clearVar(const std::string& name);
+	void	clearAllVariables();
+//	void	updateVariables(LLSD& vars);
+
+	bool	evalString(const std::string& expression, F32& result);
+	std::string::size_type	getLastErrorPos()	{ return mLastErrorPos; }
+	
+	static LLCalc* getInstance();
+	static void cleanUp();
+
+	typedef	std::map<std::string, F32> calc_map_t;
+	
+private:
+	std::string::size_type	mLastErrorPos;
+	
+	calc_map_t	mConstants;
+	calc_map_t	mVariables;
+	
+	// *TODO: Add support for storing user defined variables, and stored functions.
+	//	Will need UI work, and a means to save them between sessions.
+//	calc_map_t mUserVariables;
+	
+	// "There shall be only one"
+	static LLCalc*	sInstance;
+};
+
+#endif // LL_CALC_H

indra/llmath/llcalcparser.cpp

+/*
+ *  LLCalcParser.cpp
+ *  SecondLife
+ *
+ *  Created by Aimee Walton on 28/09/2008.
+ *  Copyright 2008 Aimee Walton.
+ *
+ */
+
+#include "linden_common.h"
+
+#include "llcalcparser.h"
+using namespace boost::spirit::classic;
+
+F32 LLCalcParser::lookup(const std::string::iterator& start, const std::string::iterator& end) const
+{
+	LLCalc::calc_map_t::iterator iter;
+
+	std::string name(start, end);
+	
+	if (mConstants)
+	{
+		iter = mConstants->find(name);
+		if (iter != mConstants->end())
+		{
+			return (*iter).second;
+		}
+	}
+	else
+	{
+		// This should never happen!
+		throw_(end, std::string("Missing constants table"));
+	}
+	
+	if (mVariables)
+	{
+		iter = mVariables->find(name);
+		if (iter != mVariables->end())
+		{
+			return (*iter).second;
+		}
+	}
+	
+	throw_(end, std::string("Unknown symbol " + name));
+	return 0.f;
+}

indra/llmath/llcalcparser.h

+/*
+ *  LLCalcParser.h
+ *  SecondLife
+ *
+ *  Created by Aimee Walton on 28/09/2008.
+ *  Copyright 2008 Aimee Walton.
+ *
+ */
+
+#ifndef LL_CALCPARSER_H
+#define LL_CALCPARSER_H
+
+#include <boost/spirit/include/classic_attribute.hpp>
+#include <boost/spirit/include/classic_core.hpp>
+#include <boost/spirit/include/classic_error_handling.hpp>
+#include <boost/spirit/include/classic_position_iterator.hpp>
+#include <boost/spirit/include/phoenix1_binders.hpp>
+#include <boost/spirit/include/classic_symbols.hpp>
+using namespace boost::spirit::classic;
+
+#include "llcalc.h"
+#include "llmath.h"
+
+struct LLCalcParser : grammar<LLCalcParser>
+{
+	LLCalcParser(F32& result, LLCalc::calc_map_t* constants, LLCalc::calc_map_t* vars) :
+		mResult(result), mConstants(constants), mVariables(vars) {};
+	
+	struct value_closure : closure<value_closure, F32>
+	{
+		member1 value;
+	};
+	
+	template <typename ScannerT>
+	struct definition
+	{
+		// Rule declarations
+		rule<ScannerT> statement, identifier;
+		rule<ScannerT, value_closure::context_t> expression, term,
+			power, 
+			unary_expr, 
+			factor, 
+			unary_func, 
+			binary_func,
+			group;
+
+		// start() should return the starting symbol
+		rule<ScannerT> const& start() const { return statement; }
+		
+		definition(LLCalcParser const& self)
+		{
+			using namespace phoenix;
+			
+			assertion<std::string> assert_domain("Domain error");
+//			assertion<std::string> assert_symbol("Unknown symbol");
+			assertion<std::string> assert_syntax("Syntax error");
+			
+			identifier =
+				lexeme_d[(alpha_p | '_') >> *(alnum_p | '_')]
+			;
+			
+			group =
+				'(' >> expression[group.value = arg1] >> assert_syntax(ch_p(')'))
+			;
+
+			unary_func =
+				((str_p("SIN") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_sin)(self,arg1)]) |
+				 (str_p("COS") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_cos)(self,arg1)]) |
+				 (str_p("TAN") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_tan)(self,arg1)]) |
+				 (str_p("ASIN") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_asin)(self,arg1)]) |
+				 (str_p("ACOS") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_acos)(self,arg1)]) |
+				 (str_p("ATAN") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_atan)(self,arg1)]) |
+				 (str_p("SQRT") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_sqrt)(self,arg1)]) |
+				 (str_p("LOG") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_log)(self,arg1)]) |
+				 (str_p("EXP") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_exp)(self,arg1)]) |
+				 (str_p("ABS") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_fabs)(self,arg1)]) |
+				 (str_p("FLR") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_floor)(self,arg1)]) |
+				 (str_p("CEIL") >> '(' >> expression[unary_func.value = bind(&LLCalcParser::_ceil)(self,arg1)])
+				) >> assert_syntax(ch_p(')'))
+			;
+			
+			binary_func =
+				((str_p("ATAN2") >> '(' >> expression[binary_func.value = arg1] >> ',' >>
+				  expression[binary_func.value = bind(&LLCalcParser::_atan2)(self, binary_func.value, arg1)]) |
+				 (str_p("MIN") >> '(' >> expression[binary_func.value = arg1] >> ',' >> 
+				  expression[binary_func.value = bind(&LLCalcParser::_min)(self, binary_func.value, arg1)]) |
+				 (str_p("MAX") >> '(' >> expression[binary_func.value = arg1] >> ',' >> 
+				  expression[binary_func.value = bind(&LLCalcParser::_max)(self, binary_func.value, arg1)])
+				) >> assert_syntax(ch_p(')'))
+			;
+			
+			// *TODO: Localisation of the decimal point?
+			// Problem, LLLineEditor::postvalidateFloat accepts a comma when appropriate
+			// for the current locale. However to do that here could clash with using
+			// the comma as a separator when passing arguments to functions.
+			factor =
+				(ureal_p[factor.value = arg1] |
+				 group[factor.value = arg1] |
+				 unary_func[factor.value = arg1] |
+				 binary_func[factor.value = arg1] |
+				 // Lookup throws an Unknown Symbol error if it is unknown, while this works fine,
+				 // would be "neater" to handle symbol lookup from here with an assertive parser.
+//				 constants_p[factor.value = arg1]|
+				 identifier[factor.value = bind(&LLCalcParser::lookup)(self, arg1, arg2)]
+				) >>
+				// Detect and throw math errors.
+				assert_domain(eps_p(bind(&LLCalcParser::checkNaN)(self, factor.value)))
+			;
+
+			unary_expr =
+				!ch_p('+') >> factor[unary_expr.value = arg1] |
+				'-' >> factor[unary_expr.value = -arg1]
+			;
+			
+			power =
+				unary_expr[power.value = arg1] >>
+				*('^' >> assert_syntax(unary_expr[power.value = bind(&powf)(power.value, arg1)]))
+			;
+			
+			term =
+				power[term.value = arg1] >>
+				*(('*' >> assert_syntax(power[term.value *= arg1])) |
+				  ('/' >> assert_syntax(power[term.value /= arg1])) |
+				  ('%' >> assert_syntax(power[term.value = bind(&fmodf)(term.value, arg1)]))
+				)
+			;
+			
+			expression =
+				assert_syntax(term[expression.value = arg1]) >>
+				*(('+' >> assert_syntax(term[expression.value += arg1])) |
+				  ('-' >> assert_syntax(term[expression.value -= arg1]))
+				)
+			;
+
+			statement =
+				!ch_p('=') >> ( expression )[var(self.mResult) = arg1] >> (end_p)
+			;
+		}
+	};
+	
+private:
+	// Member functions for semantic actions
+	F32	lookup(const std::string::iterator&, const std::string::iterator&) const;
+	F32 _min(const F32& a, const F32& b) const { return llmin(a, b); }
+	F32 _max(const F32& a, const F32& b) const { return llmax(a, b); }
+	
+	bool checkNaN(const F32& a) const { return !llisnan(a); }
+	
+	//FIX* non ambigious function fix making SIN() work for calc -Cryogenic Blitz
+	F32 _sin(const F32& a) const { return sin(DEG_TO_RAD * a); }
+	F32 _cos(const F32& a) const { return cos(DEG_TO_RAD * a); }
+	F32 _tan(const F32& a) const { return tan(DEG_TO_RAD * a); }
+	F32 _asin(const F32& a) const { return asin(a * RAD_TO_DEG); }
+	F32 _acos(const F32& a) const { return acos(a * RAD_TO_DEG); }
+	F32 _atan(const F32& a) const { return atan(a * RAD_TO_DEG); }
+	F32 _sqrt(const F32& a) const { return sqrt(a); }
+	F32 _log(const F32& a) const { return log(a); }
+	F32 _exp(const F32& a) const { return exp(a); }
+	F32 _fabs(const F32& a) const { return fabs(a); }
+	F32 _floor(const F32& a) const { return llfloor(a); }
+	F32 _ceil(const F32& a) const { return llceil(a); }
+
+	F32 _atan2(const F32& a,const F32& b) const { return atan2(a,b); }
+
+
+
+	LLCalc::calc_map_t* mConstants;
+	LLCalc::calc_map_t* mVariables;
+//	LLCalc::calc_map_t* mUserVariables;
+	
+	F32&		mResult;
+};
+
+#endif // LL_CALCPARSER_H

indra/llui/lllineeditor.cpp

 #include "llgl.h"
 #include "lltimer.h"
 
+#include "llcalc.h"
 //#include "llclipboard.h"
 #include "llcontrol.h"
 #include "llbutton.h"
 	mIgnoreTab( p.ignore_tab ),
 	mDrawAsterixes( p.is_password ),
 	mSelectAllonFocusReceived( p.select_on_focus ),
+	mSelectAllonCommit( TRUE ),
 	mPassDelete(FALSE),
 	mReadOnly(FALSE),
 	mBgImage( p.background_image ),
 
 	setControlValue(getValue());
 	LLUICtrl::onCommit();
-	selectAll();
+
+	// Selection on commit needs to be turned off when evaluating maths
+	// expressions, to allow indication of the error position
+	if (mSelectAllonCommit) selectAll();
 }
 
 // Returns TRUE if user changed value at all
 	return success;
 }
 
+BOOL LLLineEditor::evaluateFloat()
+{
+	bool success;
+	F32 result = 0.f;
+	std::string expr = getText();
+	LLStringUtil::toUpper(expr);
+
+	success = LLCalc::getInstance()->evalString(expr, result);
+
+	if (!success)
+	{
+		// Move the cursor to near the error on failure
+		setCursor(LLCalc::getInstance()->getLastErrorPos());
+		// *TODO: Translated error message indicating the type of error? Select error text?
+	}
+	else
+	{
+		// Replace the expression with the result
+		std::string result_str = llformat("%f",result);
+		setText(result_str);
+		selectAll();
+	}
+
+	return success;
+}
+
 void LLLineEditor::onMouseCaptureLost()
 {
 	endSelection();

indra/llui/lllineeditor.h

 	void			deleteSelection();
 
 	void			setSelectAllonFocusReceived(BOOL b);
+	void			setSelectAllonCommit(BOOL b) { mSelectAllonCommit = b; }
 	
 	typedef boost::function<void (LLLineEditor* caller, void* user_data)> callback_t;
 	void			setKeystrokeCallback(callback_t callback, void* user_data);
 	static BOOL		postvalidateFloat(const std::string &str);
 
 	bool			prevalidateInput(const LLWString& wstr);
+	BOOL			evaluateFloat();
 
 	// line history support:
 	void			setEnableLineHistory( BOOL enabled ) { mHaveHistory = enabled; } // switches line history on or off 
 	BOOL		mDrawAsterixes;
 
 	BOOL		mSelectAllonFocusReceived;
+	BOOL		mSelectAllonCommit;
 	BOOL		mPassDelete;
 
 	BOOL		mReadOnly;

indra/llui/llspinctrl.cpp

 #include "llresmgr.h"
 #include "lluictrlfactory.h"
 
-const U32 MAX_STRING_LENGTH = 32;
+const U32 MAX_STRING_LENGTH = 255;
 
 static LLDefaultChildRegistry::Register<LLSpinCtrl> r2("spinner");
 
 	params.max_length.bytes(MAX_STRING_LENGTH);
 	params.commit_callback.function((boost::bind(&LLSpinCtrl::onEditorCommit, this, _2)));
 	
-	if( mPrecision>0 )//should accept float numbers
-	{
-		params.prevalidate_callback(&LLTextValidate::validateFloat);
-	}
-	else //should accept int numbers
-	{
-		params.prevalidate_callback(&LLTextValidate::validateInt);
-	}
+	//*NOTE: allow entering of any chars for LLCalc, proper input will be evaluated on commit
 	
 	params.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM);
 	mEditor = LLUICtrlFactory::create<LLLineEditor> (params);
 	// than when it doesn't.  Instead, if you always have to double click to select all the text, 
 	// it's easier to understand
 	//mEditor->setSelectAllonFocusReceived(TRUE);
+	mEditor->setSelectAllonCommit(FALSE);
 	addChild(mEditor);
 
 	updateEditor();
 {
 	BOOL success = FALSE;
 	
-	std::string text = mEditor->getText();
-	if( LLLineEditor::postvalidateFloat( text ) )
+	if( mEditor->evaluateFloat() )
 	{
+		std::string text = mEditor->getText();
+
 		LLLocale locale(LLLocale::USER_LOCALE);
 		F32 val = (F32) atof(text.c_str());
 
 	}
 	updateEditor();
 
-	if( !success )
+	if( success )
+	{
+		updateEditor();
+	}
+	else
 	{
 		reportInvalidData();		
 	}

indra/mac_crash_logger/CrashReporter.nib/objects.xib

       <string name="bounds">414 390 434 487 </string>
     </object>
     <object class="IBCarbonStaticText" id="181">
-      <string name="title">Second Life appears to have crashed or frozen the last time it ran.&#10;&#10;This crash reporter collects information about your computer&apos;s hardware configuration, operating system, and some Second Life logs, all of which are used for debugging purposes only.&#10;&#10;In the space below, please briefly describe what you were doing or trying to do just prior to the crash. Thank you for your help!&#10;&#10;This report is NOT read by Customer Support. If you have billing or other questions, please go to: http://www.secondlife.com/support/&#10;&#10;If you don&apos;t wish to send Linden Lab a crash report, press Cancel.&#10;</string>
+      <string name="title">Second Life appears to have crashed or frozen the last time it ran.&#10;&#10;This crash reporter collects information about your computer&apos;s hardware configuration, operating system, and some Second Life logs, all of which are used for debugging purposes only.&#10;&#10;In the space below, please briefly describe what you were doing or trying to do just prior to the crash. Thank you for your help!&#10;&#10;This report is NOT read by Customer Support. If you have billing or other questions, please go to: http://www.secondlife.com/support/&#10;&#10;If you don&apos;t wish to send Linden Lab a crash report, press Don&apos;t Send.&#10;</string>
       <string name="bounds">20 20 231 487 </string>
     </object>
     <object class="IBCarbonWindow" id="166">

indra/mac_crash_logger/llcrashloggermac.cpp

 
 #include <Carbon/Carbon.h>
 #include <iostream>
-#include <sstream>
-
-#include "boost/tokenizer.hpp"
 
 #include "indra_constants.h"	// CRASH_BEHAVIOR_ASK, CRASH_SETTING_NAME
 #include "llerror.h"
 
 void LLCrashLoggerMac::updateApplication(const std::string& message)
 {
-	LLCrashLogger::updateApplication();
+	LLCrashLogger::updateApplication(message);
 }
 
 bool LLCrashLoggerMac::cleanup()

indra/mac_crash_logger/mac_crash_logger.cpp

  */
 
 #include "linden_common.h"
-
 #include "llcrashloggermac.h"
 
 int main(int argc, char **argv)
 {
-	//time(&gLaunchTime);
-	
-	llinfos << "Starting Second Life Viewer Crash Reporter" << llendl;
+	llinfos << "Starting crash reporter." << llendl;
 
 	LLCrashLoggerMac app;
 	app.parseCommandOptions(argc, argv);
-	if(!app.init())
+
+	if (! app.init())
 	{
-		return 0;
+		llwarns << "Unable to initialize application." << llendl;
+		return 1;
 	}
+
 	app.mainLoop();
-		
+	app.cleanup();
+	llinfos << "Crash reporter finished normally." << llendl;
 	return 0;
 }

indra/newview/app_settings/cmd_line.xml

     <map>
       <key>desc</key>
       <string>Set the detail level. 
-              0 - low, 1 - medium, 2 - high, 3 - ultra
-       </string>
+0 - low, 1 - medium, 2 - high, 3 - ultra</string>
       <key>count</key>
       <integer>1</integer>
     </map>
     <key>setdefault</key>
     <map>
       <key>desc</key>
-      <string> specify the value of a particular
-               configuration variable which can be
-               overridden by settings.xml
-      </string>
+      <string>specify the value of a particular configuration variable which can be overridden by settings.xml.</string>
       <key>count</key>
       <integer>2</integer>
       <!-- Special case. Mapped to settings procedurally. -->
     <key>set</key>
     <map>
       <key>desc</key>
-      <string> specify the value of a particular
-               configuration variable that
-               overrides all other settings
-      </string>
+      <string>specify the value of a particular configuration variable that overrides all other settings.</string>
       <key>count</key>
       <integer>2</integer>
       <key>compose</key>
Add a comment to this file

indra/newview/app_settings/settings.xml

File contents unchanged.

indra/newview/app_settings/settings_files.xml

           file_name="settings.xml"
           file_name_setting="ClientSettingsFile"/>
     <file name="CrashSettings"
-          file_name="settings_crash_behavior"/>
+          file_name="settings_crash_behavior.xml"
+          file_name_setting="CrashSettingsFile"/>
     <file name="Warnings"
           file_name="ignorable_dialogs.xml"
           file_name_setting="WarningSettingsFile"/>
           file_name="colors.xml"
           file_name_setting="SkinningSettingsFile"/>
   </group>
-</settings_files>
+</settings_files>

indra/newview/llagent.cpp

 // static
 void LLAgent::toggleFlying()
 {
-	LLToolPie::instance().stopClickToWalk();
+	if ( gAgent.mAutoPilot )
+	{
+		LLToolPie::instance().stopClickToWalk();
+	}
 
 	BOOL fly = !gAgent.getFlying();
 

indra/newview/llappviewer.cpp

 #include "llallocator.h"
 #include "llares.h" 
 #include "llcurl.h"
+#include "llcalc.h"
 #include "lltexturestats.h"
 #include "lltexturestats.h"
 #include "llviewerwindow.h"
 	}
 }
 
-// A settings system callback for CrashSubmitBehavior
-bool handleCrashSubmitBehaviorChanged(const LLSD& newvalue)
-{
-	S32 cb = newvalue.asInteger();
-	const S32 NEVER_SUBMIT_REPORT = 2;
-	if(cb == NEVER_SUBMIT_REPORT)
-	{
-		LLAppViewer::instance()->destroyMainloopTimeout();
-	}
-	return true;
-}
-
 // Use these strictly for things that are constructed at startup,
 // or for things that are performance critical.  JC
 static void settings_to_globals()
 // Static members.
 // The single viewer app.
 LLAppViewer* LLAppViewer::sInstance = NULL;
-
-const std::string LLAppViewer::sGlobalSettingsName = "Global"; 
-
 LLTextureCache* LLAppViewer::sTextureCache = NULL; 
 LLImageDecodeThread* LLAppViewer::sImageDecodeThread = NULL; 
 LLTextureFetch* LLAppViewer::sTextureFetch = NULL; 
 	LL_INFOS("InitInfo") << "J2C Engine is: " << LLImageJ2C::getEngineInfo() << LL_ENDL;
 	LL_INFOS("InitInfo") << "libcurl version is: " << LLCurl::getVersionString() << LL_ENDL;
 
-	// Get the single value from the crash settings file, if it exists
-	std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE);
-	gCrashSettings.loadFromFile(crash_settings_filename);
-	if(gSavedSettings.getBOOL("IgnoreAllNotifications"))
-	{
-		gCrashSettings.setS32(CRASH_BEHAVIOR_SETTING, CRASH_BEHAVIOR_ALWAYS_SEND);
-		gCrashSettings.saveToFile(crash_settings_filename, FALSE);
-	}
-	LL_INFOS("InitInfo") << "Crash settings done." << LL_ENDL ;
-
 	/////////////////////////////////////////////////
 	// OS-specific login dialogs
 	/////////////////////////////////////////////////
 	//EXT-7013 - On windows for some locale (Japanese) standard 
 	//datetime formatting functions didn't support some parameters such as "weekday".
 	//Names for days and months localized in xml are also useful for Polish locale(STORM-107).
-	std::string language = LLControlGroup::getInstance(sGlobalSettingsName)->getString("Language");
+	std::string language = gSavedSettings.getString("Language");
 	if(language == "ja" || language == "pl")
 	{
 		LLStringOps::setupWeekDaysNames(LLTrans::getString("dateTimeWeekdaysNames"));
 	// Note: this is where gLocalSpeakerMgr and gActiveSpeakerMgr used to be deleted.
 
 	LLWorldMap::getInstance()->reset(); // release any images
-	
+
+	LLCalc::cleanUp();
+
 	llinfos << "Global stuff deleted" << llendflush;
 
 	if (gAudiop)