bd02f9401af39c1a49cc82105cec133bb80f08cb
[cacao.git] / src / threads / threads-common.c
1 /* src/threads/threads-common.c - machine independent thread functions
2
3    Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25 */
26
27
28 #include "config.h"
29
30 #include <assert.h>
31 #include <stdint.h>
32 #include <unistd.h>
33
34 #include "vm/types.h"
35
36 #include "mm/memory.h"
37
38 #include "native/jni.h"
39 #include "native/llni.h"
40
41 #include "native/include/java_lang_Object.h"
42 #include "native/include/java_lang_String.h"
43 #include "native/include/java_lang_Thread.h"
44
45 #if defined(WITH_CLASSPATH_GNU)
46 # include "native/include/java_lang_Throwable.h"
47 # include "native/include/java_lang_VMThread.h"
48 #endif
49
50 #include "threads/critical.h"
51 #include "threads/lock-common.h"
52 #include "threads/threads-common.h"
53
54 #include "toolbox/list.h"
55
56 #include "vm/builtin.h"
57 #include "vm/stringlocal.h"
58 #include "vm/vm.h"
59
60 #include "vm/jit/stacktrace.h"
61
62 #include "vmcore/class.h"
63 #include "vmcore/options.h"
64
65 #if defined(ENABLE_STATISTICS)
66 # include "vmcore/statistics.h"
67 #endif
68
69 #include "vmcore/utf8.h"
70
71
72 /* global variables ***********************************************************/
73
74 /* global threads list */
75 static list_t *list_threads;
76
77 /* global threads free-list */
78
79 typedef struct thread_index_t {
80         int32_t    index;
81         listnode_t linkage;
82 } thread_index_t;
83
84 static list_t *list_free_thread_index;
85
86 #if defined(__LINUX__)
87 /* XXX Remove for exact-GC. */
88 bool threads_pthreads_implementation_nptl;
89 #endif
90
91
92 /* threads_preinit *************************************************************
93
94    Do some early initialization of stuff required.
95
96    ATTENTION: Do NOT use any Java heap allocation here, as gc_init()
97    is called AFTER this function!
98
99 *******************************************************************************/
100
101 void threads_preinit(void)
102 {
103         threadobject *mainthread;
104 #if defined(__LINUX__) && defined(_CS_GNU_LIBPTHREAD_VERSION)
105         char         *pathbuf;
106         size_t        len;
107 #endif
108
109 #if defined(__LINUX__)
110         /* XXX Remove for exact-GC. */
111
112         /* On Linux we need to check the pthread implementation. */
113
114         /* _CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2) */
115         /* If the glibc is a pre-2.3.2 version, we fall back to
116            linuxthreads. */
117
118 # if defined(_CS_GNU_LIBPTHREAD_VERSION)
119         len = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (size_t) 0);
120
121         /* Some systems return as length 0 (maybe cross-compilation
122            related).  In this case we also fall back to linuxthreads. */
123
124         if (len > 0) {
125                 pathbuf = MNEW(char, len);
126
127                 (void) confstr(_CS_GNU_LIBPTHREAD_VERSION, pathbuf, len);
128
129                 if (strstr(pathbuf, "NPTL") != NULL)
130                         threads_pthreads_implementation_nptl = true;
131                 else
132                         threads_pthreads_implementation_nptl = false;
133         }
134         else
135                 threads_pthreads_implementation_nptl = false;
136 # else
137         threads_pthreads_implementation_nptl = false;
138 # endif
139 #endif
140
141         /* initialize the threads lists */
142
143         list_threads           = list_create(OFFSET(threadobject, linkage));
144         list_free_thread_index = list_create(OFFSET(thread_index_t, linkage));
145
146         /* Initialize the threads implementation (sets the thinlock on the
147            main thread). */
148
149         threads_impl_preinit();
150
151         /* create internal thread data-structure for the main thread */
152
153         mainthread = threads_thread_new();
154
155         /* thread is a Java thread and running */
156
157         mainthread->flags |= THREAD_FLAG_JAVA;
158         mainthread->state = THREAD_STATE_RUNNABLE;
159
160         /* store the internal thread data-structure in the TSD */
161
162         threads_set_current_threadobject(mainthread);
163
164         /* initialize locking subsystems */
165
166         lock_init();
167
168         /* initialize the critical section */
169
170         critical_init();
171 }
172
173
174 /* threads_list_first **********************************************************
175
176    Return the first entry in the threads list.
177
178    NOTE: This function does not lock the lists.
179
180 *******************************************************************************/
181
182 threadobject *threads_list_first(void)
183 {
184         threadobject *t;
185
186         t = list_first_unsynced(list_threads);
187
188         return t;
189 }
190
191
192 /* threads_list_next ***********************************************************
193
194    Return the next entry in the threads list.
195
196    NOTE: This function does not lock the lists.
197
198 *******************************************************************************/
199
200 threadobject *threads_list_next(threadobject *t)
201 {
202         threadobject *next;
203
204         next = list_next_unsynced(list_threads, t);
205
206         return next;
207 }
208
209
210 /* threads_list_get_non_daemons ************************************************
211
212    Return the number of non-daemon threads.
213
214    NOTE: This function does a linear-search over the threads list,
215          because it's only used for joining the threads.
216
217 *******************************************************************************/
218
219 s4 threads_list_get_non_daemons(void)
220 {
221         threadobject *t;
222         s4            nondaemons;
223
224         /* lock the threads lists */
225
226         threads_list_lock();
227
228         nondaemons = 0;
229
230         for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
231                 if (!(t->flags & THREAD_FLAG_DAEMON))
232                         nondaemons++;
233         }
234
235         /* unlock the threads lists */
236
237         threads_list_unlock();
238
239         return nondaemons;
240 }
241
242
243 /* threads_thread_new **********************************************************
244
245    Allocates and initializes an internal thread data-structure and
246    adds it to the threads list.
247
248 *******************************************************************************/
249
250 threadobject *threads_thread_new(void)
251 {
252         thread_index_t *ti;
253         int32_t         index;
254         threadobject   *t;
255         
256         /* lock the threads-lists */
257
258         threads_list_lock();
259
260         /* Try to get a thread index from the free-list. */
261
262         ti = list_first_unsynced(list_free_thread_index);
263
264         /* Is a free thread index available? */
265
266         if (ti != NULL) {
267                 /* Yes, remove it from the free list, get the index and free
268                    the entry. */
269
270                 list_remove_unsynced(list_free_thread_index, ti);
271
272                 index = ti->index;
273
274                 FREE(ti, thread_index_t);
275
276 #if defined(ENABLE_STATISTICS)
277                 if (opt_stat)
278                         size_thread_index_t -= sizeof(thread_index_t);
279 #endif
280         }
281         else {
282                 /* Get a new the thread index. */
283
284                 index = list_threads->size + 1;
285         }
286
287         /* Allocate a thread data structure. */
288
289 #if defined(ENABLE_GC_BOEHM)
290         t = GCNEW_UNCOLLECTABLE(threadobject, 1);
291 #else
292         t = NEW(threadobject);
293 #endif
294
295 #if defined(ENABLE_STATISTICS)
296         if (opt_stat)
297                 size_threadobject += sizeof(threadobject);
298 #endif
299
300         /* Clear memory. */
301
302         MZERO(t, threadobject, 1);
303
304 #if defined(ENABLE_GC_CACAO)
305         /* Register reference to java.lang.Thread with the GC. */
306
307         gc_reference_register(&(t->object), GC_REFTYPE_THREADOBJECT);
308         gc_reference_register(&(t->_exceptionptr), GC_REFTYPE_THREADOBJECT);
309 #endif
310
311         /* Pre-compute the thinlock-word. */
312
313         assert(index != 0);
314
315         t->index     = index;
316         t->thinlock  = lock_pre_compute_thinlock(t->index);
317         t->flags     = 0;
318         t->state     = THREAD_STATE_NEW;
319
320 #if defined(ENABLE_GC_CACAO)
321         t->flags    |= THREAD_FLAG_IN_NATIVE; 
322 #endif
323
324         /* Initialize the implementation-specific bits. */
325
326         threads_impl_thread_new(t);
327
328         /* Add the thread to the threads-list. */
329
330         list_add_last_unsynced(list_threads, t);
331
332         /* Unlock the threads-lists. */
333
334         threads_list_unlock();
335
336         return t;
337 }
338
339
340 /* threads_thread_free *********************************************************
341
342    Remove the thread from the threads-list and free the internal
343    thread data structure.  The thread index is added to the
344    thread-index free-list.
345
346    IN:
347        t....thread data structure
348
349 *******************************************************************************/
350
351 void threads_thread_free(threadobject *t)
352 {
353         thread_index_t *ti;
354
355         /* Lock the threads lists. */
356
357         threads_list_lock();
358
359         /* Cleanup the implementation specific bits. */
360
361         threads_impl_thread_free(t);
362
363         /* Remove the thread from the threads-list. */
364
365         list_remove_unsynced(list_threads, t);
366
367         /* Add the thread index to the free list. */
368
369         ti = NEW(thread_index_t);
370
371 #if defined(ENABLE_STATISTICS)
372         if (opt_stat)
373                 size_thread_index_t += sizeof(thread_index_t);
374 #endif
375
376         ti->index = t->index;
377
378         list_add_last_unsynced(list_free_thread_index, ti);
379
380         /* Free the thread data structure. */
381
382 #if defined(ENABLE_GC_BOEHM)
383         GCFREE(t);
384 #else
385         FREE(t, threadobject);
386 #endif
387
388 #if defined(ENABLE_STATISTICS)
389         if (opt_stat)
390                 size_threadobject -= sizeof(threadobject);
391 #endif
392
393         /* Unlock the threads lists. */
394
395         threads_list_unlock();
396 }
397
398
399 /* threads_thread_start_internal ***********************************************
400
401    Start an internal thread in the JVM.  No Java thread objects exists
402    so far.
403
404    IN:
405       name.......UTF-8 name of the thread
406       f..........function pointer to C function to start
407
408 *******************************************************************************/
409
410 bool threads_thread_start_internal(utf *name, functionptr f)
411 {
412         threadobject       *t;
413         java_lang_Thread   *object;
414 #if defined(WITH_CLASSPATH_GNU)
415         java_lang_VMThread *vmt;
416 #endif
417
418         /* Enter the join-mutex, so if the main-thread is currently
419            waiting to join all threads, the number of non-daemon threads
420            is correct. */
421
422         threads_mutex_join_lock();
423
424         /* create internal thread data-structure */
425
426         t = threads_thread_new();
427
428         t->flags |= THREAD_FLAG_INTERNAL | THREAD_FLAG_DAEMON;
429
430         /* The thread is flagged as (non-)daemon thread, we can leave the
431            mutex. */
432
433         threads_mutex_join_unlock();
434
435         /* create the java thread object */
436
437         object = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
438
439         /* XXX memory leak!!! */
440         if (object == NULL)
441                 return false;
442
443 #if defined(WITH_CLASSPATH_GNU)
444         vmt = (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
445
446         /* XXX memory leak!!! */
447         if (vmt == NULL)
448                 return false;
449
450         LLNI_field_set_ref(vmt, thread, object);
451         LLNI_field_set_val(vmt, vmdata, (java_lang_Object *) t);
452
453         LLNI_field_set_ref(object, vmThread, vmt);
454 #elif defined(WITH_CLASSPATH_CLDC1_1)
455         LLNI_field_set_val(object, vm_thread, (java_lang_Object *) t);
456 #endif
457
458         threads_thread_set_object(t, (java_handle_t *) object);
459
460         /* set java.lang.Thread fields */
461
462 #if defined(WITH_CLASSPATH_GNU)
463         LLNI_field_set_ref(object, name    , (java_lang_String *) javastring_new(name));
464 #elif defined(WITH_CLASSPATH_CLDC1_1)
465         /* FIXME: In cldc the name is a char[] */
466 /*      LLNI_field_set_ref(object, name    , (java_chararray *) javastring_new(name)); */
467         LLNI_field_set_ref(object, name    , NULL);
468 #endif
469
470 #if defined(ENABLE_JAVASE)
471         LLNI_field_set_val(object, daemon  , true);
472 #endif
473
474         LLNI_field_set_val(object, priority, NORM_PRIORITY);
475
476         /* start the thread */
477
478         threads_impl_thread_start(t, f);
479
480         /* everything's ok */
481
482         return true;
483 }
484
485
486 /* threads_thread_start ********************************************************
487
488    Start a Java thread in the JVM.  Only the java thread object exists
489    so far.
490
491    IN:
492       object.....the java thread object java.lang.Thread
493
494 *******************************************************************************/
495
496 void threads_thread_start(java_handle_t *object)
497 {
498         java_lang_Thread   *o;
499         threadobject       *thread;
500 #if defined(WITH_CLASSPATH_GNU)
501         java_lang_VMThread *vmt;
502 #endif
503
504         o = (java_lang_Thread *) object;
505
506         /* Enter the join-mutex, so if the main-thread is currently
507            waiting to join all threads, the number of non-daemon threads
508            is correct. */
509
510         threads_mutex_join_lock();
511
512         /* create internal thread data-structure */
513
514         thread = threads_thread_new();
515
516         /* this is a normal Java thread */
517
518         thread->flags |= THREAD_FLAG_JAVA;
519
520 #if defined(ENABLE_JAVASE)
521         /* is this a daemon thread? */
522
523         if (LLNI_field_direct(o, daemon) == true)
524                 thread->flags |= THREAD_FLAG_DAEMON;
525 #endif
526
527         /* The thread is flagged and (non-)daemon thread, we can leave the
528            mutex. */
529
530         threads_mutex_join_unlock();
531
532         /* link the two objects together */
533
534         threads_thread_set_object(thread, object);
535
536 #if defined(WITH_CLASSPATH_GNU)
537         LLNI_field_get_ref(o, vmThread, vmt);
538
539         assert(vmt);
540         assert(LLNI_field_direct(vmt, vmdata) == NULL);
541
542         LLNI_field_set_val(vmt, vmdata, (java_lang_Object *) thread);
543 #elif defined(WITH_CLASSPATH_CLDC1_1)
544         LLNI_field_set_val(o, vm_thread, (java_lang_Object *) thread);
545 #endif
546
547         /* Start the thread.  Don't pass a function pointer (NULL) since
548            we want Thread.run()V here. */
549
550         threads_impl_thread_start(thread, NULL);
551 }
552
553
554 /* threads_thread_print_info ***************************************************
555
556    Print information of the passed thread.
557    
558 *******************************************************************************/
559
560 void threads_thread_print_info(threadobject *t)
561 {
562         java_lang_Thread *object;
563 #if defined(WITH_CLASSPATH_GNU)
564         java_lang_String *namestring;
565 #endif
566         utf              *name;
567
568         assert(t->state != THREAD_STATE_NEW);
569
570         /* the thread may be currently in initalization, don't print it */
571
572         object = (java_lang_Thread *) threads_thread_get_object(t);
573
574         if (object != NULL) {
575                 /* get thread name */
576
577 #if defined(WITH_CLASSPATH_GNU)
578                 LLNI_field_get_ref(object, name, namestring);
579                 name = javastring_toutf((java_handle_t *) namestring, false);
580 #elif defined(WITH_CLASSPATH_SUN) || defined(WITH_CLASSPATH_CLDC1_1)
581                 /* FIXME: In cldc the name is a char[] */
582 /*              name = object->name; */
583                 name = utf_null;
584 #else
585 # error unknown classpath configuration
586 #endif
587
588                 printf("\"");
589                 utf_display_printable_ascii(name);
590                 printf("\"");
591
592                 if (t->flags & THREAD_FLAG_DAEMON)
593                         printf(" daemon");
594
595                 printf(" prio=%d", LLNI_field_direct(object, priority));
596
597 #if SIZEOF_VOID_P == 8
598                 printf(" t=0x%016lx tid=0x%016lx (%ld)",
599                            (ptrint) t, (ptrint) t->tid, (ptrint) t->tid);
600 #else
601                 printf(" t=0x%08x tid=0x%08x (%d)",
602                            (ptrint) t, (ptrint) t->tid, (ptrint) t->tid);
603 #endif
604
605                 printf(" index=%d", t->index);
606
607                 /* print thread state */
608
609                 switch (t->state) {
610                 case THREAD_STATE_NEW:
611                         printf(" new");
612                         break;
613                 case THREAD_STATE_RUNNABLE:
614                         printf(" runnable");
615                         break;
616                 case THREAD_STATE_BLOCKED:
617                         printf(" blocked");
618                         break;
619                 case THREAD_STATE_WAITING:
620                         printf(" waiting");
621                         break;
622                 case THREAD_STATE_TIMED_WAITING:
623                         printf(" waiting on condition");
624                         break;
625                 case THREAD_STATE_TERMINATED:
626                         printf(" terminated");
627                         break;
628                 default:
629                         vm_abort("threads_thread_print_info: unknown thread state %d",
630                                          t->state);
631                 }
632         }
633 }
634
635
636 /* threads_get_current_tid *****************************************************
637
638    Return the tid of the current thread.
639    
640    RETURN VALUE:
641        the current tid
642
643 *******************************************************************************/
644
645 ptrint threads_get_current_tid(void)
646 {
647         threadobject *thread;
648
649         thread = THREADOBJECT;
650
651         /* this may happen during bootstrap */
652
653         if (thread == NULL)
654                 return 0;
655
656         return (ptrint) thread->tid;
657 }
658
659
660 /* threads_thread_state_runnable ***********************************************
661
662    Set the current state of the given thread to THREAD_STATE_RUNNABLE.
663
664    NOTE: If the thread has already terminated, don't set the state.
665          This is important for threads_detach_thread.
666
667 *******************************************************************************/
668
669 void threads_thread_state_runnable(threadobject *t)
670 {
671         /* Set the state inside a lock. */
672
673         threads_list_lock();
674
675         if (t->state != THREAD_STATE_TERMINATED)
676                 t->state = THREAD_STATE_RUNNABLE;
677
678         DEBUGTHREADS("is RUNNABLE", t);
679
680         threads_list_unlock();
681 }
682
683
684 /* threads_thread_state_waiting ************************************************
685
686    Set the current state of the given thread to THREAD_STATE_WAITING.
687
688    NOTE: If the thread has already terminated, don't set the state.
689          This is important for threads_detach_thread.
690
691 *******************************************************************************/
692
693 void threads_thread_state_waiting(threadobject *t)
694 {
695         /* Set the state inside a lock. */
696
697         threads_list_lock();
698
699         if (t->state != THREAD_STATE_TERMINATED)
700                 t->state = THREAD_STATE_WAITING;
701
702         DEBUGTHREADS("is WAITING", t);
703
704         threads_list_unlock();
705 }
706
707
708 /* threads_thread_state_timed_waiting ******************************************
709
710    Set the current state of the given thread to
711    THREAD_STATE_TIMED_WAITING.
712
713    NOTE: If the thread has already terminated, don't set the state.
714          This is important for threads_detach_thread.
715
716 *******************************************************************************/
717
718 void threads_thread_state_timed_waiting(threadobject *t)
719 {
720         /* Set the state inside a lock. */
721
722         threads_list_lock();
723
724         if (t->state != THREAD_STATE_TERMINATED)
725                 t->state = THREAD_STATE_TIMED_WAITING;
726
727         DEBUGTHREADS("is TIMED_WAITING", t);
728
729         threads_list_unlock();
730 }
731
732
733 /* threads_thread_state_terminated *********************************************
734
735    Set the current state of the given thread to
736    THREAD_STATE_TERMINATED.
737
738 *******************************************************************************/
739
740 void threads_thread_state_terminated(threadobject *t)
741 {
742         /* set the state in the lock */
743
744         threads_list_lock();
745
746         t->state = THREAD_STATE_TERMINATED;
747
748         DEBUGTHREADS("is TERMINATED", t);
749
750         threads_list_unlock();
751 }
752
753
754 /* threads_thread_get_state ****************************************************
755
756    Returns the current state of the given thread.
757
758 *******************************************************************************/
759
760 utf *threads_thread_get_state(threadobject *t)
761 {
762         utf *u;
763
764         switch (t->state) {
765         case THREAD_STATE_NEW:
766                 u = utf_new_char("NEW");
767                 break;
768         case THREAD_STATE_RUNNABLE:
769                 u = utf_new_char("RUNNABLE");
770                 break;
771         case THREAD_STATE_BLOCKED:
772                 u = utf_new_char("BLOCKED");
773                 break;
774         case THREAD_STATE_WAITING:
775                 u = utf_new_char("WAITING");
776                 break;
777         case THREAD_STATE_TIMED_WAITING:
778                 u = utf_new_char("TIMED_WAITING");
779                 break;
780         case THREAD_STATE_TERMINATED:
781                 u = utf_new_char("TERMINATED");
782                 break;
783         default:
784                 vm_abort("threads_get_state: unknown thread state %d", t->state);
785
786                 /* keep compiler happy */
787
788                 u = NULL;
789         }
790
791         return u;
792 }
793
794
795 /* threads_thread_is_alive *****************************************************
796
797    Returns if the give thread is alive.
798
799 *******************************************************************************/
800
801 bool threads_thread_is_alive(threadobject *t)
802 {
803         switch (t->state) {
804         case THREAD_STATE_NEW:
805         case THREAD_STATE_TERMINATED:
806                 return false;
807
808         case THREAD_STATE_RUNNABLE:
809         case THREAD_STATE_BLOCKED:
810         case THREAD_STATE_WAITING:
811         case THREAD_STATE_TIMED_WAITING:
812                 return true;
813
814         default:
815                 vm_abort("threads_thread_is_alive: unknown thread state %d", t->state);
816         }
817
818         /* keep compiler happy */
819
820         return false;
821 }
822
823
824 /* threads_dump ****************************************************************
825
826    Dumps info for all threads running in the JVM.  This function is
827    called when SIGQUIT (<ctrl>-\) is sent to CACAO.
828
829 *******************************************************************************/
830
831 void threads_dump(void)
832 {
833         threadobject *t;
834
835         /* XXX we should stop the world here */
836
837         /* lock the threads lists */
838
839         threads_list_lock();
840
841         printf("Full thread dump CACAO "VERSION":\n");
842
843         /* iterate over all started threads */
844
845         for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
846                 /* print thread info */
847
848                 printf("\n");
849                 threads_thread_print_info(t);
850                 printf("\n");
851
852                 /* print trace of thread */
853
854                 threads_thread_print_stacktrace(t);
855         }
856
857         /* unlock the threads lists */
858
859         threads_list_unlock();
860 }
861
862
863 /* threads_thread_print_stacktrace *********************************************
864
865    Print the current stacktrace of the current thread.
866
867 *******************************************************************************/
868
869 void threads_thread_print_stacktrace(threadobject *thread)
870 {
871         stackframeinfo   *sfi;
872         stacktracebuffer *stb;
873         s4                dumpsize;
874
875         /* mark start of dump memory area */
876
877         dumpsize = dump_size();
878
879         /* create a stacktrace for the passed thread */
880
881         sfi = thread->_stackframeinfo;
882
883         stb = stacktrace_create(sfi);
884
885         /* print stacktrace */
886
887         if (stb != NULL)
888                 stacktrace_print_trace_from_buffer(stb);
889         else {
890                 puts("\t<<No stacktrace available>>");
891                 fflush(stdout);
892         }
893
894         dump_release(dumpsize);
895 }
896
897
898 /* threads_print_stacktrace ****************************************************
899
900    Print the current stacktrace of the current thread.
901
902 *******************************************************************************/
903
904 void threads_print_stacktrace(void)
905 {
906         threadobject *thread;
907
908         thread = THREADOBJECT;
909
910         threads_thread_print_stacktrace(thread);
911 }
912
913
914 /*
915  * These are local overrides for various environment variables in Emacs.
916  * Please do not remove this and leave it at the end of the file, where
917  * Emacs will automagically detect them.
918  * ---------------------------------------------------------------------
919  * Local variables:
920  * mode: c
921  * indent-tabs-mode: t
922  * c-basic-offset: 4
923  * tab-width: 4
924  * End:
925  * vim:noexpandtab:sw=4:ts=4:
926  */