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
c5d67deb
Commit
c5d67deb
authored
Aug 07, 2014
by
Kenton Varda
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:kentonv/capnproto
parents
20f27660
f536c8cf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
15 deletions
+25
-15
Makefile.am
c++/Makefile.am
+1
-1
capnp.c++
c++/src/capnp/compiler/capnp.c++
+3
-0
exception.c++
c++/src/kj/exception.c++
+21
-14
No files found.
c++/Makefile.am
View file @
c5d67deb
...
...
@@ -33,7 +33,7 @@ clean-local:
cd
gtest
&&
$(MAKE)
$(AM_MAKEFLAGS)
clean
;
\
fi
AM_CXXFLAGS
=
-I
$(srcdir)
/src
-I
$(builddir)
/src
$(PTHREAD_CFLAGS)
AM_CXXFLAGS
=
-I
$(srcdir)
/src
-I
$(builddir)
/src
-DCAPNP_INCLUDE_DIR
=
'"
$(includedir)
"'
$(PTHREAD_CFLAGS)
AM_LDFLAGS
=
$(PTHREAD_CFLAGS)
...
...
c++/src/capnp/compiler/capnp.c++
View file @
c5d67deb
...
...
@@ -281,6 +281,9 @@ public:
if
(
addStandardImportPaths
)
{
loader
.
addImportPath
(
kj
::
heapString
(
"/usr/local/include"
));
loader
.
addImportPath
(
kj
::
heapString
(
"/usr/include"
));
#ifdef CAPNP_INCLUDE_DIR
loader
.
addImportPath
(
kj
::
heapString
(
CAPNP_INCLUDE_DIR
));
#endif
addStandardImportPaths
=
false
;
}
...
...
c++/src/kj/exception.c++
View file @
c5d67deb
...
...
@@ -32,7 +32,7 @@
#include <execinfo.h>
#endif
#if
__linux__
&& defined(KJ_DEBUG)
#if
(__linux__ || __APPLE__)
&& defined(KJ_DEBUG)
#include <stdio.h>
#include <pthread.h>
#endif
...
...
@@ -42,11 +42,11 @@ namespace kj {
namespace
{
String
getStackSymbols
(
ArrayPtr
<
void
*
const
>
trace
)
{
#if
__linux__
&& defined(KJ_DEBUG)
#if
(__linux__ || __APPLE__)
&& defined(KJ_DEBUG)
// We want to generate a human-readable stack trace.
// TODO(someday): It would be really great if we could avoid farming out to a
ddr2line and do
// this all in-process, but that may involve onerous requirements like large library
// TODO(someday): It would be really great if we could avoid farming out to a
nother process
//
and do
this all in-process, but that may involve onerous requirements like large library
// dependencies or using -rdynamic.
// The environment manipulation is not thread-safe, so lock a mutex. This could still be
...
...
@@ -55,15 +55,21 @@ String getStackSymbols(ArrayPtr<void* const> trace) {
// is in use.
static
pthread_mutex_t
mutex
=
PTHREAD_MUTEX_INITIALIZER
;
pthread_mutex_lock
(
&
mutex
);
KJ_DEFER
(
pthread_mutex_unlock
(
&
mutex
));
// Don't heapcheck / intercept syscalls
for addr2line
.
// Don't heapcheck / intercept syscalls.
const
char
*
preload
=
getenv
(
"LD_PRELOAD"
);
String
oldPreload
;
if
(
preload
!=
nullptr
)
{
oldPreload
=
heapString
(
preload
);
unsetenv
(
"LD_PRELOAD"
);
}
KJ_DEFER
(
if
(
oldPreload
!=
nullptr
)
{
setenv
(
"LD_PRELOAD"
,
oldPreload
.
cStr
(),
true
);
});
String
lines
[
8
];
FILE
*
p
=
nullptr
;
#if __linux__
// Get executable name from /proc/self/exe, then pass it and the stack trace to addr2line to
// get file/line pairs.
char
exe
[
512
];
...
...
@@ -73,9 +79,13 @@ String getStackSymbols(ArrayPtr<void* const> trace) {
}
exe
[
n
]
=
'\0'
;
String
lines
[
8
];
p
=
popen
(
str
(
"addr2line -e "
,
exe
,
' '
,
strArray
(
trace
,
" "
)).
cStr
(),
"r"
);
#elif __APPLE__
// The Mac OS X equivalent of addr2line is atos.
// (Internally, it uses the private CoreSymbolication.framework library.)
p
=
popen
(
str
(
"atos -d -p "
,
getpid
(),
' '
,
strArray
(
trace
,
" "
)).
cStr
(),
"r"
);
#endif
FILE
*
p
=
popen
(
str
(
"addr2line -e "
,
exe
,
' '
,
strArray
(
trace
,
" "
)).
cStr
(),
"r"
);
if
(
p
==
nullptr
)
{
return
nullptr
;
}
...
...
@@ -84,10 +94,13 @@ String getStackSymbols(ArrayPtr<void* const> trace) {
size_t
i
=
0
;
while
(
i
<
kj
::
size
(
lines
)
&&
fgets
(
line
,
sizeof
(
line
),
p
)
!=
nullptr
)
{
// Don't include exception-handling infrastructure in stack trace.
// addr2line output matches file names; atos output matches symbol names.
if
(
i
==
0
&&
(
strstr
(
line
,
"kj/common.c++"
)
!=
nullptr
||
strstr
(
line
,
"kj/exception."
)
!=
nullptr
||
strstr
(
line
,
"kj/debug."
)
!=
nullptr
))
{
strstr
(
line
,
"kj/debug."
)
!=
nullptr
||
strstr
(
line
,
"kj::Exception"
)
!=
nullptr
||
strstr
(
line
,
"kj::_::Debug"
)
!=
nullptr
))
{
continue
;
}
...
...
@@ -101,12 +114,6 @@ String getStackSymbols(ArrayPtr<void* const> trace) {
pclose
(
p
);
if
(
oldPreload
!=
nullptr
)
{
setenv
(
"LD_PRELOAD"
,
oldPreload
.
cStr
(),
true
);
}
pthread_mutex_unlock
(
&
mutex
);
return
strArray
(
arrayPtr
(
lines
,
i
),
""
);
#else
return
nullptr
;
...
...
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