/* src/native/jvmti/cacaodbg.c - contains entry points for debugging support
in cacao.
- Copyright (C) 1996-2005, 2006 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) 1996-2005, 2006, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
- Contact: cacao@complang.tuwien.ac.at
-
- Authors: Martin Platter
-
- Changes: Edwin Steiner
- Samuel Vinson
-
- $Id: cacao.c,v 3.165 2006/01/03 23:44:38 twisti Exp $
-
*/
#include "native/jvmti/jvmti.h"
#include "native/jvmti/cacaodbg.h"
#include "native/jvmti/dbg.h"
-#include "vm/vm.h"
+#include "vm/vm.hpp"
#include "vm/loader.h"
#include "vm/exceptions.h"
#include "vm/builtin.h"
#include "vm/jit/asmpart.h"
#include "vm/stringlocal.h"
#include "toolbox/logging.h"
-#include "threads/native/threads.h"
+#include "threads/mutex.h"
+#include "threads/thread.hpp"
#include <sys/types.h>
#include <unistd.h>
*******************************************************************************/
jthread jvmti_get_current_thread() {
- return (jthread)(threads_get_current_threadobject())->o.thread;
+ return (jthread)(thread_get_current)->o.thread;
}
void jvmti_set_system_breakpoint(int sysbrk, bool mode) {
struct brkpts *jvmtibrkpt;
- pthread_mutex_lock(&dbgcomlock);
+ mutex_lock(&dbgcomlock);
jvmtibrkpt = &dbgcom->jvmtibrkpt;
assert (sysbrk < BEGINUSERBRK);
/* add breakpoint*/
if (jvmtibrkpt->brk[sysbrk].count > 0) {
jvmtibrkpt->brk[sysbrk].count++;
- pthread_mutex_unlock(&dbgcomlock);
+ mutex_unlock(&dbgcomlock);
return;
}
dbgcom->addbrkpt = true;
} else {
/* avoid negative counter values */
if (jvmtibrkpt->brk[sysbrk].count > 0) jvmtibrkpt->brk[sysbrk].count--;
- pthread_mutex_unlock(&dbgcomlock);
+ mutex_unlock(&dbgcomlock);
return;
}
}
- pthread_mutex_unlock(&dbgcomlock);
+ mutex_unlock(&dbgcomlock);
/* call cacaodbgserver */
__asm__ ("setsysbrkpt:");
TRAP;
void jvmti_add_breakpoint(void* addr, jmethodID method, jlocation location) {
struct brkpts *jvmtibrkpt;
- pthread_mutex_lock(&dbgcomlock);
+ mutex_lock(&dbgcomlock);
jvmtibrkpt = &dbgcom->jvmtibrkpt;;
if (jvmtibrkpt->size == jvmtibrkpt->num)
/* todo: set breakpoint */
/* jvmtibrkpt.brk[jvmtibrkpt.num].orig = */
jvmtibrkpt->num++;
- pthread_mutex_unlock(&dbgcomlock);
+ mutex_unlock(&dbgcomlock);
fprintf (stderr,"add brk done\n");
}
*******************************************************************************/
void jvmti_cacaodbgserver_quit(){
- pthread_mutex_lock(&dbgcomlock);
+ mutex_lock(&dbgcomlock);
dbgcom->running--;
if (dbgcom->running == 0) {
__asm__ ("cacaodbgserver_quit:");
wait(NULL);
dbgcom = NULL;
}
- pthread_mutex_unlock(&dbgcomlock);
+ mutex_unlock(&dbgcomlock);
}
pid_t dbgserver;
/* start new cacaodbgserver if needed*/
- pthread_mutex_lock(&dbgcomlock);
+ mutex_lock(&dbgcomlock);
if (dbgcom == NULL) {
dbgcom = heap_allocate(sizeof(cacaodbgcommunication),true,NULL);
dbgcom->running = 1;
}
}
}
- pthread_mutex_unlock(&dbgcomlock);
+ mutex_unlock(&dbgcomlock);
/* let cacaodbgserver get ready */
sleep(1);
} else {
dbgcom->running++;
- pthread_mutex_unlock(&dbgcomlock);
+ mutex_unlock(&dbgcomlock);
+ }
+}
+
+
+/* jvmti_ClassFileLoadHook ****************************************************
+
+ prepares firing a new Class File Load Hook event
+
+*******************************************************************************/
+
+void jvmti_ClassFileLoadHook(utf* name, int class_data_len,
+ unsigned char* class_data,
+ java_objectheader* loader,
+ java_objectheader* protection_domain,
+ jint* new_class_data_len,
+ unsigned char** new_class_data) {
+ genericEventData d;
+
+ d.ev = JVMTI_EVENT_CLASS_FILE_LOAD_HOOK;
+ d.klass = NULL; /* class is not redefined */
+ d.object = loader;
+ d.name = (char*)MNEW(char,(utf_bytes(name)+1));
+ utf_sprint_convert_to_latin1(d.name, name);
+ d.protection_domain = protection_domain;
+ d.class_data = class_data;
+ d.jint1 = class_data_len;
+ d.new_class_data_len = new_class_data_len;
+ d.new_class_data = new_class_data;
+
+ jvmti_fireEvent(&d);
+ MFREE(d.name,char,utf_bytes(name)+1);
+}
+
+
+/* jvmti_ClassFileLoadHook ****************************************************
+
+ prepares firing a new Class Prepare or Load event
+
+*******************************************************************************/
+
+void jvmti_ClassLoadPrepare(bool prepared, classinfo *c) {
+ genericEventData d;
+
+ if (prepared)
+ d.ev = JVMTI_EVENT_CLASS_PREPARE;
+ else
+ d.ev = JVMTI_EVENT_CLASS_LOAD;
+
+ d.klass = c;
+ jvmti_fireEvent(&d);
+}
+
+
+/* jvmti_MonitorContendedEntering *********************************************
+
+ prepares firing a new Monitor Contended Enter or Entered event
+
+*******************************************************************************/
+
+void jvmti_MonitorContendedEntering(bool entered, jobject obj) {
+ genericEventData d;
+
+ if (entered)
+ d.ev = JVMTI_EVENT_MONITOR_CONTENDED_ENTERED;
+ else
+ d.ev = JVMTI_EVENT_MONITOR_CONTENDED_ENTER;
+
+ d.object = obj;
+
+ jvmti_fireEvent(&d);
+}
+
+/* jvmti_MonitorWaiting ******************************************************
+
+ prepares firing a new Monitor Wait or Waited event
+
+*******************************************************************************/
+
+void jvmti_MonitorWaiting(bool wait, jobject obj, jlong timeout) {
+ genericEventData d;
+
+ if (wait) {
+ d.ev = JVMTI_EVENT_MONITOR_WAIT;
+ d.jlong = timeout;
+ } else {
+ d.ev = JVMTI_EVENT_MONITOR_WAITED;
+ d.b = timeout != 0;
}
+
+ d.object = obj;
+
+ jvmti_fireEvent(&d);
}
+/* jvmti_ThreadStartEnd ********************************************************
+
+ prepares firing a new Thread Start or End event
+
+*******************************************************************************/
+
+void jvmti_ThreadStartEnd(jvmtiEvent ev) {
+ genericEventData d;
+
+ d.ev = ev;
+ jvmti_fireEvent(&d);
+}
+
+/* jvmti_NativeMethodBind *****************************************************
+
+ prepares firing a new Native Method Bind event
+
+*******************************************************************************/
+
+void jvmti_NativeMethodBind(jmethodID method, void* address,
+ void** new_address_ptr) {
+ genericEventData d;
+
+ d.ev = JVMTI_EVENT_NATIVE_METHOD_BIND;
+ d.method = method;
+ d.address = address;
+ d.new_address_ptr = new_address_ptr;
+
+ jvmti_fireEvent(&d);
+}
+
+
/*
* These are local overrides for various environment variables in Emacs.