summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-06-27 14:35:05 -0400
committerDwight <dmerriman@gmail.com>2008-06-27 14:35:05 -0400
commitd3e3876751b6becc9084b5508fd0a48178f30b1b (patch)
tree46d2e86cc3bfda7a5b41fb0092e3c060a7b8ebd2
parent0c4751cb7856a849963841e59784d5058557e9a0 (diff)
downloadmongo-d3e3876751b6becc9084b5508fd0a48178f30b1b.tar.gz
stack traces
-rw-r--r--db/db.cpp2
-rw-r--r--db/makefile2
-rw-r--r--db/pdfile.cpp1
-rw-r--r--db/tests.cpp3
-rw-r--r--stdafx.h2
-rw-r--r--util/goodies.h20
6 files changed, 28 insertions, 2 deletions
diff --git a/db/db.cpp b/db/db.cpp
index 7986980ec72..130636ca23a 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -347,7 +347,7 @@ public:
115 replay, opLogging
*/
void listen(int port) {
- const char *Version = "db version: 117 24jun2008";
+ const char *Version = "db version: 118 27jun2008";
problem() << Version << endl;
cout << Version << endl;
pdfileInit();
diff --git a/db/makefile b/db/makefile
index 7ddbcfcb1f1..76d8cbfdb2f 100644
--- a/db/makefile
+++ b/db/makefile
@@ -1,6 +1,6 @@
# makefile for our db project
-FLAGS= ${CFLAGS} -fPIC -ggdb -pthread -O3 -I .. -Isrc/p -I/src/p/db -L/usr/local/lib -L/usr/lib
+FLAGS= ${CFLAGS} -fPIC -ggdb -pthread -O3 -I .. -Isrc/p -I/src/p/db -L/usr/local/lib -L/usr/lib -rdynamic
LIB_DEPS = -lpcrecpp -lpcre
LIB_BOOST = -lboost_thread -lboost_filesystem
diff --git a/db/pdfile.cpp b/db/pdfile.cpp
index c39191d42a7..1ec6a11142d 100644
--- a/db/pdfile.cpp
+++ b/db/pdfile.cpp
@@ -40,6 +40,7 @@ void sayDbContext(const char *errmsg) {
cout << " op:" << curOp << ' ' << callDepth << endl;
if( client )
cout << " ns: " << curNs << endl;
+ printStackTrace();
}
JSObj::JSObj(Record *r) {
diff --git a/db/tests.cpp b/db/tests.cpp
index 3d07fcf1aed..1fac4d76573 100644
--- a/db/tests.cpp
+++ b/db/tests.cpp
@@ -8,6 +8,9 @@
int test2() {
cout << "test2" << endl;
+ printStackTrace();
+ if( 1 )
+ return 1;
MemoryMappedFile f;
diff --git a/stdafx.h b/stdafx.h
index 502f91aa0f2..d2c5effcd6d 100644
--- a/stdafx.h
+++ b/stdafx.h
@@ -140,3 +140,5 @@ void dbexit(int resultcode);
#define assert xassert
#define yassert 1
using namespace boost::filesystem;
+
+#include "util/goodies.h"
diff --git a/util/goodies.h b/util/goodies.h
index 7f2a4f7cb34..8bb25f31afa 100644
--- a/util/goodies.h
+++ b/util/goodies.h
@@ -8,6 +8,26 @@
#if !defined(_WIN32)
#include <pthread.h>
inline pthread_t GetCurrentThreadId() { return pthread_self(); }
+#include <execinfo.h>
+/* use "addr2line -CFe <exe>" to parse. */
+inline void printStackTrace() {
+ void *b[12];
+ size_t size;
+ char **strings;
+ size_t i;
+
+ size = backtrace(b, 12);
+ strings = backtrace_symbols(b, size);
+
+ for (i = 0; i < size; i++)
+ cout << ' ' << hex << b[i] << '\n';
+ for (i = 0; i < size; i++)
+ cout << ' ' << strings[i] << '\n';
+
+ free (strings);
+}
+#else
+inline void printStackTrace() { }
#endif
/* set to TRUE if we are exiting */