commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r897850 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_private.h os/unix/main.c os/unix/signals.c os/unix/uutils.c os/win32/wutil.c shared/bzip2.c shared/clazz.c shared/error.c shared/ini.c
Date Mon, 11 Jan 2010 13:06:25 GMT
Author: mturk
Date: Mon Jan 11 13:06:24 2010
New Revision: 897850

URL: http://svn.apache.org/viewvc?rev=897850&view=rev
Log:
Use debug macro that always prints to /dev/tty

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
    commons/sandbox/runtime/trunk/src/main/native/shared/bzip2.c
    commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
    commons/sandbox/runtime/trunk/src/main/native/shared/error.c
    commons/sandbox/runtime/trunk/src/main/native/shared/ini.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h?rev=897850&r1=897849&r2=897850&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h Mon Jan 11 13:06:24
2010
@@ -516,6 +516,12 @@
 #ifndef ACR_DO_STATS
 #define ACR_DO_STATS 1
 #endif
+#if defined(DEBUG)
+void acr_dbprintf(const char *, ...);
+#define ACR_DEBUG(x) acr_dbprintf x
+#endif
+#else
+#define ACR_DEBUG(x)
 #endif
 
 #ifdef __cplusplus

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c?rev=897850&r1=897849&r2=897850&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c Mon Jan 11 13:06:24 2010
@@ -88,10 +88,8 @@
     void   *epp;
 
     UNREFERENCED(reserved);
-#if defined(DEBUG)
-    fprintf(stdout, "JNI_Onload()\n");
-    fflush(stdout);
-#endif
+
+    ACR_DEBUG(("JNI_Onload"));
     if ((*vm)->GetEnv(vm, &epp, JNI_VERSION_1_4))
         return JNI_ERR;
     if (ACR_Initialize(vm)) {
@@ -193,3 +191,4 @@
 
     return tlsd->env;
 }
+

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c?rev=897850&r1=897849&r2=897850&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c Mon Jan 11 13:06:24 2010
@@ -39,10 +39,9 @@
     acr_seh_ctxt_t *ctxt = (acr_seh_ctxt_t *)pthread_getspecific(seh_ctxt_key);
     if (sig == SIGSEGV || sig == SIGBUS) {
         if (ctxt && ctxt->init) {
-            fprintf(stderr, "[error] Executing SEH handler for signal: %d (%s)\n",
-                    sig, ACR_SignalDescription(sig));
-            fprintf(stderr, "        Line: %d - %s\n", ctxt->line, ctxt->file);
-            fflush(stderr);
+            ACR_DEBUG(("[ERROR] Executing SEH handler for signal: %d (%s)",
+		       sig, ACR_SignalDescription(sig)));
+            ACR_DEBUG(("        Line: %d - %s", ctxt->line, ctxt->file));
             siglongjmp(ctxt->jump, 1);
         }
         else if (_signalset[sig]->sa_handler != SIG_DFL &&
@@ -56,10 +55,9 @@
             /* Not inside JVM.
              * Print some warning and abort
              */
-            fprintf(stderr, "[error] Cannot find default handler for signal '%s'\n",
-                    ACR_SignalDescription(sig));
-            fputs("        Aborting ...\n", stderr);
-            fflush(stderr);
+            ACR_DEBUG(("[error] Cannot find default handler for signal '%s'",
+		       ACR_SignalDescription(sig)));
+            ACR_DEBUG(("        Aborting ..."));
             abort();
         }
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c?rev=897850&r1=897849&r2=897850&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c Mon Jan 11 13:06:24 2010
@@ -24,6 +24,23 @@
 #include "acr_file.h"
 #include "acr_time.h"
 
+#if defined(DEBUG) || defined(_DEBUG)
+void acr_dbprintf(const char *format, ...)
+{
+    FILE    *stream;
+    va_list ap;
+
+    if (!(stream = fopen("/dev/tty", "a")))
+        return;
+    va_start(ap, format);
+    vfprintf(stream, format, ap);
+    va_end(ap);
+    fputc('\n', stream);
+    fflush(stream);
+    fclose(stream);
+}
+#endif
+
 char *acr_FileReadTxt(const char *name)
 {
     FILE  *f;

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c?rev=897850&r1=897849&r2=897850&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c Mon Jan 11 13:06:24 2010
@@ -28,6 +28,19 @@
 #include <direct.h>
 #define NON_UNC_PATH_LENGTH 248
 
+#if defined(DEBUG) || defined(_DEBUG)
+void acr_dbprintf(const char *format, ...)
+{
+    char    buf[8192];
+    va_list ap;
+
+    va_start(ap, format);
+    _vsnprintf(buf, sizeof(buf), format, ap);
+    va_end(ap);
+    OutputDebugStringA(buf);
+}
+#endif
+
 wchar_t *res_name_from_filenamew(int type, wchar_t *rname,
                                  const wchar_t *fname)
 {
@@ -577,3 +590,4 @@
         return ACR_StrdupW(_E, THROW_FMARK, name);
     }
 }
+

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/bzip2.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/bzip2.c?rev=897850&r1=897849&r2=897850&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/bzip2.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/bzip2.c Mon Jan 11 13:06:24 2010
@@ -29,6 +29,6 @@
     /* TODO: Make this as configurable callback
      * So that those messages can pop up in Java loggers.
      */
-    fprintf(stderr, "Internal bzlib error=(%d)\n", errorcode);
-    fflush(stderr);
+    ACR_DEBUG(("Internal bzlib error=(%d)", errorcode));
 }
