Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
302dd170
Commit
302dd170
authored
Dec 03, 2017
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debug Windows: Dump stack on segfaults and such.
parent
64257713
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
1 deletion
+41
-1
exception.c++
c++/src/kj/exception.c++
+41
-1
No files found.
c++/src/kj/exception.c++
View file @
302dd170
...
...
@@ -348,7 +348,7 @@ BOOL WINAPI breakHandler(DWORD type) {
context
.
ContextFlags
=
CONTEXT_FULL
;
if
(
GetThreadContext
(
thread
,
&
context
))
{
void
*
traceSpace
[
32
];
auto
trace
=
getStackTrace
(
traceSpace
,
2
,
thread
,
context
);
auto
trace
=
getStackTrace
(
traceSpace
,
0
,
thread
,
context
);
ResumeThread
(
thread
);
auto
message
=
kj
::
str
(
"*** Received CTRL+C. stack: "
,
stringifyStackTraceAddresses
(
trace
),
...
...
@@ -369,11 +369,51 @@ BOOL WINAPI breakHandler(DWORD type) {
return
FALSE
;
// still crash
}
kj
::
StringPtr
exceptionDescription
(
DWORD
code
)
{
switch
(
code
)
{
case
EXCEPTION_ACCESS_VIOLATION
:
return
"access violation"
;
case
EXCEPTION_ARRAY_BOUNDS_EXCEEDED
:
return
"array bounds exceeded"
;
case
EXCEPTION_BREAKPOINT
:
return
"breakpoint"
;
case
EXCEPTION_DATATYPE_MISALIGNMENT
:
return
"datatype misalignment"
;
case
EXCEPTION_FLT_DENORMAL_OPERAND
:
return
"denormal floating point operand"
;
case
EXCEPTION_FLT_DIVIDE_BY_ZERO
:
return
"floating point division by zero"
;
case
EXCEPTION_FLT_INEXACT_RESULT
:
return
"inexact floating point result"
;
case
EXCEPTION_FLT_INVALID_OPERATION
:
return
"invalid floating point operation"
;
case
EXCEPTION_FLT_OVERFLOW
:
return
"floating point overflow"
;
case
EXCEPTION_FLT_STACK_CHECK
:
return
"floating point stack overflow"
;
case
EXCEPTION_FLT_UNDERFLOW
:
return
"floating point underflow"
;
case
EXCEPTION_ILLEGAL_INSTRUCTION
:
return
"illegal instruction"
;
case
EXCEPTION_IN_PAGE_ERROR
:
return
"page error"
;
case
EXCEPTION_INT_DIVIDE_BY_ZERO
:
return
"integer divided by zero"
;
case
EXCEPTION_INT_OVERFLOW
:
return
"integer overflow"
;
case
EXCEPTION_INVALID_DISPOSITION
:
return
"invalid disposition"
;
case
EXCEPTION_NONCONTINUABLE_EXCEPTION
:
return
"noncontinuable exception"
;
case
EXCEPTION_PRIV_INSTRUCTION
:
return
"privileged instruction"
;
case
EXCEPTION_SINGLE_STEP
:
return
"single step"
;
case
EXCEPTION_STACK_OVERFLOW
:
return
"stack overflow"
;
default
:
return
"(unknown exception code)"
;
}
}
LONG
WINAPI
sehHandler
(
EXCEPTION_POINTERS
*
info
)
{
void
*
traceSpace
[
32
];
auto
trace
=
getStackTrace
(
traceSpace
,
0
,
GetCurrentThread
(),
*
info
->
ContextRecord
);
auto
message
=
kj
::
str
(
"*** Received structured exception #0x"
,
hex
(
info
->
ExceptionRecord
->
ExceptionCode
),
": "
,
exceptionDescription
(
info
->
ExceptionRecord
->
ExceptionCode
),
"; stack: "
,
stringifyStackTraceAddresses
(
trace
),
stringifyStackTrace
(
trace
),
'\n'
);
FdOutputStream
(
STDERR_FILENO
).
write
(
message
.
begin
(),
message
.
size
());
return
EXCEPTION_EXECUTE_HANDLER
;
// still crash
}
}
// namespace
void
printStackTraceOnCrash
()
{
mainThreadId
=
GetCurrentThreadId
();
KJ_WIN32
(
SetConsoleCtrlHandler
(
breakHandler
,
TRUE
));
SetUnhandledExceptionFilter
(
&
sehHandler
);
}
#elif KJ_HAS_BACKTRACE
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment