diff options
Diffstat (limited to 'linden/indra/newview/viewer.cpp')
-rw-r--r-- | linden/indra/newview/viewer.cpp | 93 |
1 files changed, 75 insertions, 18 deletions
diff --git a/linden/indra/newview/viewer.cpp b/linden/indra/newview/viewer.cpp index 2f05754..7ff6cc3 100644 --- a/linden/indra/newview/viewer.cpp +++ b/linden/indra/newview/viewer.cpp | |||
@@ -81,7 +81,9 @@ | |||
81 | #if LL_LINUX | 81 | #if LL_LINUX |
82 | # include <dlfcn.h> // RTLD_LAZY | 82 | # include <dlfcn.h> // RTLD_LAZY |
83 | # include <execinfo.h> // backtrace - glibc only | 83 | # include <execinfo.h> // backtrace - glibc only |
84 | # ifndef LL_ELFBIN | ||
84 | #define LL_ELFBIN 1 | 85 | #define LL_ELFBIN 1 |
86 | # endif // LL_ELFBIN | ||
85 | # if LL_ELFBIN | 87 | # if LL_ELFBIN |
86 | # include <cxxabi.h> // for symbol demangling | 88 | # include <cxxabi.h> // for symbol demangling |
87 | # include "ELFIO.h" // for better backtraces | 89 | # include "ELFIO.h" // for better backtraces |
@@ -189,6 +191,7 @@ | |||
189 | #include "llnotify.h" | 191 | #include "llnotify.h" |
190 | #include "llselectmgr.h" | 192 | #include "llselectmgr.h" |
191 | #include "llsky.h" | 193 | #include "llsky.h" |
194 | #include "llsrv.h" | ||
192 | #include "llstartup.h" | 195 | #include "llstartup.h" |
193 | #include "llstatusbar.h" | 196 | #include "llstatusbar.h" |
194 | #include "llsurface.h" | 197 | #include "llsurface.h" |
@@ -337,8 +340,7 @@ static EUserServerDomain UserServerDefaultChoice = USERSERVER_DMZ; | |||
337 | BOOL gHackGodmode = FALSE; | 340 | BOOL gHackGodmode = FALSE; |
338 | #endif | 341 | #endif |
339 | 342 | ||
340 | // Only used if not empty. Otherwise uses value from table above. | 343 | std::vector<std::string> gLoginURIs; |
341 | static std::string gLoginURI; | ||
342 | static std::string gHelperURI; | 344 | static std::string gHelperURI; |
343 | 345 | ||
344 | LLAgent gAgent; | 346 | LLAgent gAgent; |
@@ -382,7 +384,7 @@ LLUUID gViewerDigest; // MD5 digest of the viewer's executable file. | |||
382 | LLPumpIO* gServicePump = NULL; | 384 | LLPumpIO* gServicePump = NULL; |
383 | S32 gNumSessions = 0; | 385 | S32 gNumSessions = 0; |
384 | 386 | ||
385 | BOOL gAllowAFK = TRUE; | 387 | BOOL gAllowIdleAFK = TRUE; |
386 | F32 gAFKTimeout = DEFAULT_AFK_TIMEOUT; | 388 | F32 gAFKTimeout = DEFAULT_AFK_TIMEOUT; |
387 | F32 gMouseSensitivity = 3.f; | 389 | F32 gMouseSensitivity = 3.f; |
388 | BOOL gInvertMouse = FALSE; | 390 | BOOL gInvertMouse = FALSE; |
@@ -2397,7 +2399,7 @@ static inline BOOL do_elfio_glibc_backtrace() | |||
2397 | } | 2399 | } |
2398 | // print offset from symbol start | 2400 | // print offset from symbol start |
2399 | fprintf(StraceFile, | 2401 | fprintf(StraceFile, |
2400 | "+0x%x) [%p]\n", | 2402 | "+0x%lx) [%p]\n", |
2401 | uintptr_t(array[btpos]) - | 2403 | uintptr_t(array[btpos]) - |
2402 | value, | 2404 | value, |
2403 | array[btpos]); | 2405 | array[btpos]); |
@@ -2429,8 +2431,57 @@ static inline BOOL do_elfio_glibc_backtrace() | |||
2429 | #endif // LL_ELFBIN | 2431 | #endif // LL_ELFBIN |
2430 | #endif // LL_LINUX | 2432 | #endif // LL_LINUX |
2431 | 2433 | ||
2434 | /* Report whether we're being run under the control of a debugger. */ | ||
2435 | static inline bool being_debugged() | ||
2436 | { | ||
2437 | static enum {unknown, no, yes} debugged = unknown; | ||
2438 | |||
2439 | if (debugged == unknown) | ||
2440 | { | ||
2441 | #if LL_LINUX | ||
2442 | pid_t ppid = getppid(); | ||
2443 | char *name; | ||
2444 | int ret; | ||
2445 | |||
2446 | ret = asprintf(&name, "/proc/%d/exe", ppid); | ||
2447 | if (ret != -1) | ||
2448 | { | ||
2449 | char buf[1024]; | ||
2450 | size_t n; | ||
2451 | |||
2452 | n = readlink(name, buf, sizeof(buf) - 1); | ||
2453 | if (n != -1) | ||
2454 | { | ||
2455 | char *base = strrchr(buf, '/'); | ||
2456 | buf[n + 1] = '\0'; | ||
2457 | if (base == NULL) | ||
2458 | { | ||
2459 | base = buf; | ||
2460 | } else { | ||
2461 | base += 1; | ||
2462 | } | ||
2463 | |||
2464 | if (strcmp(base, "gdb") == 0) | ||
2465 | { | ||
2466 | debugged = yes; | ||
2467 | } | ||
2468 | } | ||
2469 | free(name); | ||
2470 | } | ||
2471 | #endif // LL_LINUX | ||
2472 | } | ||
2473 | |||
2474 | return debugged == yes; | ||
2475 | } | ||
2476 | |||
2432 | void viewer_crash_callback() | 2477 | void viewer_crash_callback() |
2433 | { | 2478 | { |
2479 | // This will drop us into the debugger. | ||
2480 | if (being_debugged()) | ||
2481 | { | ||
2482 | abort(); | ||
2483 | } | ||
2484 | |||
2434 | // Returns whether a dialog was shown. | 2485 | // Returns whether a dialog was shown. |
2435 | // Only do the logic in here once | 2486 | // Only do the logic in here once |
2436 | if (gReportedCrash) | 2487 | if (gReportedCrash) |
@@ -3483,7 +3534,7 @@ void idle_network() | |||
3483 | void idle_afk_check() | 3534 | void idle_afk_check() |
3484 | { | 3535 | { |
3485 | // check idle timers | 3536 | // check idle timers |
3486 | if (gAwayTriggerTimer.getElapsedTimeF32() > gAFKTimeout) | 3537 | if (gAllowIdleAFK && (gAwayTriggerTimer.getElapsedTimeF32() > gAFKTimeout)) |
3487 | { | 3538 | { |
3488 | gAgent.setAFK(); | 3539 | gAgent.setAFK(); |
3489 | } | 3540 | } |
@@ -4970,7 +5021,7 @@ void saved_settings_to_globals() | |||
4970 | gAgent.mHideGroupTitle = gSavedSettings.getBOOL("RenderHideGroupTitle"); | 5021 | gAgent.mHideGroupTitle = gSavedSettings.getBOOL("RenderHideGroupTitle"); |
4971 | 5022 | ||
4972 | gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc"); | 5023 | gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc"); |
4973 | gAllowAFK = gSavedSettings.getBOOL("AllowAFK"); | 5024 | gAllowIdleAFK = gSavedSettings.getBOOL("AllowIdleAFK"); |
4974 | gAFKTimeout = gSavedSettings.getF32("AFKTimeout"); | 5025 | gAFKTimeout = gSavedSettings.getF32("AFKTimeout"); |
4975 | gMouseSensitivity = gSavedSettings.getF32("MouseSensitivity"); | 5026 | gMouseSensitivity = gSavedSettings.getF32("MouseSensitivity"); |
4976 | gInvertMouse = gSavedSettings.getBOOL("InvertMouse"); | 5027 | gInvertMouse = gSavedSettings.getBOOL("InvertMouse"); |
@@ -5044,7 +5095,7 @@ void cleanup_saved_settings() | |||
5044 | 5095 | ||
5045 | gSavedSettings.setBOOL("DebugWindowProc", gDebugWindowProc); | 5096 | gSavedSettings.setBOOL("DebugWindowProc", gDebugWindowProc); |
5046 | 5097 | ||
5047 | gSavedSettings.setBOOL("AllowAFK", gAllowAFK); | 5098 | gSavedSettings.setBOOL("AllowIdleAFK", gAllowIdleAFK); |
5048 | gSavedSettings.setBOOL("ShowObjectUpdates", gShowObjectUpdates); | 5099 | gSavedSettings.setBOOL("ShowObjectUpdates", gShowObjectUpdates); |
5049 | 5100 | ||
5050 | if (!gNoRender) | 5101 | if (!gNoRender) |
@@ -5483,7 +5534,14 @@ void catch_signals() | |||
5483 | // Handle the signals that default to causing a core image to be created, as per the man page on signal(2). | 5534 | // Handle the signals that default to causing a core image to be created, as per the man page on signal(2). |
5484 | signal(SIGILL, signal_handlers); | 5535 | signal(SIGILL, signal_handlers); |
5485 | signal(SIGTRAP, signal_handlers); | 5536 | signal(SIGTRAP, signal_handlers); |
5486 | signal(SIGABRT, signal_handlers); | 5537 | if (being_debugged()) |
5538 | { | ||
5539 | // If we're being run under the control of a debugger, give | ||
5540 | // ourselves a way to bail into the debugger. | ||
5541 | signal(SIGABRT, SIG_DFL); | ||
5542 | } else { | ||
5543 | signal(SIGABRT, signal_handlers); | ||
5544 | } | ||
5487 | signal(SIGFPE, signal_handlers); | 5545 | signal(SIGFPE, signal_handlers); |
5488 | signal(SIGBUS, signal_handlers); | 5546 | signal(SIGBUS, signal_handlers); |
5489 | signal(SIGSEGV, signal_handlers); | 5547 | signal(SIGSEGV, signal_handlers); |
@@ -5658,8 +5716,7 @@ int parse_args(int argc, char **argv) | |||
5658 | } | 5716 | } |
5659 | else if (!strcmp(argv[j], "-loginuri") && (++j < argc)) | 5717 | else if (!strcmp(argv[j], "-loginuri") && (++j < argc)) |
5660 | { | 5718 | { |
5661 | gLoginURI = argv[j]; | 5719 | gLoginURIs.push_back(utf8str_trim(argv[j])); |
5662 | gLoginURI = utf8str_trim(gLoginURI); | ||
5663 | } | 5720 | } |
5664 | else if (!strcmp(argv[j], "-helperuri") && (++j < argc)) | 5721 | else if (!strcmp(argv[j], "-helperuri") && (++j < argc)) |
5665 | { | 5722 | { |
@@ -5934,13 +5991,13 @@ void LLURLSimString::setString(const LLString& url) | |||
5934 | // static | 5991 | // static |
5935 | S32 LLURLSimString::parseGridIdx(const LLString& in_string, S32 idx0, S32* res, S32 max) | 5992 | S32 LLURLSimString::parseGridIdx(const LLString& in_string, S32 idx0, S32* res, S32 max) |
5936 | { | 5993 | { |
5937 | if ((std::string::size_type)idx0 == LLString::npos || in_string[idx0] != '/') | 5994 | if (idx0 == INT_MAX || in_string[idx0] != '/') |
5938 | { | 5995 | { |
5939 | return LLString::npos; // parse error | 5996 | return INT_MAX; // parse error |
5940 | } | 5997 | } |
5941 | idx0++; | 5998 | idx0++; |
5942 | std::string::size_type idx1 = in_string.find_first_of('/', idx0); | 5999 | std::string::size_type idx1 = in_string.find_first_of('/', idx0); |
5943 | S32 len = (idx1 == LLString::npos) ? LLString::npos : idx1-idx0; | 6000 | std::string::size_type len = (idx1 == LLString::npos) ? LLString::npos : idx1-idx0; |
5944 | LLString tstring = in_string.substr(idx0,len); | 6001 | LLString tstring = in_string.substr(idx0,len); |
5945 | S32 val = atoi(tstring.c_str()); | 6002 | S32 val = atoi(tstring.c_str()); |
5946 | *res = llclamp(val,0,max); | 6003 | *res = llclamp(val,0,max); |
@@ -5964,7 +6021,7 @@ bool LLURLSimString::parse() | |||
5964 | idx0 = sInstance.mSimString.find_first_not_of('/'); // strip any bogus initial '/' | 6021 | idx0 = sInstance.mSimString.find_first_not_of('/'); // strip any bogus initial '/' |
5965 | if (idx0 == LLString::npos) idx0 = 0; | 6022 | if (idx0 == LLString::npos) idx0 = 0; |
5966 | idx1 = sInstance.mSimString.find_first_of('/', idx0); | 6023 | idx1 = sInstance.mSimString.find_first_of('/', idx0); |
5967 | S32 len = (idx1 == LLString::npos) ? LLString::npos : idx1-idx0; | 6024 | std::string::size_type len = (idx1 == LLString::npos) ? LLString::npos : idx1-idx0; |
5968 | LLString tstring = sInstance.mSimString.substr(idx0,len); | 6025 | LLString tstring = sInstance.mSimString.substr(idx0,len); |
5969 | char* curlstr = curl_unescape(tstring.c_str(), tstring.size()); | 6026 | char* curlstr = curl_unescape(tstring.c_str(), tstring.size()); |
5970 | sInstance.mSimName = LLString(curlstr); | 6027 | sInstance.mSimName = LLString(curlstr); |
@@ -6577,14 +6634,14 @@ void cleanup_app() | |||
6577 | end_messaging_system(); | 6634 | end_messaging_system(); |
6578 | } | 6635 | } |
6579 | 6636 | ||
6580 | const std::string& getLoginURI() | 6637 | const std::vector<std::string>& getLoginURIs() |
6581 | { | 6638 | { |
6582 | if (gLoginURI.empty()) | 6639 | if (gLoginURIs.empty()) |
6583 | { | 6640 | { |
6584 | // not specified on the command line, use value from table | 6641 | // not specified on the command line, use value from table |
6585 | gLoginURI = gUserServerDomainName[gUserServerChoice].mLoginURI; | 6642 | gLoginURIs = LLSRV::rewriteURI(gUserServerDomainName[gUserServerChoice].mLoginURI); |
6586 | } | 6643 | } |
6587 | return gLoginURI; | 6644 | return gLoginURIs; |
6588 | } | 6645 | } |
6589 | 6646 | ||
6590 | const std::string& getHelperURI() | 6647 | const std::string& getHelperURI() |