aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcrashlogger/llcrashlogger.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xlinden/indra/llcrashlogger/llcrashlogger.cpp71
1 files changed, 45 insertions, 26 deletions
diff --git a/linden/indra/llcrashlogger/llcrashlogger.cpp b/linden/indra/llcrashlogger/llcrashlogger.cpp
index af30136..13f804a 100755
--- a/linden/indra/llcrashlogger/llcrashlogger.cpp
+++ b/linden/indra/llcrashlogger/llcrashlogger.cpp
@@ -4,7 +4,7 @@
4* 4*
5* $LicenseInfo:firstyear=2003&license=viewergpl$ 5* $LicenseInfo:firstyear=2003&license=viewergpl$
6* 6*
7* Copyright (c) 2003-2008, Linden Research, Inc. 7* Copyright (c) 2003-2009, Linden Research, Inc.
8* 8*
9* Second Life Viewer Source Code 9* Second Life Viewer Source Code
10* The source code in this file ("Source Code") is provided by Linden Lab 10* The source code in this file ("Source Code") is provided by Linden Lab
@@ -123,6 +123,33 @@ void trimSLLog(std::string& sllog)
123 } 123 }
124} 124}
125 125
126std::string getStartupStateFromLog(std::string& sllog)
127{
128 std::string startup_state = "STATE_FIRST";
129 std::string startup_token = "Startup state changing from ";
130
131 int index = sllog.rfind(startup_token);
132 if (index < 0 || index + startup_token.length() > sllog.length()) {
133 return startup_state;
134 }
135
136 // find new line
137 char cur_char = sllog[index + startup_token.length()];
138 std::string::size_type newline_loc = index + startup_token.length();
139 while(cur_char != '\n' && newline_loc < sllog.length())
140 {
141 newline_loc++;
142 cur_char = sllog[newline_loc];
143 }
144
145 // get substring and find location of " to "
146 std::string state_line = sllog.substr(index, newline_loc - index);
147 std::string::size_type state_index = state_line.find(" to ");
148 startup_state = state_line.substr(state_index + 4, state_line.length() - state_index - 4);
149
150 return startup_state;
151}
152
126void LLCrashLogger::gatherFiles() 153void LLCrashLogger::gatherFiles()
127{ 154{
128 155
@@ -154,6 +181,9 @@ void LLCrashLogger::gatherFiles()
154 if (debug_log_file.is_open()) 181 if (debug_log_file.is_open())
155 { 182 {
156 LLSDSerialize::fromXML(mDebugLog, debug_log_file); 183 LLSDSerialize::fromXML(mDebugLog, debug_log_file);
184
185 mCrashInPreviousExec = mDebugLog["CrashNotHandled"].asBoolean();
186
157 mFileMap["SecondLifeLog"] = mDebugLog["SLLog"].asString(); 187 mFileMap["SecondLifeLog"] = mDebugLog["SLLog"].asString();
158 mFileMap["SettingsXml"] = mDebugLog["SettingsFilename"].asString(); 188 mFileMap["SettingsXml"] = mDebugLog["SettingsFilename"].asString();
159 if(mDebugLog.has("CAFilename")) 189 if(mDebugLog.has("CAFilename"))
@@ -176,6 +206,16 @@ void LLCrashLogger::gatherFiles()
176 mFileMap["SettingsXml"] = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,"settings.xml"); 206 mFileMap["SettingsXml"] = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS,"settings.xml");
177 } 207 }
178 208
209 if(mCrashInPreviousExec)
210 {
211 // Replace the log file ext with .old, since the
212 // instance that launched this process has overwritten
213 // SecondLife.log
214 std::string log_filename = mFileMap["SecondLifeLog"];
215 log_filename.replace(log_filename.size() - 4, 4, ".old");
216 mFileMap["SecondLifeLog"] = log_filename;
217 }
218
179 gatherPlatformSpecificFiles(); 219 gatherPlatformSpecificFiles();
180 220
181 //Use the debug log to reconstruct the URL to send the crash report to 221 //Use the debug log to reconstruct the URL to send the crash report to
@@ -219,6 +259,10 @@ void LLCrashLogger::gatherFiles()
219 std::string crash_info = s.str(); 259 std::string crash_info = s.str();
220 if(itr->first == "SecondLifeLog") 260 if(itr->first == "SecondLifeLog")
221 { 261 {
262 if(!mCrashInfo["DebugLog"].has("StartupState"))
263 {
264 mCrashInfo["DebugLog"]["StartupState"] = getStartupStateFromLog(crash_info);
265 }
222 trimSLLog(crash_info); 266 trimSLLog(crash_info);
223 } 267 }
224 268
@@ -229,12 +273,6 @@ void LLCrashLogger::gatherFiles()
229LLSD LLCrashLogger::constructPostData() 273LLSD LLCrashLogger::constructPostData()
230{ 274{
231 LLSD ret; 275 LLSD ret;
232
233 if(mCrashInPreviousExec)
234 {
235 mCrashInfo["CrashInPreviousExecution"] = "Y";
236 }
237
238 return mCrashInfo; 276 return mCrashInfo;
239} 277}
240 278
@@ -338,25 +376,6 @@ bool LLCrashLogger::init()
338 llinfos << "Loading crash behavior setting" << llendl; 376 llinfos << "Loading crash behavior setting" << llendl;
339 mCrashBehavior = loadCrashBehaviorSetting(); 377 mCrashBehavior = loadCrashBehaviorSetting();
340 378
341 //Run through command line options
342 if(getOption("previous").isDefined())
343 {
344 llinfos << "Previous execution did not remove Imprudence.exec_marker" << llendl;
345 mCrashInPreviousExec = TRUE;
346 }
347
348 if(getOption("dialog").isDefined())
349 {
350 llinfos << "Show the user dialog" << llendl;
351 mCrashBehavior = CRASH_BEHAVIOR_ASK;
352 }
353
354 LLSD name = getOption("name");
355 if(name.isDefined())
356 {
357 mProductName = name.asString();
358 }
359
360 // If user doesn't want to send, bail out 379 // If user doesn't want to send, bail out
361 if (mCrashBehavior == CRASH_BEHAVIOR_NEVER_SEND) 380 if (mCrashBehavior == CRASH_BEHAVIOR_NEVER_SEND)
362 { 381 {