Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
4e6580bf
Commit
4e6580bf
authored
14 years ago
by
Andrew A. de Laix
Browse files
Options
Downloads
Patches
Plain Diff
DOS 2 UNIX line endings.
parent
1ec7de1b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/newview/llwindebug.cpp
+188
-188
188 additions, 188 deletions
indra/newview/llwindebug.cpp
with
188 additions
and
188 deletions
indra/newview/llwindebug.cpp
+
188
−
188
View file @
4e6580bf
/**
/**
* @file llwindebug.cpp
* @file llwindebug.cpp
* @brief Windows debugging functions
* @brief Windows debugging functions
*
*
* $LicenseInfo:firstyear=2004&license=viewergpl$
* $LicenseInfo:firstyear=2004&license=viewergpl$
*
*
* Copyright (c) 2004-2009, Linden Research, Inc.
* Copyright (c) 2004-2009, Linden Research, Inc.
*
*
* Second Life Viewer Source Code
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* 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
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* ("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
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
*
* There are special exceptions to the terms and conditions of the GPL as
* 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
* 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
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
*
* By copying, modifying or distributing this software, you acknowledge
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
* and agree to abide by those obligations.
*
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
* $/LicenseInfo$
*/
*/
#include
"llviewerprecompiledheaders.h"
#include
"llviewerprecompiledheaders.h"
#include
"llwindebug.h"
#include
"llwindebug.h"
#include
"lldir.h"
#include
"lldir.h"
// based on dbghelp.h
// based on dbghelp.h
typedef
BOOL
(
WINAPI
*
MINIDUMPWRITEDUMP
)(
HANDLE
hProcess
,
DWORD
dwPid
,
HANDLE
hFile
,
MINIDUMP_TYPE
DumpType
,
typedef
BOOL
(
WINAPI
*
MINIDUMPWRITEDUMP
)(
HANDLE
hProcess
,
DWORD
dwPid
,
HANDLE
hFile
,
MINIDUMP_TYPE
DumpType
,
CONST
PMINIDUMP_EXCEPTION_INFORMATION
ExceptionParam
,
CONST
PMINIDUMP_EXCEPTION_INFORMATION
ExceptionParam
,
CONST
PMINIDUMP_USER_STREAM_INFORMATION
UserStreamParam
,
CONST
PMINIDUMP_USER_STREAM_INFORMATION
UserStreamParam
,
CONST
PMINIDUMP_CALLBACK_INFORMATION
CallbackParam
CONST
PMINIDUMP_CALLBACK_INFORMATION
CallbackParam
);
);
MINIDUMPWRITEDUMP
f_mdwp
=
NULL
;
MINIDUMPWRITEDUMP
f_mdwp
=
NULL
;
class
LLMemoryReserve
{
class
LLMemoryReserve
{
public:
public:
LLMemoryReserve
();
LLMemoryReserve
();
~
LLMemoryReserve
();
~
LLMemoryReserve
();
void
reserve
();
void
reserve
();
void
release
();
void
release
();
protected:
protected:
unsigned
char
*
mReserve
;
unsigned
char
*
mReserve
;
static
const
size_t
MEMORY_RESERVATION_SIZE
;
static
const
size_t
MEMORY_RESERVATION_SIZE
;
};
};
LLMemoryReserve
::
LLMemoryReserve
()
:
LLMemoryReserve
::
LLMemoryReserve
()
:
mReserve
(
NULL
)
mReserve
(
NULL
)
{
{
};
};
LLMemoryReserve
::~
LLMemoryReserve
()
LLMemoryReserve
::~
LLMemoryReserve
()
{
{
release
();
release
();
}
}
// I dunno - this just seemed like a pretty good value.
// I dunno - this just seemed like a pretty good value.
const
size_t
LLMemoryReserve
::
MEMORY_RESERVATION_SIZE
=
5
*
1024
*
1024
;
const
size_t
LLMemoryReserve
::
MEMORY_RESERVATION_SIZE
=
5
*
1024
*
1024
;
void
LLMemoryReserve
::
reserve
()
void
LLMemoryReserve
::
reserve
()
{
{
if
(
NULL
==
mReserve
)
if
(
NULL
==
mReserve
)
mReserve
=
new
unsigned
char
[
MEMORY_RESERVATION_SIZE
];
mReserve
=
new
unsigned
char
[
MEMORY_RESERVATION_SIZE
];
};
};
void
LLMemoryReserve
::
release
()
void
LLMemoryReserve
::
release
()
{
{
delete
[]
mReserve
;
delete
[]
mReserve
;
mReserve
=
NULL
;
mReserve
=
NULL
;
};
};
static
LLMemoryReserve
gEmergencyMemoryReserve
;
static
LLMemoryReserve
gEmergencyMemoryReserve
;
LONG
NTAPI
vectoredHandler
(
PEXCEPTION_POINTERS
exception_infop
)
LONG
NTAPI
vectoredHandler
(
PEXCEPTION_POINTERS
exception_infop
)
{
{
LLWinDebug
::
instance
().
generateMinidump
(
exception_infop
);
LLWinDebug
::
instance
().
generateMinidump
(
exception_infop
);
return
EXCEPTION_CONTINUE_SEARCH
;
return
EXCEPTION_CONTINUE_SEARCH
;
}
}
// static
// static
void
LLWinDebug
::
init
()
void
LLWinDebug
::
init
()
{
{
static
bool
s_first_run
=
true
;
static
bool
s_first_run
=
true
;
// Load the dbghelp dll now, instead of waiting for the crash.
// Load the dbghelp dll now, instead of waiting for the crash.
// Less potential for stack mangling
// Less potential for stack mangling
if
(
s_first_run
)
if
(
s_first_run
)
{
{
// First, try loading from the directory that the app resides in.
// First, try loading from the directory that the app resides in.
std
::
string
local_dll_name
=
gDirUtilp
->
findFile
(
"dbghelp.dll"
,
gDirUtilp
->
getWorkingDir
(),
gDirUtilp
->
getExecutableDir
());
std
::
string
local_dll_name
=
gDirUtilp
->
findFile
(
"dbghelp.dll"
,
gDirUtilp
->
getWorkingDir
(),
gDirUtilp
->
getExecutableDir
());
HMODULE
hDll
=
NULL
;
HMODULE
hDll
=
NULL
;
hDll
=
LoadLibraryA
(
local_dll_name
.
c_str
());
hDll
=
LoadLibraryA
(
local_dll_name
.
c_str
());
if
(
!
hDll
)
if
(
!
hDll
)
{
{
hDll
=
LoadLibrary
(
L"dbghelp.dll"
);
hDll
=
LoadLibrary
(
L"dbghelp.dll"
);
}
}
if
(
!
hDll
)
if
(
!
hDll
)
{
{
LL_WARNS
(
"AppInit"
)
<<
"Couldn't find dbghelp.dll!"
<<
LL_ENDL
;
LL_WARNS
(
"AppInit"
)
<<
"Couldn't find dbghelp.dll!"
<<
LL_ENDL
;
}
}
else
else
{
{
f_mdwp
=
(
MINIDUMPWRITEDUMP
)
GetProcAddress
(
hDll
,
"MiniDumpWriteDump"
);
f_mdwp
=
(
MINIDUMPWRITEDUMP
)
GetProcAddress
(
hDll
,
"MiniDumpWriteDump"
);
if
(
!
f_mdwp
)
if
(
!
f_mdwp
)
{
{
FreeLibrary
(
hDll
);
FreeLibrary
(
hDll
);
hDll
=
NULL
;
hDll
=
NULL
;
}
}
}
}
gEmergencyMemoryReserve
.
reserve
();
gEmergencyMemoryReserve
.
reserve
();
s_first_run
=
false
;
s_first_run
=
false
;
// Add this exeption hanlder to save windows style minidump.
// Add this exeption hanlder to save windows style minidump.
AddVectoredExceptionHandler
(
0
,
&
vectoredHandler
);
AddVectoredExceptionHandler
(
0
,
&
vectoredHandler
);
}
}
}
}
void
LLWinDebug
::
writeDumpToFile
(
MINIDUMP_TYPE
type
,
MINIDUMP_EXCEPTION_INFORMATION
*
ExInfop
,
const
std
::
string
&
filename
)
void
LLWinDebug
::
writeDumpToFile
(
MINIDUMP_TYPE
type
,
MINIDUMP_EXCEPTION_INFORMATION
*
ExInfop
,
const
std
::
string
&
filename
)
{
{
if
(
f_mdwp
==
NULL
||
gDirUtilp
==
NULL
)
if
(
f_mdwp
==
NULL
||
gDirUtilp
==
NULL
)
{
{
return
;
return
;
}
}
else
else
{
{
std
::
string
dump_path
=
gDirUtilp
->
getExpandedFilename
(
LL_PATH_LOGS
,
filename
);
std
::
string
dump_path
=
gDirUtilp
->
getExpandedFilename
(
LL_PATH_LOGS
,
filename
);
HANDLE
hFile
=
CreateFileA
(
dump_path
.
c_str
(),
HANDLE
hFile
=
CreateFileA
(
dump_path
.
c_str
(),
GENERIC_WRITE
,
GENERIC_WRITE
,
FILE_SHARE_WRITE
,
FILE_SHARE_WRITE
,
NULL
,
NULL
,
CREATE_ALWAYS
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
NULL
);
if
(
hFile
!=
INVALID_HANDLE_VALUE
)
if
(
hFile
!=
INVALID_HANDLE_VALUE
)
{
{
// Write the dump, ignoring the return value
// Write the dump, ignoring the return value
f_mdwp
(
GetCurrentProcess
(),
f_mdwp
(
GetCurrentProcess
(),
GetCurrentProcessId
(),
GetCurrentProcessId
(),
hFile
,
hFile
,
type
,
type
,
ExInfop
,
ExInfop
,
NULL
,
NULL
,
NULL
);
NULL
);
CloseHandle
(
hFile
);
CloseHandle
(
hFile
);
}
}
}
}
}
}
// static
// static
void
LLWinDebug
::
generateMinidump
(
struct
_EXCEPTION_POINTERS
*
exception_infop
)
void
LLWinDebug
::
generateMinidump
(
struct
_EXCEPTION_POINTERS
*
exception_infop
)
{
{
std
::
string
dump_path
=
gDirUtilp
->
getExpandedFilename
(
LL_PATH_LOGS
,
std
::
string
dump_path
=
gDirUtilp
->
getExpandedFilename
(
LL_PATH_LOGS
,
"SecondLifeException"
);
"SecondLifeException"
);
if
(
exception_infop
)
if
(
exception_infop
)
{
{
// Since there is exception info... Release the hounds.
// Since there is exception info... Release the hounds.
gEmergencyMemoryReserve
.
release
();
gEmergencyMemoryReserve
.
release
();
_MINIDUMP_EXCEPTION_INFORMATION
ExInfo
;
_MINIDUMP_EXCEPTION_INFORMATION
ExInfo
;
ExInfo
.
ThreadId
=
::
GetCurrentThreadId
();
ExInfo
.
ThreadId
=
::
GetCurrentThreadId
();
ExInfo
.
ExceptionPointers
=
exception_infop
;
ExInfo
.
ExceptionPointers
=
exception_infop
;
ExInfo
.
ClientPointers
=
NULL
;
ExInfo
.
ClientPointers
=
NULL
;
writeDumpToFile
((
MINIDUMP_TYPE
)(
MiniDumpWithDataSegs
|
MiniDumpWithIndirectlyReferencedMemory
),
&
ExInfo
,
"SecondLife.dmp"
);
writeDumpToFile
((
MINIDUMP_TYPE
)(
MiniDumpWithDataSegs
|
MiniDumpWithIndirectlyReferencedMemory
),
&
ExInfo
,
"SecondLife.dmp"
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment