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
13 #include <gcj/method.h>
14 #include <java-interp.h>
15 #include <java-insns.h>
16 #include <java-assert.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
));
29 = _Jv_FindInterpreterMethod (klass
, id
);
30 JvAssert (base
!= NULL
);
31 return reinterpret_cast<_Jv_InterpMethod
*> (base
);
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
));
46 gnu::gcj::jvmti::Breakpoint::install ()
49 _Jv_InterpMethod
*imeth
= get_interp_method (method
);
50 imeth
->install_break (location
);
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
62 _Jv_RewriteBreakpointInsn (jmethodID mid
, jlocation loc
, pc_t new_insn
)
64 using namespace ::gnu::gcj::jvmti
;
66 = BreakpointManager::getBreakpoint (reinterpret_cast<jlong
> (mid
), loc
);
69 pc_t old_insn
= (pc_t
) bp
->data
;
70 old_insn
->insn
= new_insn
;
73 #endif // DIRECT_THREADED