snapshot: replace DumpIntoLog() with lighter-weight debugging
authorBrian Norris <banorris@uci.edu>
Thu, 14 Jun 2012 06:13:29 +0000 (23:13 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 14 Jun 2012 06:17:20 +0000 (23:17 -0700)
This file I/O "debug" messaging gets in the way. Make the debugging code simple
and succinct, or don't put it in at all. Now, you can enabled SnapShot
debugging by adding this near the top of snapshot.cc:

 #define CONFIG_DEBUG

snapshot.cc

index 378f53b5496f131926dff662cf276edbce594195..51d2a3adbb4842902db2fab53ceda4f61dbb48d9 100644 (file)
 
 #define FAILURE(mesg) { printf("failed in the API: %s with errno relative message: %s\n", mesg, strerror( errno ) ); exit(EXIT_FAILURE); }
 
+#ifdef CONFIG_SSDEBUG
+#define SSDEBUG                printf
+#else
+#define SSDEBUG(...)   do { } while (0)
+#endif
+
 /* extern declaration definition */
 #if USE_MPROTECT_SNAPSHOT
 struct SnapShot * snapshotrecord = NULL;
@@ -26,18 +32,7 @@ struct Snapshot_t * sTheRecord = NULL;
 #else
 struct Snapshot_t * sTheRecord = NULL;
 #endif
-void DumpIntoLog( const char * filename, const char * message ){
-#if SSDEBUG
-       static pid_t thePID = getpid();
-       char newFn[ 1024 ] ={ 0 };
-       sprintf( newFn,"%s-%d.txt", filename, thePID );
-       FILE * myFile = fopen( newFn, "w+" );
-       fprintf( myFile, "the message %s: the process id %d\n", message, thePID );
-       fflush( myFile );
-       fclose( myFile );
-       myFile = NULL;
-#endif
-}
+
 #if !USE_MPROTECT_SNAPSHOT
 static ucontext_t savedSnapshotContext;
 static ucontext_t savedUserSnapshotContext;
@@ -226,11 +221,10 @@ void initSnapShotLibrary(unsigned int numbackingpages,
                } else {
                        int status;
                        int retVal;
-#if SSDEBUG
-                       char mesg[ 1024 ] = { 0 };
-                       sprintf( mesg, "The process id of child is %d and the process id of this process is %d and snapshot id is %d", forkedID, getpid(), snapshotid );
-                       DumpIntoLog( "ModelSnapshot", mesg );
-#endif
+
+                       SSDEBUG("The process id of child is %d and the process id of this process is %d and snapshot id is %d",
+                               forkedID, getpid(), snapshotid );
+
                        do {
                                retVal=waitpid( forkedID, &status, 0 );
                        } while( -1 == retVal && errno == EINTR );
@@ -323,9 +317,7 @@ void rollBack( snapshot_id theID ){
        getcontext( &sTheRecord->mContextToRollback );
        if( !sTemp ){
                sTemp = 1;
-#if SSDEBUG
-               DumpIntoLog( "ModelSnapshot", "Invoked rollback" );
-#endif
+               SSDEBUG("Invoked rollback");
                exit(EXIT_SUCCESS);
        }
 #endif