Add a 'directlog' option to allow logging to an exact file am: 18abf82e52 am: cffbb6caea
am: b7974f02a3

Change-Id: I2f63a0f99b8a93ac22c3f8434cc5664721966ef6
diff --git a/src/share/back/debugInit.c b/src/share/back/debugInit.c
index a11a9bc..7589085 100644
--- a/src/share/back/debugInit.c
+++ b/src/share/back/debugInit.c
@@ -89,6 +89,8 @@
 static jboolean suspendOnInit = JNI_TRUE;   /* suspend all app threads after init */
 static jboolean dopause = JNI_FALSE;        /* pause for debugger attach */
 static jboolean docoredump = JNI_FALSE;     /* core dump on exit */
+/* ANDROID-CHANGED: Added directlog option */
+static jboolean directlog = JNI_FALSE;      /* Don't add pid to logfile. */
 static char *logfile = NULL;                /* Name of logfile (if logging) */
 static unsigned logflags = 0;               /* Log flags */
 
@@ -1003,6 +1005,8 @@
  "pause=y|n                    pause to debug PID                n\n"
  "coredump=y|n                 coredump at exit                  n\n"
  "errorexit=y|n                exit on any error                 n\n"
+ /* ANDROID-CHANGED: Added directlog */
+ "directlog                    do not add pid to name of logfile n\n"
  "logfile=filename             name of log file                  none\n"
  "logflags=flags               log flags (bitmask)               none\n"
  "                               JVM calls     = 0x001\n"
@@ -1108,6 +1112,8 @@
     /* Set defaults */
     gdata->assertOn     = DEFAULT_ASSERT_ON;
     gdata->assertFatal  = DEFAULT_ASSERT_FATAL;
+    /* ANDROID-CHANGED: Add directlog */
+    directlog           = JNI_FALSE;
     logfile             = DEFAULT_LOGFILE;
     // ANDROID-CHANGED: By default we assume ddms is off initially.
     gdata->ddmInitiallyActive = JNI_FALSE;
@@ -1263,6 +1269,12 @@
         } else if (strcmp(buf, "precrash") == 0) {
             errmsg = "The precrash option removed, use -XX:OnError";
             goto bad_option_with_errmsg;
+        } else if (strcmp(buf, "directlog") == 0) {
+            /* ANDROID-CHANGED: Added directlog */
+            /*LINTED*/
+            if ( !get_boolean(&str, &directlog) ) {
+                goto syntax_error;
+            }
         } else if (strcmp(buf, "logfile") == 0) {
             /*LINTED*/
             if (!get_tok(&str, current, (int)(end - current), ',')) {
@@ -1324,7 +1336,8 @@
 
     /* Setup logging now */
     if ( logfile!=NULL ) {
-        setup_logging(logfile, logflags);
+        /* ANDROID-CHANGED: Add directlog */
+        setup_logging(logfile, logflags, directlog);
         (void)atexit(&atexit_finish_logging);
     }
 
diff --git a/src/share/back/log_messages.c b/src/share/back/log_messages.c
index 32bea29..78b21c2 100644
--- a/src/share/back/log_messages.c
+++ b/src/share/back/log_messages.c
@@ -202,8 +202,9 @@
 #endif
 
 /* Set up the logging with the name of a logging file. */
+/* ANDROID-CHANGED: Added directlog */
 void
-setup_logging(const char *filename, unsigned flags)
+setup_logging(const char *filename, unsigned flags, int directlog)
 {
 #ifdef JDWP_LOGGING
     FILE *fp = NULL;
@@ -217,9 +218,14 @@
         return;
 
     /* Create potential filename for logging */
-    processPid = GETPID();
-    (void)snprintf(logging_filename, sizeof(logging_filename),
-                    "%s.%d", filename, (int)processPid);
+    /* ANDROID-CHANGED: Add directlog */
+    if (directlog) {
+      strncpy(logging_filename, filename, sizeof(logging_filename));
+    } else {
+      processPid = GETPID();
+      (void)snprintf(logging_filename, sizeof(logging_filename),
+                      "%s.%d", filename, (int)processPid);
+    }
 
     /* Turn on logging (do this last) */
     logging = 1;
diff --git a/src/share/back/log_messages.h b/src/share/back/log_messages.h
index 129fab6..23833bf 100644
--- a/src/share/back/log_messages.h
+++ b/src/share/back/log_messages.h
@@ -28,7 +28,8 @@
 
 /* LOG: Must be called like:  LOG_category(("anything")) or LOG_category((format,args)) */
 
-void setup_logging(const char *, unsigned);
+/* ANDROID-CHANGED: Added directlog argument */
+void setup_logging(const char *, unsigned, int);
 void finish_logging();
 
 #define LOG_NULL ((void)0)