aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llappviewerlinux.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/newview/llappviewerlinux.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/newview/llappviewerlinux.cpp')
-rw-r--r--linden/indra/newview/llappviewerlinux.cpp74
1 files changed, 50 insertions, 24 deletions
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 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -164,14 +165,14 @@ static inline BOOL do_basic_glibc_backtrace()
164// amazing backtrace. 165// amazing backtrace.
165static inline BOOL do_basic_glibc_backtrace() 166static inline BOOL do_basic_glibc_backtrace()
166{ 167{
167 void *array[MAX_STACK_TRACE_DEPTH]; 168 void *stackarray[MAX_STACK_TRACE_DEPTH];
168 size_t size; 169 size_t size;
169 char **strings; 170 char **strings;
170 size_t i; 171 size_t i;
171 BOOL success = FALSE; 172 BOOL success = FALSE;
172 173
173 size = backtrace(array, MAX_STACK_TRACE_DEPTH); 174 size = backtrace(stackarray, MAX_STACK_TRACE_DEPTH);
174 strings = backtrace_symbols(array, size); 175 strings = backtrace_symbols(stackarray, size);
175 176
176 std::string strace_filename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log"); 177 std::string strace_filename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"stack_trace.log");
177 llinfos << "Opening stack trace file " << strace_filename << llendl; 178 llinfos << "Opening stack trace file " << strace_filename << llendl;
@@ -185,8 +186,13 @@ static inline BOOL do_basic_glibc_backtrace()
185 if (size) 186 if (size)
186 { 187 {
187 for (i = 0; i < size; i++) 188 for (i = 0; i < size; i++)
188 fputs((std::string(strings[i])+"\n").c_str(), 189 {
189 StraceFile); 190 // the format of the StraceFile is very specific, to allow (kludgy) machine-parsing
191 fprintf(StraceFile, "%-3d ", i);
192 fprintf(StraceFile, "%-32s\t", "unknown");
193 fprintf(StraceFile, "%p ", stackarray[i]);
194 fprintf(StraceFile, "%s\n", strings[i]);
195 }
190 196
191 success = TRUE; 197 success = TRUE;
192 } 198 }
@@ -204,7 +210,7 @@ static inline BOOL do_basic_glibc_backtrace()
204// extraction without exporting symbols (which'd cause subtle, fatal bugs). 210// extraction without exporting symbols (which'd cause subtle, fatal bugs).
205static inline BOOL do_elfio_glibc_backtrace() 211static inline BOOL do_elfio_glibc_backtrace()
206{ 212{
207 void *array[MAX_STACK_TRACE_DEPTH]; 213 void *stackarray[MAX_STACK_TRACE_DEPTH];
208 size_t btsize; 214 size_t btsize;
209 char **strings; 215 char **strings;
210 BOOL success = FALSE; 216 BOOL success = FALSE;
@@ -221,8 +227,8 @@ static inline BOOL do_elfio_glibc_backtrace()
221 } 227 }
222 228
223 // get backtrace address list and basic symbol info 229 // get backtrace address list and basic symbol info
224 btsize = backtrace(array, MAX_STACK_TRACE_DEPTH); 230 btsize = backtrace(stackarray, MAX_STACK_TRACE_DEPTH);
225 strings = backtrace_symbols(array, btsize); 231 strings = backtrace_symbols(stackarray, btsize);
226 232
227 // create ELF reader for our app binary 233 // create ELF reader for our app binary
228 IELFI* pReader; 234 IELFI* pReader;
@@ -256,7 +262,8 @@ static inline BOOL do_elfio_glibc_backtrace()
256 size_t btpos; 262 size_t btpos;
257 for (btpos = 0; btpos < btsize; ++btpos) 263 for (btpos = 0; btpos < btsize; ++btpos)
258 { 264 {
259 fprintf(StraceFile, "%d:\t", btpos); 265 // the format of the StraceFile is very specific, to allow (kludgy) machine-parsing
266 fprintf(StraceFile, "%-3d ", btpos);
260 int symidx; 267 int symidx;
261 for (symidx = 0; symidx < nSymNo; ++symidx) 268 for (symidx = 0; symidx < nSymNo; ++symidx)
262 { 269 {
@@ -265,9 +272,13 @@ static inline BOOL do_elfio_glibc_backtrace()
265 bind, type, section)) 272 bind, type, section))
266 { 273 {
267 // check if trace address within symbol range 274 // check if trace address within symbol range
268 if (uintptr_t(array[btpos]) >= value && 275 if (uintptr_t(stackarray[btpos]) >= value &&
269 uintptr_t(array[btpos]) < value+ssize) 276 uintptr_t(stackarray[btpos]) < value+ssize)
270 { 277 {
278 // symbol is inside viewer
279 fprintf(StraceFile, "%-32s\t", "com.secondlife.indra.viewer");
280 fprintf(StraceFile, "%p ", stackarray[btpos]);
281
271 char *demangled_str = NULL; 282 char *demangled_str = NULL;
272 int demangle_result = 1; 283 int demangle_result = 1;
273 demangled_str = 284 demangled_str =
@@ -277,20 +288,19 @@ static inline BOOL do_elfio_glibc_backtrace()
277 if (0 == demangle_result && 288 if (0 == demangle_result &&
278 NULL != demangled_str) { 289 NULL != demangled_str) {
279 fprintf(StraceFile, 290 fprintf(StraceFile,
280 "ELF(%s", demangled_str); 291 "%s", demangled_str);
281 free(demangled_str); 292 free(demangled_str);
282 } 293 }
283 else // failed demangle; print it raw 294 else // failed demangle; print it raw
284 { 295 {
285 fprintf(StraceFile, 296 fprintf(StraceFile,
286 "ELF(%s", name.c_str()); 297 "%s", name.c_str());
287 } 298 }
288 // print offset from symbol start 299 // print offset from symbol start
289 fprintf(StraceFile, 300 fprintf(StraceFile,
290 "+0x%lx) [%p]\n", 301 " + %lu\n",
291 uintptr_t(array[btpos]) - 302 uintptr_t(stackarray[btpos]) -
292 value, 303 value);
293 array[btpos]);
294 goto got_sym; // early escape 304 goto got_sym; // early escape
295 } 305 }
296 } 306 }
@@ -298,6 +308,8 @@ static inline BOOL do_elfio_glibc_backtrace()
298 // Fallback: 308 // Fallback:
299 // Didn't find a suitable symbol in the binary - it's probably 309 // Didn't find a suitable symbol in the binary - it's probably
300 // a symbol in a DSO; use glibc's idea of what it should be. 310 // a symbol in a DSO; use glibc's idea of what it should be.
311 fprintf(StraceFile, "%-32s\t", "unknown");
312 fprintf(StraceFile, "%p ", stackarray[btpos]);
301 fprintf(StraceFile, "%s\n", strings[btpos]); 313 fprintf(StraceFile, "%s\n", strings[btpos]);
302 got_sym:; 314 got_sym:;
303 } 315 }
@@ -331,6 +343,12 @@ LLAppViewerLinux::~LLAppViewerLinux()
331 343
332bool LLAppViewerLinux::init() 344bool LLAppViewerLinux::init()
333{ 345{
346 // g_thread_init() must be called before *any* use of glib, *and*
347 // before any mutexes are held, *and* some of our third-party
348 // libraries likes to use glib functions; in short, do this here
349 // really early in app startup!
350 if (!g_thread_supported ()) g_thread_init (NULL);
351
334 return LLAppViewer::init(); 352 return LLAppViewer::init();
335} 353}
336 354
@@ -432,8 +450,10 @@ gboolean viewer_app_api_GoSLURL(ViewerAppAPI *obj, gchar *slurl, gboolean **succ
432 450
433 llinfos << "Was asked to go to slurl: " << slurl << llendl; 451 llinfos << "Was asked to go to slurl: " << slurl << llendl;
434 452
435 const bool from_external_browser = true; 453 std::string url = slurl;
436 if (LLURLDispatcher::dispatch(slurl, from_external_browser)) 454 LLWebBrowserCtrl* web = NULL;
455 const bool trusted_browser = false;
456 if (LLURLDispatcher::dispatch(url, web, trusted_browser))
437 { 457 {
438 // bring window to foreground, as it has just been "launched" from a URL 458 // bring window to foreground, as it has just been "launched" from a URL
439 // todo: hmm, how to get there from here? 459 // todo: hmm, how to get there from here?
@@ -537,9 +557,11 @@ void LLAppViewerLinux::handleCrashReporting(bool reportFreeze)
537 cmd += gDirUtilp->getDirDelimiter(); 557 cmd += gDirUtilp->getDirDelimiter();
538#if LL_LINUX 558#if LL_LINUX
539 cmd += "linux-crash-logger.bin"; 559 cmd += "linux-crash-logger.bin";
540#else // LL_SOLARIS 560#elif LL_SOLARIS
541 cmd += "bin/solaris-crash-logger"; 561 cmd += "solaris-crash-logger";
542#endif // LL_LINUX 562#else
563# error Unknown platform
564#endif
543 565
544 if(reportFreeze) 566 if(reportFreeze)
545 { 567 {
@@ -620,7 +642,10 @@ void LLAppViewerLinux::handleCrashReporting(bool reportFreeze)
620bool LLAppViewerLinux::beingDebugged() 642bool LLAppViewerLinux::beingDebugged()
621{ 643{
622 static enum {unknown, no, yes} debugged = unknown; 644 static enum {unknown, no, yes} debugged = unknown;
623 645
646#if LL_SOLARIS
647 return debugged == no; // BUG: fix this for Solaris
648#else
624 if (debugged == unknown) 649 if (debugged == unknown)
625 { 650 {
626 pid_t ppid = getppid(); 651 pid_t ppid = getppid();
@@ -655,6 +680,7 @@ bool LLAppViewerLinux::beingDebugged()
655 } 680 }
656 681
657 return debugged == yes; 682 return debugged == yes;
683#endif
658} 684}
659 685
660bool LLAppViewerLinux::initLogging() 686bool LLAppViewerLinux::initLogging()