diff options
Diffstat (limited to 'indra/mac_crash_logger/llcrashloggermac.cpp')
-rw-r--r-- | indra/mac_crash_logger/llcrashloggermac.cpp | 119 |
1 files changed, 104 insertions, 15 deletions
diff --git a/indra/mac_crash_logger/llcrashloggermac.cpp b/indra/mac_crash_logger/llcrashloggermac.cpp index bec8cce04e..16efa4fe2c 100644 --- a/indra/mac_crash_logger/llcrashloggermac.cpp +++ b/indra/mac_crash_logger/llcrashloggermac.cpp @@ -2,25 +2,31 @@ * @file llcrashloggermac.cpp * @brief Mac OSX crash logger implementation * - * $LicenseInfo:firstyear=2003&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2003&license=viewergpl$ + * + * Copyright (c) 2003-2009, Linden Research, Inc. * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * 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 * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -205,6 +211,89 @@ bool LLCrashLoggerMac::init(void) void LLCrashLoggerMac::gatherPlatformSpecificFiles() { updateApplication("Gathering hardware information..."); + char path[MAX_PATH]; + FSRef folder; + + if(FSFindFolder(kUserDomain, kLogsFolderType, false, &folder) == noErr) + { + // folder is an FSRef to ~/Library/Logs/ + if(FSRefMakePath(&folder, (UInt8*)&path, sizeof(path)) == noErr) + { + struct stat dw_stat; + std::string mBuf; + bool isLeopard = false; + // Try the 10.3 path first... + std::string dw_file_name = std::string(path) + std::string("/CrashReporter/Second Life.crash.log"); + int res = stat(dw_file_name.c_str(), &dw_stat); + + if (res) + { + // Try the 10.2 one next... + dw_file_name = std::string(path) + std::string("/Second Life.crash.log"); + res = stat(dw_file_name.c_str(), &dw_stat); + } + + if(res) + { + //10.5: Like 10.3+, except it puts the crash time in the file instead of dividing it up + //using asterisks. Get a directory listing, search for files starting with second life, + //use the last one found. + std::string old_file_name, current_file_name, pathname, mask; + pathname = std::string(path) + std::string("/CrashReporter/"); + mask = "Second Life*"; + while(gDirUtilp->getNextFileInDir(pathname, mask, current_file_name, false)) + { + old_file_name = current_file_name; + } + if(old_file_name != "") + { + dw_file_name = pathname + old_file_name; + res=stat(dw_file_name.c_str(), &dw_stat); + isLeopard = true; + } + } + + if (!res) + { + std::ifstream fp(dw_file_name.c_str()); + std::stringstream str; + if(!fp.is_open()) return; + str << fp.rdbuf(); + mBuf = str.str(); + + if(!isLeopard) + { + // Crash logs consist of a number of entries, one per crash. + // Each entry is preceeded by "**********" on a line by itself. + // We want only the most recent (i.e. last) one. + const char *sep = "**********"; + const char *start = mBuf.c_str(); + const char *cur = start; + const char *temp = strstr(cur, sep); + + while(temp != NULL) + { + // Skip past the marker we just found + cur = temp + strlen(sep); /* Flawfinder: ignore */ + + // and try to find another + temp = strstr(cur, sep); + } + + // If there's more than one entry in the log file, strip all but the last one. + if(cur != start) + { + mBuf.erase(0, cur - start); + } + } + mCrashInfo["CrashLog"] = mBuf; + } + else + { + llwarns << "Couldn't find any CrashReporter files..." << llendl; + } + } + } } bool LLCrashLoggerMac::mainLoop() |