+

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c?rev=897850&r1=897849&r2=897850&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c Mon Jan 11 13:06:24 2010
@@ -204,20 +204,14 @@
             core_classes[i].clazz = (jclass)(*_E)->NewGlobalRef(_E, o);
             (*_E)->DeleteLocalRef(_E, o);
             if (core_classes[i].clazz == NULL) {
-#ifdef DEBUG
-                fprintf(stderr, "[ERROR] Cannot reference core class '%s'\n",
-                        core_classes[i].name);
-                fflush(stderr);
-#endif
+                ACR_DEBUG(("[ERROR] Cannot reference core class '%s'",
+                           core_classes[i].name));
                 return ACR_ENOMEM;
             }
         }
         else {
-#ifdef DEBUG
-            fprintf(stderr, "[ERROR] Cannot find core class '%s'\n",
-                    core_classes[i].name);
-            fflush(stderr);
-#endif
+            ACR_DEBUG(("[ERROR] Cannot find core class '%s'",
+                       core_classes[i].name));
             return ACR_ESYMNOTFOUND;
         }
         i++;
@@ -266,10 +260,7 @@
             /* According to the JNI spec this can
              * happen if the system runs out of memory.
              */
-#ifdef DEBUG
-            fprintf(stderr, "[ERROR] Cannot reference class '%s'\n", name);
-            fflush(stderr);
-#endif
+            ACR_DEBUG(("[ERROR] Cannot reference class '%s'", name));
             return NULL;
         }
         (*_E)->DeleteLocalRef(_E, o);
@@ -283,10 +274,7 @@
         /* Class cannot fe found. The exception has already
          * been thrown.
          */
-#ifdef DEBUG
-        fprintf(stderr, "[ERROR] Cannot find class '%s'\n", name);
-        fflush(stderr);
-#endif
+        ACR_DEBUG(("[ERROR] Cannot find class '%s'", name));
     }
     return c;
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=897850&r1=897849&r2=897850&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Mon Jan 11 13:06:24 2010
@@ -65,24 +65,20 @@
     if (env == NULL)
         env = ACR_GetJNIEnv();
     if (IS_INVALID_HANDLE(env)) {
-#ifdef DEBUG
-        fprintf(stderr, "[ERROR]  JNI Environment is invalid or unavailable.\n");
-        fprintf(stderr, "[ERROR]  Throwing class '%s'\n", clazz);
-        if (msg)
-            fprintf(stderr, "[ERROR]  %s\n", msg);
-        fflush(stderr);
-#endif
+        ACR_DEBUG(("[ERROR]  JNI Environment is invalid or unavailable."));
+        ACR_DEBUG(("[ERROR]  Throwing class '%s'", clazz));
+        if (msg) {
+            ACR_DEBUG(("[ERROR]  %s", msg));
+        }
         return;
     }
     if ((*env)->ExceptionCheck(env)) {
         /* We already have a pending exception. */
-#ifdef DEBUG
-        fprintf(stderr, "[INFO]   Exception is already in the queue.\n");
-        fprintf(stderr, "[INFO]   Class '%s' was not thrown.\n", clazz);
-        if (msg)
-            fprintf(stderr, "[INFO]   %s\n", msg);
-        fflush(stderr);
-#endif
+        ACR_DEBUG(("[INFO]   Exception is already in the queue."));
+        ACR_DEBUG(("[INFO]   Class '%s' was not thrown.", clazz));
+        if (msg) {
+            ACR_DEBUG(("[INFO]   %s", msg));
+        }
         return;
     }
     ec = (*env)->FindClass(env, clazz);
@@ -91,12 +87,10 @@
          * the Exception has already been thrown.
          * See JNI Find Class for the Exceptions thrown.
          */
-#ifdef DEBUG
-        fprintf(stderr, "[ERROR]  Cannot find class '%s'\n", clazz);
-        if (msg)
-            fprintf(stderr, "[ERROR]  %s\n", msg);
-        fflush(stderr);
-#endif
+        ACR_DEBUG(("[ERROR]  Cannot find class '%s'", clazz));
+        if (msg) {
+            ACR_DEBUG(("[ERROR]  %s", msg));
+        }
         return;
     }
     (*env)->ThrowNew(env, ec, msg);
@@ -915,3 +909,4 @@
     char buf[512];
     return ACR_NewJavaStringA(_E, acr_os_strerror(buf, sizeof(buf), err));
 }
+

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/ini.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/ini.c?rev=897850&r1=897849&r2=897850&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/ini.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/ini.c Mon Jan 11 13:06:24 2010
@@ -847,7 +847,6 @@
                                 section, cur->name ? cur->name : "(null)",
                                 counter);
                 ACR_ThrowExceptionA(_E, THROW_NMARK, ACR_EX_EINVAL, buffer);
-                fprintf(stderr, "%s\n", buffer);
                 goto cleanup;
             }
             cur = ACR_IniSetParentAsCurrent(ini, cur);
@@ -859,7 +858,6 @@
             if (!ends) {
                 sprintf(buffer, "Unterminated section at line %d", counter);
                 ACR_ThrowExceptionA(_E, THROW_NMARK, ACR_EX_EINVAL, buffer);
-                fprintf(stderr, "%s\n", buffer);
                 goto cleanup;
             }
             *ends = '\0';



Mime
View raw message