jamvm

changeset 402:24373fc1d951

Add additional tracing support.

2008-08-04 Andrew John Hughes <gnu_andrew@member.fsf.org>

* .hgignore: Updated with autogen.sh output.
* configure.ac: Add new trace options.
* src/class.c,
* src/excep.c,
* src/natives.c,
* src/resolve.c: Add trace support.
* src/jam.h,
* src/dll.c,
* src/os/linux/os.c: Add support for reporting
the linking error using dlerror.
author andrew
date Tue Aug 05 05:46:09 2008 +0100 (2008-08-05)
parents 3ca4c2fbbd7f
children 907df5a02819
files .hgignore ChangeLog configure.ac src/class.c src/dll.c src/excep.c src/jam.h src/natives.c src/os/linux/os.c src/resolve.c
line diff
     1.1 --- a/.hgignore	Tue Aug 05 05:16:11 2008 +0100
     1.2 +++ b/.hgignore	Tue Aug 05 05:46:09 2008 +0100
     1.3 @@ -1,2 +1,10 @@
     1.4  patches
     1.5  tmp
     1.6 +.*Makefile.in
     1.7 +config.guess
     1.8 +config.sub
     1.9 +ltmain.sh
    1.10 +aclocal.m4
    1.11 +autom4te.cache
    1.12 +configure
    1.13 +src/config.h.in
     2.1 --- a/ChangeLog	Tue Aug 05 05:16:11 2008 +0100
     2.2 +++ b/ChangeLog	Tue Aug 05 05:46:09 2008 +0100
     2.3 @@ -5,6 +5,19 @@
     2.4  ==============
     2.5  2008-08-04  Andrew John Hughes  <gnu_andrew@member.fsf.org>
     2.6  
     2.7 +	* .hgignore: Updated with autogen.sh output.
     2.8 +	* configure.ac: Add new trace options.
     2.9 +	* src/class.c,
    2.10 +	* src/excep.c,
    2.11 +	* src/natives.c,
    2.12 +	* src/resolve.c: Add trace support.
    2.13 +	* src/jam.h,
    2.14 +	* src/dll.c,
    2.15 +	* src/os/linux/os.c: Add support for reporting
    2.16 +	the linking error using dlerror.
    2.17 +
    2.18 +2008-08-04  Andrew John Hughes  <gnu_andrew@member.fsf.org>
    2.19 +
    2.20  	* configure.ac: Credit CACAO for
    2.21  	--with-java-runtime-library macro.
    2.22  	* src/excep.c,
     3.1 --- a/configure.ac	Tue Aug 05 05:16:11 2008 +0100
     3.2 +++ b/configure.ac	Tue Aug 05 05:46:09 2008 +0100
     3.3 @@ -109,6 +109,30 @@
     3.4          AC_DEFINE([TRACEINLINING],1,[defined if interpreter inlining tracing enabled for debugging])
     3.5      fi],)
     3.6  
     3.7 +AC_ARG_ENABLE(traceclass,
     3.8 +    [AS_HELP_STRING(--enable-traceclass,add classfile parsing tracing (for debugging))],
     3.9 +    [if test "$enableval" != no; then
    3.10 +        AC_DEFINE([TRACECLASS],1,[defined if classfile parsing tracing enabled for debugging])
    3.11 +    fi],)
    3.12 +
    3.13 +AC_ARG_ENABLE(traceexcep,
    3.14 +    [AS_HELP_STRING(--enable-traceexcep,add exception handling tracing (for debugging))],
    3.15 +    [if test "$enableval" != no; then
    3.16 +        AC_DEFINE([TRACEEXCEP],1,[defined if exception handling tracing enabled for debugging])
    3.17 +    fi],)
    3.18 +
    3.19 +AC_ARG_ENABLE(tracenative,
    3.20 +    [AS_HELP_STRING(--enable-tracenative,add native method tracing (for debugging))],
    3.21 +    [if test "$enableval" != no; then
    3.22 +        AC_DEFINE([TRACENATIVE],1,[defined if native method tracing enabled for debugging])
    3.23 +    fi],)
    3.24 +
    3.25 +AC_ARG_ENABLE(traceresolve,
    3.26 +    [AS_HELP_STRING(--enable-traceresolve,add resolver tracing (for debugging))],
    3.27 +    [if test "$enableval" != no; then
    3.28 +        AC_DEFINE([TRACERESOLVE],1,[defined if resolver tracing enabled for debugging])
    3.29 +    fi],)
    3.30 +
    3.31  AC_ARG_ENABLE(trace,
    3.32      [AS_HELP_STRING(--enable-trace,add all tracing (for debugging))],
    3.33      [if test "$enableval" != no; then
    3.34 @@ -121,6 +145,10 @@
    3.35          AC_DEFINE([TRACECOMPACT],1,[defined if GC compaction phase tracing enabled for debugging])
    3.36          AC_DEFINE([TRACEDIRECT],1,[defined if interpreter direct-mode tracing enabled for debugging])
    3.37          AC_DEFINE([TRACEINLINING],1,[defined if interpreter inlining tracing enabled for debugging])
    3.38 +        AC_DEFINE([TRACECLASS],1,[defined if classfile parsing tracing enabled for debugging])
    3.39 +        AC_DEFINE([TRACEEXCEP],1,[defined if exception handling tracing enabled for debugging])
    3.40 +        AC_DEFINE([TRACENATIVE],1,[defined if native method tracing enabled for debugging])
    3.41 +        AC_DEFINE([TRACERESOLVE],1,[defined if resolver tracing enabled for debugging])
    3.42      fi],)
    3.43  
    3.44  AC_ARG_ENABLE(int-threading,
     4.1 --- a/src/class.c	Tue Aug 05 05:16:11 2008 +0100
     4.2 +++ b/src/class.c	Tue Aug 05 05:46:09 2008 +0100
     4.3 @@ -42,6 +42,12 @@
     4.4  #define SCAVENGE(ptr) FALSE
     4.5  #define FOUND(ptr) ptr
     4.6  
     4.7 +/* Trace classfile parsing */
     4.8 +#ifdef TRACECLASS
     4.9 +#define TRACE(fmt, ...) jam_printf(fmt, ## __VA_ARGS__)
    4.10 +#define TRACE(fmt, ...)
    4.11 +#endif
    4.12 +
    4.13  static int verbose;
    4.14  static char *bootpath;
    4.15  static char *classpath;
    4.16 @@ -163,6 +169,7 @@
    4.17      Class *class, *found;
    4.18      Class **interfaces;
    4.19  
    4.20 +    TRACE("<CLASS: Defining class %s>\n", classname);
    4.21      READ_U4(magic, ptr, len);
    4.22  
    4.23      if(magic != 0xcafebabe) {
    4.24 @@ -550,7 +557,11 @@
    4.25      classblock->super = super_idx ? resolveClass(class, super_idx, FALSE) : NULL;
    4.26  
    4.27      if(exceptionOccurred())
    4.28 -       return NULL;
    4.29 +      {
    4.30 +	TRACE("<CLASS: Exception %s occurred in defining class %s>\n",
    4.31 +	      CLASS_CB(getExecEnv()->exception->class)->name, classname);
    4.32 +	return NULL;
    4.33 +      }
    4.34  
    4.35      classblock->state = CLASS_LOADED;
    4.36  
     5.1 --- a/src/dll.c	Tue Aug 05 05:16:11 2008 +0100
     5.2 +++ b/src/dll.c	Tue Aug 05 05:46:09 2008 +0100
     5.3 @@ -206,6 +206,7 @@
     5.4      void *func = resolveNativeMethod(mb);
     5.5  
     5.6      if(func == NULL) {
     5.7 +        TRACE("<DLL: Couldn't link %s in %s>\n", mb->name, CLASS_CB(class)->name);
     5.8          signalException(java_lang_UnsatisfiedLinkError, mb->name);
     5.9          return ostack;
    5.10      }
    5.11 @@ -255,8 +256,10 @@
    5.12          DllEntry *dll2;
    5.13          void *onload, *handle = nativeLibOpen(name);
    5.14  
    5.15 -        if(handle == NULL)
    5.16 +        if(handle == NULL) {
    5.17 +	    TRACE("<DLL: Load failed: %s>\n", nativeLibError());
    5.18              return FALSE;
    5.19 +	}
    5.20  
    5.21          TRACE("<DLL: Successfully opened library %s>\n", name);
    5.22  
     6.1 --- a/src/excep.c	Tue Aug 05 05:16:11 2008 +0100
     6.2 +++ b/src/excep.c	Tue Aug 05 05:46:09 2008 +0100
     6.3 @@ -26,6 +26,12 @@
     6.4  #include "symbol.h"
     6.5  #include "excep.h"
     6.6  
     6.7 +/* Trace exception handling */
     6.8 +#ifdef TRACEEXCEP
     6.9 +#define TRACE(fmt, ...) jam_printf(fmt, ## __VA_ARGS__)
    6.10 +#define TRACE(fmt, ...)
    6.11 +#endif
    6.12 +
    6.13  static Class *ste_class, *ste_array_class, *throw_class, *vmthrow_class;
    6.14  static MethodBlock *vmthrow_init_mb;
    6.15  static int backtrace_offset;
    6.16 @@ -134,6 +140,8 @@
    6.17  }
    6.18  
    6.19  void signalChainedExceptionEnum(int excep_enum, char *message, Object *cause) {
    6.20 +    TRACE("<EXCEP: Exception with message %s and cause %s>\n", message,
    6.21 +      cause ? CLASS_CB(cause->class)->name : "unknown");
    6.22      if(!inited) {
    6.23          char *excep_name = symbol_values[exception_symbols[excep_enum]];
    6.24  
     7.1 --- a/src/jam.h	Tue Aug 05 05:16:11 2008 +0100
     7.2 +++ b/src/jam.h	Tue Aug 05 05:46:09 2008 +0100
     7.3 @@ -903,6 +903,7 @@
     7.4  extern void nativeLibClose(void *handle);
     7.5  extern char *nativeLibMapName(char *name);
     7.6  extern void *nativeLibSym(void *handle, char *symbol);
     7.7 +extern char *nativeLibError();
     7.8  extern void *nativeStackBase();
     7.9  extern int nativeAvailableProcessors();
    7.10  
     8.1 --- a/src/natives.c	Tue Aug 05 05:16:11 2008 +0100
     8.2 +++ b/src/natives.c	Tue Aug 05 05:46:09 2008 +0100
     8.3 @@ -37,6 +37,12 @@
     8.4  #include "symbol.h"
     8.5  #include "excep.h"
     8.6  
     8.7 +/* Trace native method handling */
     8.8 +#ifdef TRACENATIVE
     8.9 +#define TRACE(fmt, ...) jam_printf(fmt, ## __VA_ARGS__)
    8.10 +#define TRACE(fmt, ...)
    8.11 +#endif
    8.12 +
    8.13  static int pd_offset;
    8.14  
    8.15  void initialiseNatives() {
     9.1 --- a/src/os/linux/os.c	Tue Aug 05 05:16:11 2008 +0100
     9.2 +++ b/src/os/linux/os.c	Tue Aug 05 05:46:09 2008 +0100
     9.3 @@ -73,3 +73,7 @@
     9.4     sprintf(buff, "lib%s.so", name);
     9.5     return buff;
     9.6  }
     9.7 +
     9.8 +char *nativeLibError() {
     9.9 +  return dlerror();
    9.10 +}
    10.1 --- a/src/resolve.c	Tue Aug 05 05:16:11 2008 +0100
    10.2 +++ b/src/resolve.c	Tue Aug 05 05:46:09 2008 +0100
    10.3 @@ -25,15 +25,22 @@
    10.4  #include "symbol.h"
    10.5  #include "excep.h"
    10.6  
    10.7 +#ifdef TRACERESOLVE
    10.8 +#define TRACE(fmt, ...) jam_printf(fmt, ## __VA_ARGS__)
    10.9 +#define TRACE(fmt, ...)
   10.10 +#endif
   10.11 +
   10.12  MethodBlock *findMethod(Class *class, char *methodname, char *type) {
   10.13     ClassBlock *cb = CLASS_CB(class);
   10.14     MethodBlock *mb = cb->methods;
   10.15     int i;
   10.16  
   10.17 -   for(i = 0; i < cb->methods_count; i++,mb++)
   10.18 +   TRACE("<RESOLVE: Searching for method: %s with type: %s in class %s>\n", methodname, type, cb->name);
   10.19 +   for(i = 0; i < cb->methods_count; i++,mb++) {
   10.20 +       TRACE("<RESOLVE: Checking method: %s with type: %s>\n", mb->name, mb->type);
   10.21         if(mb->name == methodname && mb->type == type)
   10.22            return mb;
   10.23 -
   10.24 +   }
   10.25     return NULL;
   10.26  }
   10.27