Daily bump.
[official-gcc.git] / libjava / gnu / gcj / jvmti / natBreakpoint.cc
blob87016b089f5aa095db01427e162532448b3ada3b
1 // natBreakpoint.cc - C++ side of Breakpoint
3 /* Copyright (C) 2006, 2007 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 details. */
11 #include <config.h>
12 #include <gcj/cni.h>
13 #include <gcj/method.h>
14 #include <java-interp.h>
15 #include <java-insns.h>
16 #include <java-assert.h>
17 #include <jvmti.h>
19 #include <gnu/gcj/jvmti/Breakpoint.h>
20 #include <gnu/gcj/jvmti/BreakpointManager.h>
22 static _Jv_InterpMethod *
23 get_interp_method (jlong method)
25 jmethodID id = reinterpret_cast<jmethodID> (method);
26 jclass klass = _Jv_GetMethodDeclaringClass (id);
27 JvAssert (_Jv_IsInterpretedClass (klass));
28 _Jv_MethodBase *base
29 = _Jv_FindInterpreterMethod (klass, id);
30 JvAssert (base != NULL);
31 return reinterpret_cast<_Jv_InterpMethod *> (base);
34 void
35 gnu::gcj::jvmti::Breakpoint::_save_insn ()
37 _Jv_InterpMethod *imeth = get_interp_method (method);
39 // copy contents of insn at location into data
40 pc_t code = imeth->get_insn (location);
41 data = (RawDataManaged *) JvAllocBytes (sizeof (*code));
42 memcpy (data, code, sizeof (*code));
45 void
46 gnu::gcj::jvmti::Breakpoint::install ()
48 _save_insn ();
49 _Jv_InterpMethod *imeth = get_interp_method (method);
50 imeth->install_break (location);
53 void
54 gnu::gcj::jvmti::Breakpoint::remove ()
56 _Jv_InterpMethod *imeth = get_interp_method (method);
57 imeth->set_insn (location, reinterpret_cast<pc_t> (data));
60 #ifdef DIRECT_THREADED
61 void
62 _Jv_RewriteBreakpointInsn (jmethodID mid, jlocation loc, pc_t new_insn)
64 using namespace ::gnu::gcj::jvmti;
65 Breakpoint *bp
66 = BreakpointManager::getBreakpoint (reinterpret_cast<jlong> (mid), loc);
67 if (bp != NULL)
69 pc_t old_insn = (pc_t) bp->data;
70 old_insn->insn = new_insn;
73 #endif // DIRECT_THREADED