1 /* vmlog - high-speed logging for free VMs */
2 /* Copyright (C) 2006 Edwin Steiner <edwin.steiner@gmx.net> */
4 /* This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 /* vmlog_cacao.c - code to be #included in cacao */
21 #include <vmlog_cacao.h>
22 #define VMLOG_HAVE_PTRINT
26 /*** global variables ************************************************/
28 static vmlog_log *vmlog_global_log = NULL;
29 static java_objectheader vmlog_global_lock;
31 /*** locking *********************************************************/
33 #define VMLOG_LOCK(vml) lock_monitor_enter(&vmlog_global_lock)
34 #define VMLOG_UNLOCK(vml) lock_monitor_exit(&vmlog_global_lock)
36 /*** include the vmlog code ******************************************/
40 /*** internal functions **********************************************/
42 void vmlog_cacao_init(JavaVMInitArgs *vmargs)
46 opts = vmlog_opt_parse_vmargs(vmargs);
51 vmlog_global_log = vmlog_log_new(opts->prefix,1);
53 if (opts->ignoreprefix) {
54 vmlog_log_load_ignorelist(vmlog_global_log,
58 if (opts->stringprefix) {
59 vmlog_load_stringhash(vmlog_global_log,
66 void vmlog_cacao_init_lock(void)
68 lock_init_object_lock(&vmlog_global_lock);
71 static void vmlog_cacao_do_log(vmlog_log_function fun,
79 if (!vmlog_global_log)
82 name = vmlog_concat4len(m->class->name->text,m->class->name->blength,
84 m->name->text,m->name->blength,
85 m->descriptor->text,m->descriptor->blength,
88 fun(vmlog_global_log,(void*) THREADOBJECT,name,namelen);
90 VMLOG_FREE_ARRAY(char,namelen+1,name);
93 /*** functions callable from cacao ***********************************/
95 void vmlog_cacao_enter_method(methodinfo *m)
97 vmlog_cacao_do_log(vmlog_log_enter,m);
100 void vmlog_cacao_leave_method(methodinfo *m)
102 vmlog_cacao_do_log(vmlog_log_leave,m);
105 void vmlog_cacao_unrol_method(methodinfo *m)
107 vmlog_cacao_do_log(vmlog_log_unrol,m);
110 void vmlog_cacao_rerol_method(methodinfo *m)
112 vmlog_cacao_do_log(vmlog_log_rerol,m);
115 void vmlog_cacao_unwnd_method(methodinfo *m)
117 vmlog_cacao_do_log(vmlog_log_unwnd,m);
120 void vmlog_cacao_throw(java_objectheader *xptr)
124 if (!vmlog_global_log)
128 c = xptr->vftbl->class;
129 vmlog_log_throw(vmlog_global_log,(void*) THREADOBJECT,
130 c->name->text,c->name->blength);
133 vmlog_log_throw(vmlog_global_log,(void*) THREADOBJECT,
134 "unknown Throwable",strlen("unknown Throwable"));
138 void vmlog_cacao_catch(java_objectheader *xptr)
142 if (!vmlog_global_log)
146 c = xptr->vftbl->class;
147 vmlog_log_catch(vmlog_global_log,(void*) THREADOBJECT,
148 c->name->text,c->name->blength);
151 vmlog_log_catch(vmlog_global_log,(void*) THREADOBJECT,
152 "unknown Throwable",strlen("unknown Throwable"));
156 void vmlog_cacao_signl(const char *name)
158 if (!vmlog_global_log)
161 vmlog_log_signl(vmlog_global_log,(void*) THREADOBJECT,
165 /* vim: noet ts=8 sw=8