/*** global variables ************************************************/
static vmlog_log *vmlog_global_log = NULL;
-static java_objectheader vmlog_global_lock;
+static java_object_t *vmlog_global_lock = NULL;
+static vmlog_options *vmlog_cacao_options = NULL;
/*** locking *********************************************************/
-#define VMLOG_LOCK(vml) lock_monitor_enter(&vmlog_global_lock)
-#define VMLOG_UNLOCK(vml) lock_monitor_exit(&vmlog_global_lock)
+#define VMLOG_LOCK(vml) lock_monitor_enter(vmlog_global_lock)
+#define VMLOG_UNLOCK(vml) lock_monitor_exit(vmlog_global_lock)
/*** include the vmlog code ******************************************/
/*** internal functions **********************************************/
-void vmlog_cacao_init(JavaVMInitArgs *vmargs)
+void vmlog_cacao_init()
{
- vmlog_options *opts;
-
- opts = vmlog_opt_parse_vmargs(vmargs);
-
- if (!opts->prefix)
+ if (!vmlog_cacao_options->prefix)
return;
- vmlog_global_log = vmlog_log_new(opts->prefix,1);
+ vmlog_global_log = vmlog_log_new(vmlog_cacao_options->prefix,1);
- if (opts->ignoreprefix) {
+ if (vmlog_cacao_options->ignoreprefix) {
vmlog_log_load_ignorelist(vmlog_global_log,
- opts->ignoreprefix);
+ vmlog_cacao_options->ignoreprefix);
}
- if (opts->stringprefix) {
+ if (vmlog_cacao_options->stringprefix) {
vmlog_load_stringhash(vmlog_global_log,
- opts->stringprefix);
+ vmlog_cacao_options->stringprefix);
}
- vmlog_opt_free(opts);
+ vmlog_opt_free(vmlog_cacao_options);
+ vmlog_cacao_options = NULL;
}
void vmlog_cacao_init_lock(void)
{
- lock_init_object_lock(&vmlog_global_lock);
+ vmlog_global_lock = NEW(java_object_t);
+ lock_init_object_lock(vmlog_global_lock);
}
static void vmlog_cacao_do_log(vmlog_log_function fun,
{
char *name;
int namelen;
+ char *cname;
+ int cnamelen;
assert(m);
if (!vmlog_global_log)
return;
- name = vmlog_concat4len(m->class->name->text,m->class->name->blength,
+ if (m->class) {
+ cname = m->class->name->text;
+ cnamelen = m->class->name->blength;
+ }
+ else {
+ cname = "<NULL>";
+ cnamelen = 6;
+ }
+
+ name = vmlog_concat4len(cname,cnamelen,
".",1,
m->name->text,m->name->blength,
m->descriptor->text,m->descriptor->blength,
vmlog_cacao_do_log(vmlog_log_unwnd,m);
}
-void vmlog_cacao_throw(java_objectheader *xptr)
+void vmlog_cacao_throw(java_object_t *xptr)
{
classinfo *c;
}
}
-void vmlog_cacao_catch(java_objectheader *xptr)
+void vmlog_cacao_catch(java_object_t *xptr)
{
classinfo *c;
name, strlen(name));
}
+void vmlog_cacao_signl_type(int type)
+{
+ char message[20];
+
+ if (!vmlog_global_log)
+ return;
+
+ sprintf(message, "EXC %d", type);
+
+ vmlog_log_signl(vmlog_global_log,(void*) THREADOBJECT,
+ message, strlen(message));
+}
+
+void vmlog_cacao_init_options(void)
+{
+ vmlog_cacao_options = vmlog_opt_new();
+}
+
+void vmlog_cacao_set_prefix(const char *arg)
+{
+ vmlog_opt_set_prefix(vmlog_cacao_options, arg);
+}
+
+void vmlog_cacao_set_stringprefix(const char *arg)
+{
+ vmlog_opt_set_stringprefix(vmlog_cacao_options, arg);
+}
+
+void vmlog_cacao_set_ignoreprefix(const char *arg)
+{
+ vmlog_opt_set_ignoreprefix(vmlog_cacao_options, arg);
+}
+
/* vim: noet ts=8 sw=8
*/