Permalink
Browse files

SERVER-7856: record allocator and build flags in buildinfo

  • Loading branch information...
1 parent d718db4 commit 9e2543ec729da2a2176dc374ced0f2d29f723ad6 @scotthernandez scotthernandez committed Dec 18, 2012
View
@@ -26,6 +26,9 @@ buildinfo_template = '''
namespace mongo {
const char * gitVersion() { return "%(git_version)s"; }
+ const char * allocator() { return "%(allocator)s"; }
+ const char * loaderFlags() { return "%(loader_flags)s"; }
+ const char * compilerFlags() { return "%(compiler_flags)s"; }
std::string sysInfo() { return "%(sys_info)s BOOST_LIB_VERSION=" BOOST_LIB_VERSION ; }
} // namespace mongo
'''
@@ -36,7 +39,12 @@ def generate_buildinfo(env, target, source, **kw):
git_version += " modules: " + ", ".join(env["MONGO_MODULES"])
contents = str(source[0]) % dict(git_version=git_version,
- sys_info=getSysInfo())
+ sys_info=getSysInfo(),
+ allocator=GetOption('allocator'),
+ loader_flags=env.subst('$LINKFLAGS $LDFLAGS',
+ source=source, target=target),
+ compiler_flags=env.subst('$CXXFLAGS $CCFLAGS $CFLAGS',
+ source=source, target=target))
out = open(str(target[0]), 'wb')
try:
out.write(contents)
View
@@ -38,4 +38,4 @@ assert.gt( after.uptimeEstimate , before.uptimeEstimate , "up2" )
assert.eq( db.runCommand( "buildinfo" ).gitVersion,
- db.getSisterDB( "local" ).startup_log.find().sort( { $natural: -1 } ).limit(0)[0].gitVersion );
+ db.getSisterDB( "local" ).startup_log.find().sort( { $natural: -1 } ).limit(1).next().buildinfo.gitVersion );
View
@@ -250,12 +250,13 @@ namespace mongo {
curTimeString( buf );
toLog.append( "startTimeLocal", buf );
- toLog.append( "version", versionString );
- toLog.append( "gitVersion", gitVersion() );
-
toLog.append( "cmdLine", CmdLine::getParsedOpts() );
toLog.append( "pid", getpid() );
- toLog.append( "bits", static_cast<int>(sizeof(int*) * 8) );
+
+
+ BSONObjBuilder buildinfo( toLog.subobjStart("buildinfo"));
+ appendBuildInfo(buildinfo);
+ buildinfo.doneFast();
BSONObj o = toLog.obj();
@@ -594,6 +595,7 @@ namespace mongo {
log() << mongodVersion() << endl;
printGitVersion();
printSysInfo();
+ printAllocator();
printCommandLineOpts();
{
@@ -117,22 +117,18 @@ namespace mongo {
help << "get version #, etc.\n";
help << "{ buildinfo:1 }";
}
+
bool run(const std::string& dbname,
BSONObj& jsobj,
int, // options
std::string& errmsg,
BSONObjBuilder& result,
bool fromRepl) {
- result << "version" << versionString
- << "gitVersion" << gitVersion()
- << "sysInfo" << sysInfo()
- << "versionArray" << versionArray
- << "interpreterVersion" << globalScriptEngine->getInterpreterVersionString()
- << "bits" << ( sizeof( int* ) == 4 ? 32 : 64 );
- result.appendBool( "debug" , debug );
- result.appendNumber("maxBsonObjectSize", BSONObjMaxUserSize);
- return true;
+ appendBuildInfo(result);
+ return true;
+
}
+
} cmdBuildInfo;
View
@@ -23,6 +23,7 @@
#include <string>
#include <fstream>
#include "mongo/util/startup_test.h"
+#include "mongo/scripting/engine.h"
#include "version.h"
#include "stringutils.h"
#include "../db/jsobj.h"
@@ -95,6 +96,9 @@ namespace mongo {
#ifndef _SCONS
// only works in scons
const char * gitVersion() { return "not-scons"; }
+ const char * allocator() { return ""; }
+ const char * loaderFlags() { return ""; }
+ const char * compilerFlags() { return ""; }
#endif
void printGitVersion() { log() << "git version: " << gitVersion() << endl; }
@@ -114,13 +118,32 @@ namespace mongo {
}
#else
string sysInfo() { return ""; }
+
#endif
#endif
void printSysInfo() {
log() << "build info: " << sysInfo() << endl;
}
+ void printAllocator() {
+ log() << "allocator: " << allocator() << endl;
+ }
+
+ void appendBuildInfo(BSONObjBuilder& result) {
+ result << "version" << versionString
+ << "gitVersion" << gitVersion()
+ << "sysInfo" << sysInfo()
+ << "loaderFlags" << loaderFlags()
+ << "compilerFlags" << compilerFlags()
+ << "allocator" << allocator()
+ << "versionArray" << versionArray
+ << "interpreterVersion" << globalScriptEngine->getInterpreterVersionString()
+ << "bits" << ( sizeof( int* ) == 4 ? 32 : 64 );
+ result.appendBool( "debug" , debug );
+ result.appendNumber("maxBsonObjectSize", BSONObjMaxUserSize);
+ }
+
Tee* const startupWarningsLog = new RamLog("startupWarnings"); //intentionally leaked
View
@@ -20,6 +20,7 @@
#include <string>
#include "mongo/base/string_data.h"
+#include "mongo/bson/bsonobjbuilder.h"
namespace mongo {
struct BSONArray;
@@ -30,11 +31,18 @@ namespace mongo {
std::string mongodVersion();
int versionCmp(StringData rhs, StringData lhs); // like strcmp
+ void appendBuildInfo(BSONObjBuilder& result);
+
const char * gitVersion();
+ const char * allocator();
+ const char * loaderFlags();
+ const char * compilerFlags();
+
void printGitVersion();
std::string sysInfo();
void printSysInfo();
+ void printAllocator();
void show_warnings();

0 comments on commit 9e2543e

Please sign in to comment.