summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorLeyla Farazha <leyla@lindenlab.com>2010-06-21 11:24:33 -0700
committerLeyla Farazha <leyla@lindenlab.com>2010-06-21 11:24:33 -0700
commitb088449517c7070ba15b6e344dbc7a1145f64dac (patch)
tree66562b72586081f59fa74e9baaedf560ff49ffd5 /indra/llcommon
parent4bf8a0c7fca329ce1d0c58bc3ebf86fbbe544d40 (diff)
parentbb95afc9e1246abfc3656b31b33d1e5ae1dc85f2 (diff)
Merge from ssh://hg.lindenlab.com/dessie/viewer-release
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llapp.cpp47
-rw-r--r--indra/llcommon/llfasttimer_class.cpp3
2 files changed, 46 insertions, 4 deletions
diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp
index eedec0b24e..0447ca93f5 100644
--- a/indra/llcommon/llapp.cpp
+++ b/indra/llcommon/llapp.cpp
@@ -32,6 +32,12 @@
#include <cstdlib>
+#ifdef LL_DARWIN
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/sysctl.h>
+#endif
+
#include "linden_common.h"
#include "llapp.h"
@@ -306,7 +312,42 @@ void LLApp::setupErrorHandling()
setup_signals();
// Add google breakpad exception handler configured for Darwin/Linux.
- if(mExceptionHandler == 0)
+ bool installHandler = true;
+#ifdef LL_DARWIN
+ // For the special case of Darwin, we do not want to install the handler if
+ // the process is being debugged as the app will exit with value ABRT (6) if
+ // we do. Unfortunately, the code below which performs that test relies on
+ // the structure kinfo_proc which has been tagged by apple as an unstable
+ // API. We disable this test for shipping versions to avoid conflicts with
+ // future releases of Darwin. This test is really only needed for developers
+ // starting the app from a debugger anyway.
+ #ifndef LL_RELEASE_FOR_DOWNLOAD
+ int mib[4];
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_PID;
+ mib[3] = getpid();
+
+ struct kinfo_proc info;
+ memset(&info, 0, sizeof(info));
+
+ size_t size = sizeof(info);
+ int result = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
+ if((result == 0) || (errno == ENOMEM))
+ {
+ // P_TRACED flag is set, so this process is being debugged; do not install
+ // the handler
+ if(info.kp_proc.p_flag & P_TRACED) installHandler = false;
+ }
+ else
+ {
+ // Failed to discover if the process is being debugged; default to
+ // installing the handler.
+ installHandler = true;
+ }
+ #endif
+#endif
+ if(installHandler && (mExceptionHandler == 0))
{
std::string dumpPath = "/tmp/";
mExceptionHandler = new google_breakpad::ExceptionHandler(dumpPath, 0, &unix_post_minidump_callback, 0, true);
@@ -364,7 +405,7 @@ void LLApp::setError()
void LLApp::setMiniDumpDir(const std::string &path)
{
- llassert(mExceptionHandler);
+ if(mExceptionHandler == 0) return;
#ifdef LL_WINDOWS
wchar_t buffer[MAX_MINDUMP_PATH_LENGTH];
mbstowcs(buffer, path.c_str(), MAX_MINDUMP_PATH_LENGTH);
@@ -376,7 +417,7 @@ void LLApp::setMiniDumpDir(const std::string &path)
void LLApp::writeMiniDump()
{
- llassert(mExceptionHandler);
+ if(mExceptionHandler == 0) return;
mExceptionHandler->WriteMinidump();
}
diff --git a/indra/llcommon/llfasttimer_class.cpp b/indra/llcommon/llfasttimer_class.cpp
index 20727dd76e..dfbae09864 100644
--- a/indra/llcommon/llfasttimer_class.cpp
+++ b/indra/llcommon/llfasttimer_class.cpp
@@ -238,7 +238,8 @@ U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer
#else // windows or x86-mac or x86-linux or x86-solaris
U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer
{
- static U64 sCPUClockFrequency = U64(LLProcessorInfo().getCPUFrequency());
+ //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz
+ static U64 sCPUClockFrequency = U64(LLProcessorInfo().getCPUFrequency()*1000000.0);
// we drop the low-order byte in our timers, so report a lower frequency
return sCPUClockFrequency >> 8;