Skip to content

Commit

Permalink
make StackChecker a little easier to read, debug
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Apr 16, 2012
1 parent aa7709f commit 722f856
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/mongo/db/client.cpp
Expand Up @@ -62,17 +62,26 @@ namespace mongo {
static int max;
StackChecker *sc = checker.get();
const char *p = sc->buf;
int i = 0;
for( ; i < SZ; i++ ) {
if( p[i] != 42 )

int lastStackByteModifed = 0;
for( ; lastStackByteModifed < SZ; lastStackByteModifed++ ) {
if( p[lastStackByteModifed] != 42 )
break;
}
int z = SZ-i;
if( z > max ) {
max = z;
log() << "thread " << tname << " stack usage was " << z << " bytes" << endl;
int numberBytesUsed = SZ-lastStackByteModifed;

if( numberBytesUsed > max ) {
max = numberBytesUsed;
log() << "thread " << tname << " stack usage was " << numberBytesUsed << " bytes, "
<< " which is the most so far" << endl;
}

if ( numberBytesUsed > ( SZ - 16000 ) ) {
// we are within 16000 bytes of SZ
log() << "used " << numberBytesUsed << " bytes, max is " << (int)SZ << " exiting" << endl;
fassertFailed( 16151 );
}
wassert( i > 16000 );

}
};
#endif
Expand Down

0 comments on commit 722f856

Please sign in to comment.