summaryrefslogtreecommitdiff
path: root/shell/dbshell.cpp
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-03-24 17:35:50 -0400
committerAaron <aaron@10gen.com>2009-03-24 17:35:50 -0400
commitcc6f3c9a259bcabf3ffd6153ced0cfe04785b289 (patch)
treebac041decde140fb88941919fdc9cd749d9d9992 /shell/dbshell.cpp
parentd0520ccafb1a68f2c441163bdbffc2e7f0a16936 (diff)
downloadmongo-cc6f3c9a259bcabf3ffd6153ced0cfe04785b289.tar.gz
Print debug info when mongo crashes
Diffstat (limited to 'shell/dbshell.cpp')
-rw-r--r--shell/dbshell.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/shell/dbshell.cpp b/shell/dbshell.cpp
index edaa3d9625a..35860c370a8 100644
--- a/shell/dbshell.cpp
+++ b/shell/dbshell.cpp
@@ -46,18 +46,42 @@ char * shellReadline( const char * prompt ){
#endif
}
+#if !defined(_WIN32)
+#include <execinfo.h>
+#include <string.h>
+
void quitNicely( int sig ){
shellHistoryDone();
exit(0);
}
+/* use "addr2line -CFe <exe>" to parse. */
+inline void printStackTrace() {
+ void *b[20];
+ size_t size;
+ char **strings;
+ size_t i;
+
+ size = backtrace(b, 20);
+ strings = backtrace_symbols(b, size);
+
+ for (i = 0; i < size; i++)
+ cout << hex << b[i] << ' ';
+ cout << '\n';
+ for (i = 0; i < size; i++)
+ cout << ' ' << strings[i] << '\n';
+ cout << dec;
+ free (strings);
+}
+
void quitAbruptly( int sig ) {
+ cout << "mongo got signal" << sig << " (" << strsignal( sig ) << "), stack trace: " << endl;
+ printStackTrace();
KillMongoProgramInstances();
exit(14);
}
void setupSignals() {
-#ifndef _WIN32
signal( SIGINT , quitNicely );
signal( SIGTERM , quitNicely );
signal( SIGPIPE , quitNicely ); // Maybe just log and continue?
@@ -65,8 +89,10 @@ void setupSignals() {
signal( SIGSEGV , quitAbruptly );
signal( SIGBUS , quitAbruptly );
signal( SIGFPE , quitAbruptly );
-#endif
}
+#else
+inline void setupSignals() {}
+#endif
string fixHost( string url , string host , string port ){
if ( host.size() == 0 && port.size() == 0 ){