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
612dddaf
Commit
612dddaf
authored
Jul 15, 2014
by
Philip Quinn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for exception backtraces on OS X.
parent
c8598892
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
exception.c++
c++/src/kj/exception.c++
+21
-1
No files found.
c++/src/kj/exception.c++
View file @
612dddaf
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "exception.h"
#include "exception.h"
#include "string.h"
#include "string.h"
#include "string-tree.h"
#include "debug.h"
#include "debug.h"
#include "threadlocal.h"
#include "threadlocal.h"
#include <unistd.h>
#include <unistd.h>
...
@@ -32,7 +33,7 @@
...
@@ -32,7 +33,7 @@
#include <execinfo.h>
#include <execinfo.h>
#endif
#endif
#if
__linux__
&& defined(KJ_DEBUG)
#if
(__linux__ || __APPLE__)
&& defined(KJ_DEBUG)
#include <stdio.h>
#include <stdio.h>
#include <pthread.h>
#include <pthread.h>
#endif
#endif
...
@@ -108,6 +109,23 @@ String getStackSymbols(ArrayPtr<void* const> trace) {
...
@@ -108,6 +109,23 @@ String getStackSymbols(ArrayPtr<void* const> trace) {
pthread_mutex_unlock
(
&
mutex
);
pthread_mutex_unlock
(
&
mutex
);
return
strArray
(
arrayPtr
(
lines
,
i
),
""
);
return
strArray
(
arrayPtr
(
lines
,
i
),
""
);
#elif __APPLE__ && defined(KJ_DEBUG)
// The Mac OS X equivalent of addr2line is atos(1).
// (Internally, it uses the private CoreSymbolication.framework library.)
FILE
*
p
=
popen
(
str
(
"atos -d -p "
,
getpid
(),
' '
,
strArray
(
trace
,
" "
)).
cStr
(),
"r"
);
if
(
p
==
nullptr
)
{
return
nullptr
;
}
StringTree
stackSymbols
;
char
line
[
512
];
while
(
fgets
(
line
,
sizeof
(
line
),
p
)
!=
nullptr
)
{
stackSymbols
=
strTree
(
mv
(
stackSymbols
),
str
(
line
));
}
pclose
(
p
);
return
stackSymbols
.
flatten
();
#else
#else
return
nullptr
;
return
nullptr
;
#endif
#endif
...
@@ -171,6 +189,7 @@ String KJ_STRINGIFY(const Exception& e) {
...
@@ -171,6 +189,7 @@ String KJ_STRINGIFY(const Exception& e) {
e
.
getDurability
()
==
Exception
::
Durability
::
TEMPORARY
?
" (temporary)"
:
""
,
e
.
getDurability
()
==
Exception
::
Durability
::
TEMPORARY
?
" (temporary)"
:
""
,
e
.
getDescription
()
==
nullptr
?
""
:
": "
,
e
.
getDescription
(),
e
.
getDescription
()
==
nullptr
?
""
:
": "
,
e
.
getDescription
(),
e
.
getStackTrace
().
size
()
>
0
?
"
\n
stack: "
:
""
,
strArray
(
e
.
getStackTrace
(),
" "
),
e
.
getStackTrace
().
size
()
>
0
?
"
\n
stack: "
:
""
,
strArray
(
e
.
getStackTrace
(),
" "
),
"
\n
"
,
getStackSymbols
(
e
.
getStackTrace
()));
getStackSymbols
(
e
.
getStackTrace
()));
}
}
...
@@ -330,6 +349,7 @@ private:
...
@@ -330,6 +349,7 @@ private:
e
.
getNature
(),
e
.
getDurability
()
==
Exception
::
Durability
::
TEMPORARY
?
" (temporary)"
:
""
,
e
.
getNature
(),
e
.
getDurability
()
==
Exception
::
Durability
::
TEMPORARY
?
" (temporary)"
:
""
,
e
.
getDescription
()
==
nullptr
?
""
:
": "
,
e
.
getDescription
(),
e
.
getDescription
()
==
nullptr
?
""
:
": "
,
e
.
getDescription
(),
e
.
getStackTrace
().
size
()
>
0
?
"
\n
stack: "
:
""
,
strArray
(
e
.
getStackTrace
(),
" "
),
e
.
getStackTrace
().
size
()
>
0
?
"
\n
stack: "
:
""
,
strArray
(
e
.
getStackTrace
(),
" "
),
"
\n
"
,
getStackSymbols
(
e
.
getStackTrace
()),
"
\n
"
));
getStackSymbols
(
e
.
getStackTrace
()),
"
\n
"
));
}
}
};
};
...
...
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