MAINT-7691 Fixed crash report not generating files in unicode named folders

master
andreykproductengine 2017-09-06 16:04:59 +03:00
parent f6655bd2ae
commit 4a4d93d8c0
5 changed files with 86 additions and 7 deletions

View File

@ -256,6 +256,60 @@ bool LLApp::parseCommandOptions(int argc, char** argv)
return true;
}
bool LLApp::parseCommandOptions(int argc, wchar_t** wargv)
{
LLSD commands;
std::string name;
std::string value;
for(int ii = 1; ii < argc; ++ii)
{
if(wargv[ii][0] != '-')
{
LL_INFOS() << "Did not find option identifier while parsing token: "
<< wargv[ii] << LL_ENDL;
return false;
}
int offset = 1;
if(wargv[ii][1] == '-') ++offset;
name.assign(utf16str_to_utf8str(&wargv[ii][offset]));
if(((ii+1) >= argc) || (wargv[ii+1][0] == '-'))
{
// we found another option after this one or we have
// reached the end. simply record that this option was
// found and continue.
int flag = name.compare("logfile");
if (0 == flag)
{
commands[name] = "log";
}
else
{
commands[name] = true;
}
continue;
}
++ii;
value.assign(utf16str_to_utf8str(wargv[ii]));
#if LL_WINDOWS
//Windows changed command line parsing. Deal with it.
S32 slen = value.length() - 1;
S32 start = 0;
S32 end = slen;
if (wargv[ii][start]=='"')start++;
if (wargv[ii][end]=='"')end--;
if (start!=0 || end!=slen)
{
value = value.substr (start,end);
}
#endif
commands[name] = value;
}
setOptionData(PRIORITY_COMMAND_LINE, commands);
return true;
}
void LLApp::manageLiveFile(LLLiveFile* livefile)
{
@ -354,7 +408,7 @@ void LLApp::setupErrorHandling(bool second_instance)
std::wstring wpipe_name;
wpipe_name = mCrashReportPipeStr + wstringize(getPid());
const std::wstring wdump_path(wstringize(mDumpPath));
const std::wstring wdump_path(utf8str_to_utf16str(mDumpPath));
int retries = 30;
for (; retries > 0; --retries)
@ -515,9 +569,9 @@ void LLApp::setMiniDumpDir(const std::string &path)
if(mExceptionHandler == 0) return;
#ifdef LL_WINDOWS
wchar_t buffer[MAX_MINDUMP_PATH_LENGTH];
mbstowcs(buffer, mDumpPath.c_str(), MAX_MINDUMP_PATH_LENGTH);
mExceptionHandler->set_dump_path(std::wstring(buffer));
std::wstring buffer(utf8str_to_utf16str(mDumpPath));
if (buffer.size() > MAX_MINDUMP_PATH_LENGTH) buffer.resize(MAX_MINDUMP_PATH_LENGTH);
mExceptionHandler->set_dump_path(buffer);
#elif LL_LINUX
//google_breakpad::MinidumpDescriptor desc("/tmp"); //path works in debug fails in production inside breakpad lib so linux gets a little less stack reporting until it is patched.
google_breakpad::MinidumpDescriptor desc(mDumpPath); //path works in debug fails in production inside breakpad lib so linux gets a little less stack reporting until it is patched.

View File

@ -106,7 +106,7 @@ public:
LLSD getOption(const std::string& name) const;
/**
* @brief Parse command line options and insert them into
* @brief Parse ASCII command line options and insert them into
* application command line options.
*
* The name inserted into the option will have leading option
@ -119,6 +119,20 @@ public:
*/
bool parseCommandOptions(int argc, char** argv);
/**
* @brief Parse Unicode command line options and insert them into
* application command line options.
*
* The name inserted into the option will have leading option
* identifiers (a minus or double minus) stripped. All options
* with values will be stored as a string, while all options
* without values will be stored as true.
* @param argc The argc passed into main().
* @param wargv The wargv passed into main().
* @return Returns true if the parse succeeded.
*/
bool parseCommandOptions(int argc, wchar_t** wargv);
/**
* @brief Keep track of live files automatically.
*

View File

@ -697,7 +697,7 @@ void LLAppViewerWin32::initCrashReporting(bool reportFreeze)
exe_wstr = utf8str_to_utf16str(exe_path);
std::wstring arg_wstr;
arg_wstr=wstringize(arg_str);
arg_wstr = utf8str_to_utf16str(arg_str);
LL_INFOS("CrashReport") << "Creating crash reporter process " << exe_path << " with params: " << arg_str << LL_ENDL;
if(CreateProcess(exe_wstr.c_str(),

View File

@ -377,7 +377,7 @@ bool LLCrashLoggerWindows::initCrashServer()
std::wstring wpipe_name;
wpipe_name = mCrashReportPipeStr + std::wstring(wstringize(mPID));
std::wstring wdump_path( wstringize(dump_path) );
std::wstring wdump_path(utf8str_to_utf16str(dump_path));
//Pipe naming conventions: http://msdn.microsoft.com/en-us/library/aa365783%28v=vs.85%29.aspx
mCrashHandler = new CrashGenerationServer( wpipe_name,

View File

@ -29,15 +29,26 @@
#include <stdlib.h>
#include "llcrashloggerwindows.h"
#ifdef _UNICODE
int APIENTRY wWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nCmdShow)
#else
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
#endif //_UNICODE
{
LL_INFOS() << "Starting crash reporter with args" << &lpCmdLine << LL_ENDL;
LLCrashLoggerWindows app;
app.setHandle(hInstance);
#ifdef _UNICODE
app.parseCommandOptions(__argc, __wargv);
#else
app.parseCommandOptions(__argc, __argv);
#endif //_UNICODE
LLSD options = LLApp::instance()->getOptionData(
LLApp::PRIORITY_COMMAND_LINE);