mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
Merge branch 'master' of git@github.com:mongodb/mongo
This commit is contained in:
commit
77cacf8451
@ -278,7 +278,7 @@ if GetOption( "extralib" ) is not None:
|
||||
|
||||
commonFiles = Split( "stdafx.cpp buildinfo.cpp db/jsobj.cpp db/json.cpp db/commands.cpp db/lasterror.cpp db/nonce.cpp db/queryutil.cpp shell/mongo.cpp" )
|
||||
commonFiles += [ "util/background.cpp" , "util/mmap.cpp" , "util/sock.cpp" , "util/util.cpp" , "util/message.cpp" ,
|
||||
"util/assert_util.cpp" , "util/httpclient.cpp" , "util/md5main.cpp" , "util/base64.cpp" ]
|
||||
"util/assert_util.cpp" , "util/httpclient.cpp" , "util/md5main.cpp" , "util/base64.cpp", "util/debug_util.cpp" ]
|
||||
commonFiles += Glob( "util/*.c" )
|
||||
commonFiles += Split( "client/connpool.cpp client/dbclient.cpp client/model.cpp client/parallel.cpp" )
|
||||
commonFiles += [ "scripting/engine.cpp" ]
|
||||
|
31
db/db.cpp
31
db/db.cpp
@ -956,32 +956,6 @@ namespace mongo {
|
||||
exitCleanly();
|
||||
}
|
||||
|
||||
/* Magic gdb trampoline
|
||||
* Assumptions:
|
||||
* 1) gdbserver is on your path
|
||||
* 2) You have run "handle SIGSTOP noprint" in gdb
|
||||
* 3) cmdLine.port + 2000 is free
|
||||
*/
|
||||
void launchGDB(int){
|
||||
// Don't come back here
|
||||
signal(SIGTRAP, SIG_IGN);
|
||||
|
||||
int newPort = cmdLine.port + 2000;
|
||||
string newPortStr = "localhost:" + BSONObjBuilder::numStr(newPort);
|
||||
string pidToDebug = BSONObjBuilder::numStr(getpid());
|
||||
|
||||
cout << "\n\n\t**** Launching gdbserver on " << newPortStr << " ****" << endl << endl;
|
||||
if (fork() == 0){
|
||||
//child
|
||||
execlp("gdbserver", "gdbserver", "--attach", newPortStr.c_str(), pidToDebug.c_str(), NULL);
|
||||
perror(NULL);
|
||||
}else{
|
||||
//parent
|
||||
raise(SIGSTOP); // pause all threads until gdb connects and continues
|
||||
raise(SIGTRAP); // break inside gdbserver
|
||||
}
|
||||
}
|
||||
|
||||
void setupSignals() {
|
||||
assert( signal(SIGSEGV, abruptQuit) != SIG_ERR );
|
||||
assert( signal(SIGFPE, abruptQuit) != SIG_ERR );
|
||||
@ -990,10 +964,7 @@ namespace mongo {
|
||||
assert( signal(SIGPIPE, pipeSigHandler) != SIG_ERR );
|
||||
assert( signal(SIGUSR1 , rotateLogs ) != SIG_ERR );
|
||||
|
||||
#ifdef _DEBUG //build with scons --dd to get this flag
|
||||
// if running in gdb we never get this signal
|
||||
assert( signal(SIGTRAP , launchGDB ) != SIG_ERR );
|
||||
#endif
|
||||
setupSIGTRAPforGDB();
|
||||
|
||||
sigemptyset( &asyncSignals );
|
||||
sigaddset( &asyncSignals, SIGINT );
|
||||
|
@ -1117,6 +1117,7 @@ namespace mongo {
|
||||
|
||||
/** append an element but with a new name */
|
||||
void appendAs(const BSONElement& e, const char *as) {
|
||||
assert( !e.eoo() ); // do not append eoo, that would corrupt us. the builder auto appends when done() is called.
|
||||
b.append((char) e.type());
|
||||
b.append(as);
|
||||
b.append((void *) e.value(), e.valuesize());
|
||||
|
@ -92,6 +92,7 @@ namespace mongo {
|
||||
|
||||
void init(){
|
||||
serverID.init();
|
||||
setupSIGTRAPforGDB();
|
||||
}
|
||||
|
||||
void start() {
|
||||
|
59
util/debug_util.cpp
Normal file
59
util/debug_util.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
// debug_util.cpp
|
||||
|
||||
/* Copyright 2009 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "../db/cmdline.h"
|
||||
#include "../db/jsobj.h"
|
||||
|
||||
namespace mongo {
|
||||
|
||||
#if defined(_DEBUG) && !defined(_WIN32)
|
||||
/* Magic gdb trampoline
|
||||
* Do not call directly! call setupSIGTRAPforGDB()
|
||||
* Assumptions:
|
||||
* 1) gdbserver is on your path
|
||||
* 2) You have run "handle SIGSTOP noprint" in gdb
|
||||
* 3) cmdLine.port + 2000 is free
|
||||
*/
|
||||
void launchGDB(int){
|
||||
// Don't come back here
|
||||
signal(SIGTRAP, SIG_IGN);
|
||||
|
||||
int newPort = cmdLine.port + 2000;
|
||||
string newPortStr = "localhost:" + BSONObjBuilder::numStr(newPort);
|
||||
string pidToDebug = BSONObjBuilder::numStr(getpid());
|
||||
|
||||
cout << "\n\n\t**** Launching gdbserver on " << newPortStr << " ****" << endl << endl;
|
||||
if (fork() == 0){
|
||||
//child
|
||||
execlp("gdbserver", "gdbserver", "--attach", newPortStr.c_str(), pidToDebug.c_str(), NULL);
|
||||
perror(NULL);
|
||||
}else{
|
||||
//parent
|
||||
raise(SIGSTOP); // pause all threads until gdb connects and continues
|
||||
raise(SIGTRAP); // break inside gdbserver
|
||||
}
|
||||
}
|
||||
|
||||
void setupSIGTRAPforGDB(){
|
||||
assert( signal(SIGTRAP , launchGDB ) != SIG_ERR );
|
||||
}
|
||||
#else
|
||||
void setupSIGTRAPforGDB() {
|
||||
}
|
||||
#endif
|
||||
}
|
@ -66,6 +66,10 @@ namespace mongo {
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
// Sets SIGTRAP handler to launch GDB
|
||||
// Noop unless on *NIX and compiled with _DEBUG
|
||||
void setupSIGTRAPforGDB();
|
||||
|
||||
#if defined(_WIN32)
|
||||
inline void breakpoint() {} //noop
|
||||
#else // defined(_WIN32)
|
||||
|
Loading…
Reference in New Issue
Block a user