summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorLynx Linden <lynx@lindenlab.com>2010-05-28 15:10:52 +0100
committerLynx Linden <lynx@lindenlab.com>2010-05-28 15:10:52 +0100
commit4fb77380279bdf853b7f213ba8997511720468dd (patch)
tree06844fc3edd57e6f0cec1e287e53d2775a9b036d /indra/llcommon
parent3729983908d365843bf8cf85178b61f719448374 (diff)
Write breakpad minidump files to the SL log directory.
Also, clean out old minidump files when we start up.
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llapp.cpp38
-rw-r--r--indra/llcommon/llapp.h16
2 files changed, 41 insertions, 13 deletions
diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp
index da14020f2b..861122a4ac 100644
--- a/indra/llcommon/llapp.cpp
+++ b/indra/llcommon/llapp.cpp
@@ -140,6 +140,8 @@ void LLApp::commonCtor()
mExceptionHandler = 0;
+ // initialize the buffer to write the minidump filename to
+ // (this is used to avoid allocating memory in the crash handler)
memset(minidump_path, 0, MAX_MINDUMP_PATH_LENGTH);
}
@@ -359,8 +361,15 @@ void LLApp::setError()
setStatus(APP_STATUS_ERROR);
}
+void LLApp::setMiniDumpDir(const std::string &path)
+{
+ llassert(mExceptionHandler);
+ mExceptionHandler->set_dump_path(path);
+}
+
void LLApp::writeMiniDump()
{
+ llassert(mExceptionHandler);
mExceptionHandler->WriteMinidump();
}
@@ -786,17 +795,25 @@ bool unix_post_minidump_callback(const char *dump_dir,
// The path must not be truncated.
llassert((dirPathLength + idLength + 5) <= LLApp::MAX_MINDUMP_PATH_LENGTH);
- char * path = LLApp::instance()->minidump_path;
+ char * path = LLApp::instance()->getMiniDumpFilename();
S32 remaining = LLApp::MAX_MINDUMP_PATH_LENGTH;
strncpy(path, dump_dir, remaining);
remaining -= dirPathLength;
path += dirPathLength;
- strncpy(path, minidump_id, remaining);
- remaining -= idLength;
- path += idLength;
- strncpy(path, ".dmp", remaining);
+ if (remaining > 0 && dirPathLength > 0 && path[-1] != '/')
+ {
+ *path++ = '/';
+ --remaining;
+ }
+ if (remaining > 0)
+ {
+ strncpy(path, minidump_id, remaining);
+ remaining -= idLength;
+ path += idLength;
+ strncpy(path, ".dmp", remaining);
+ }
- llinfos << "generated minidump: " << LLApp::instance()->minidump_path << llendl;
+ llinfos << "generated minidump: " << LLApp::instance()->getMiniDumpFilename() << llendl;
LLApp::runErrorHandler();
return true;
}
@@ -810,13 +827,18 @@ bool windows_post_minidump_callback(const wchar_t* dump_path,
MDRawAssertionInfo* assertion,
bool succeeded)
{
- char * path = LLApp::instance()->minidump_path;
+ char * path = LLApp::instance()->getMiniDumpFilename();
S32 remaining = LLApp::MAX_MINDUMP_PATH_LENGTH;
size_t bytesUsed;
bytesUsed = wcstombs(path, dump_path, static_cast<size_t>(remaining));
remaining -= bytesUsed;
path += bytesUsed;
+ if(remaining > 0 && bytesUsed > 0 && path[-1] != '\\')
+ {
+ *path++ = '\\';
+ --remaining;
+ }
if(remaining > 0)
{
bytesUsed = wcstombs(path, minidump_id, static_cast<size_t>(remaining));
@@ -828,7 +850,7 @@ bool windows_post_minidump_callback(const wchar_t* dump_path,
strncpy(path, ".dmp", remaining);
}
- llinfos << "generated minidump: " << LLApp::instance()->minidump_path << llendl;
+ llinfos << "generated minidump: " << LLApp::instance()->getMiniDumpFilename() << llendl;
// *NOTE:Mani - this code is stolen from LLApp, where its never actually used.
//OSMessageBox("Attach Debugger Now", "Error", OSMB_OK);
// *TODO: Translate the signals/exceptions into cross-platform stuff
diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h
index a6294a5e1a..fef05a7939 100644
--- a/indra/llcommon/llapp.h
+++ b/indra/llcommon/llapp.h
@@ -234,9 +234,16 @@ public:
static void runErrorHandler(); // run shortly after we detect an error, ran in the relatively robust context of the LLErrorThread - preferred.
//@}
- //
+ // the maximum length of the minidump filename returned by getMiniDumpFilename()
+ static const U32 MAX_MINDUMP_PATH_LENGTH = 256;
+
+ // change the directory where Breakpad minidump files are written to
+ void setMiniDumpDir(const std::string &path);
+
+ // Return the Google Breakpad minidump filename after a crash.
+ char *getMiniDumpFilename() { return minidump_path; }
+
// Write out a Google Breakpad minidump file.
- //
void writeMiniDump();
#if !LL_WINDOWS
@@ -274,9 +281,6 @@ public:
typedef std::map<std::string, std::string> string_map;
string_map mOptionMap; // Contains all command-line options and arguments in a map
- // Contains the path to minidump file after a crash.
- static const U32 MAX_MINDUMP_PATH_LENGTH = 256;
- char minidump_path[MAX_MINDUMP_PATH_LENGTH];
protected:
static void setStatus(EAppStatus status); // Use this to change the application status.
@@ -298,6 +302,8 @@ protected:
private:
void startErrorThread();
+ // Contains the filename of the minidump file after a crash.
+ char minidump_path[MAX_MINDUMP_PATH_LENGTH];
// *NOTE: On Windows, we need a routine to reset the structured
// exception handler when some evil driver has taken it over for