From ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Thu, 30 Apr 2009 13:04:20 -0500 Subject: Second Life viewer sources 1.23.0-RC --- linden/indra/newview/llappviewerlinux.cpp | 74 +++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 24 deletions(-) (limited to 'linden/indra/newview/llappviewerlinux.cpp') diff --git a/linden/indra/newview/llappviewerlinux.cpp b/linden/indra/newview/llappviewerlinux.cpp index ad90b82..d02e86a 100644 --- a/linden/indra/newview/llappviewerlinux.cpp +++ b/linden/indra/newview/llappviewerlinux.cpp @@ -17,7 +17,8 @@ * There are special exceptions to the terms and conditions of the GPL as * it is applied to this Source Code. View the full text of the exception * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -164,14 +165,14 @@ static inline BOOL do_basic_glibc_backtrace() // amazing backtrace. static inline BOOL do_basic_glibc_backtrace() { - void *array[MAX_STACK_TRACE_DEPTH]; + void *stackarray[MAX_STACK_TRACE_DEPTH]; size_t size; char **strings; size_t i; BOOL success = FALSE; - size = backtrace(array, MAX_STACK_TRACE_DEPTH); - strings = backtrace_symbols(array, size); + size = backtrace(stackarray, MAX_STACK_TRACE_DEPTH); + strings = backtrace_symbols(stackarray, size); std::string strace_filename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log"); llinfos << "Opening stack trace file " << strace_filename << llendl; @@ -185,8 +186,13 @@ static inline BOOL do_basic_glibc_backtrace() if (size) { for (i = 0; i < size; i++) - fputs((std::string(strings[i])+"\n").c_str(), - StraceFile); + { + // the format of the StraceFile is very specific, to allow (kludgy) machine-parsing + fprintf(StraceFile, "%-3d ", i); + fprintf(StraceFile, "%-32s\t", "unknown"); + fprintf(StraceFile, "%p ", stackarray[i]); + fprintf(StraceFile, "%s\n", strings[i]); + } success = TRUE; } @@ -204,7 +210,7 @@ static inline BOOL do_basic_glibc_backtrace() // extraction without exporting symbols (which'd cause subtle, fatal bugs). static inline BOOL do_elfio_glibc_backtrace() { - void *array[MAX_STACK_TRACE_DEPTH]; + void *stackarray[MAX_STACK_TRACE_DEPTH]; size_t btsize; char **strings; BOOL success = FALSE; @@ -221,8 +227,8 @@ static inline BOOL do_elfio_glibc_backtrace() } // get backtrace address list and basic symbol info - btsize = backtrace(array, MAX_STACK_TRACE_DEPTH); - strings = backtrace_symbols(array, btsize); + btsize = backtrace(stackarray, MAX_STACK_TRACE_DEPTH); + strings = backtrace_symbols(stackarray, btsize); // create ELF reader for our app binary IELFI* pReader; @@ -256,7 +262,8 @@ static inline BOOL do_elfio_glibc_backtrace() size_t btpos; for (btpos = 0; btpos < btsize; ++btpos) { - fprintf(StraceFile, "%d:\t", btpos); + // the format of the StraceFile is very specific, to allow (kludgy) machine-parsing + fprintf(StraceFile, "%-3d ", btpos); int symidx; for (symidx = 0; symidx < nSymNo; ++symidx) { @@ -265,9 +272,13 @@ static inline BOOL do_elfio_glibc_backtrace() bind, type, section)) { // check if trace address within symbol range - if (uintptr_t(array[btpos]) >= value && - uintptr_t(array[btpos]) < value+ssize) + if (uintptr_t(stackarray[btpos]) >= value && + uintptr_t(stackarray[btpos]) < value+ssize) { + // symbol is inside viewer + fprintf(StraceFile, "%-32s\t", "com.secondlife.indra.viewer"); + fprintf(StraceFile, "%p ", stackarray[btpos]); + char *demangled_str = NULL; int demangle_result = 1; demangled_str = @@ -277,20 +288,19 @@ static inline BOOL do_elfio_glibc_backtrace() if (0 == demangle_result && NULL != demangled_str) { fprintf(StraceFile, - "ELF(%s", demangled_str); + "%s", demangled_str); free(demangled_str); } else // failed demangle; print it raw { fprintf(StraceFile, - "ELF(%s", name.c_str()); + "%s", name.c_str()); } // print offset from symbol start fprintf(StraceFile, - "+0x%lx) [%p]\n", - uintptr_t(array[btpos]) - - value, - array[btpos]); + " + %lu\n", + uintptr_t(stackarray[btpos]) - + value); goto got_sym; // early escape } } @@ -298,6 +308,8 @@ static inline BOOL do_elfio_glibc_backtrace() // Fallback: // Didn't find a suitable symbol in the binary - it's probably // a symbol in a DSO; use glibc's idea of what it should be. + fprintf(StraceFile, "%-32s\t", "unknown"); + fprintf(StraceFile, "%p ", stackarray[btpos]); fprintf(StraceFile, "%s\n", strings[btpos]); got_sym:; } @@ -331,6 +343,12 @@ LLAppViewerLinux::~LLAppViewerLinux() bool LLAppViewerLinux::init() { + // g_thread_init() must be called before *any* use of glib, *and* + // before any mutexes are held, *and* some of our third-party + // libraries likes to use glib functions; in short, do this here + // really early in app startup! + if (!g_thread_supported ()) g_thread_init (NULL); + return LLAppViewer::init(); } @@ -432,8 +450,10 @@ gboolean viewer_app_api_GoSLURL(ViewerAppAPI *obj, gchar *slurl, gboolean **succ llinfos << "Was asked to go to slurl: " << slurl << llendl; - const bool from_external_browser = true; - if (LLURLDispatcher::dispatch(slurl, from_external_browser)) + std::string url = slurl; + LLWebBrowserCtrl* web = NULL; + const bool trusted_browser = false; + if (LLURLDispatcher::dispatch(url, web, trusted_browser)) { // bring window to foreground, as it has just been "launched" from a URL // todo: hmm, how to get there from here? @@ -537,9 +557,11 @@ void LLAppViewerLinux::handleCrashReporting(bool reportFreeze) cmd += gDirUtilp->getDirDelimiter(); #if LL_LINUX cmd += "linux-crash-logger.bin"; -#else // LL_SOLARIS - cmd += "bin/solaris-crash-logger"; -#endif // LL_LINUX +#elif LL_SOLARIS + cmd += "solaris-crash-logger"; +#else +# error Unknown platform +#endif if(reportFreeze) { @@ -620,7 +642,10 @@ void LLAppViewerLinux::handleCrashReporting(bool reportFreeze) bool LLAppViewerLinux::beingDebugged() { static enum {unknown, no, yes} debugged = unknown; - + +#if LL_SOLARIS + return debugged == no; // BUG: fix this for Solaris +#else if (debugged == unknown) { pid_t ppid = getppid(); @@ -655,6 +680,7 @@ bool LLAppViewerLinux::beingDebugged() } return debugged == yes; +#endif } bool LLAppViewerLinux::initLogging() -- cgit v1.1