* Merged with fd492236e7ac.
[cacao.git] / src / threads / threads-common.c
index e53c0f5667e0decad97b01dfa059c1090c04b357..d3d3074615bef8c49255cab8e21453a36986ab3e 100644 (file)
@@ -1,9 +1,7 @@
 /* src/threads/threads-common.c - machine independent thread functions
 
-   Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -43,6 +41,7 @@
 #include "native/include/java_lang_Thread.h"
 
 #if defined(WITH_CLASSPATH_GNU)
+# include "native/include/java_lang_Throwable.h"
 # include "native/include/java_lang_VMThread.h"
 #endif
 
@@ -454,7 +453,7 @@ bool threads_thread_start_internal(utf *name, functionptr f)
        LLNI_field_set_val(object, vm_thread, (java_lang_Object *) t);
 #endif
 
-       threads_thread_set_object(t, object);
+       threads_thread_set_object(t, (java_handle_t *) object);
 
        /* set java.lang.Thread fields */
 
@@ -842,6 +841,10 @@ void threads_dump(void)
        /* iterate over all started threads */
 
        for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
+               /* ignore threads which are in state NEW */
+               if (t->state == THREAD_STATE_NEW)
+                       continue;
+
                /* print thread info */
 
                printf("\n");
@@ -861,36 +864,39 @@ void threads_dump(void)
 
 /* threads_thread_print_stacktrace *********************************************
 
-   Print the current stacktrace of the current thread.
+   Print the current stacktrace of the given thread.
 
 *******************************************************************************/
 
 void threads_thread_print_stacktrace(threadobject *thread)
 {
-       stackframeinfo   *sfi;
-       stacktracebuffer *stb;
-       s4                dumpsize;
-
-       /* mark start of dump memory area */
-
-       dumpsize = dump_size();
+       stackframeinfo_t        *sfi;
+       java_handle_bytearray_t *ba;
+       stacktrace_t            *st;
 
-       /* create a stacktrace for the passed thread */
+       /* Build a stacktrace for the passed thread. */
 
        sfi = thread->_stackframeinfo;
 
-       stb = stacktrace_create(sfi);
+       ba = stacktrace_get();
+       
+       /* We need a critical section here as we use the byte-array data
+          pointer directly. */
+
+       LLNI_CRITICAL_START;
+       
+       st = (stacktrace_t *) LLNI_array_data(ba);
 
-       /* print stacktrace */
+       /* Print stacktrace. */
 
-       if (stb != NULL)
-               stacktrace_print_trace_from_buffer(stb);
+       if (st != NULL)
+               stacktrace_print(st);
        else {
                puts("\t<<No stacktrace available>>");
                fflush(stdout);
        }
 
-       dump_release(dumpsize);
+       LLNI_CRITICAL_END;
 }