diff options
author | Sebastien Hertz <shertz@google.com> | 2015-02-25 15:05:59 +0100 |
---|---|---|
committer | Sebastien Hertz <shertz@google.com> | 2015-03-09 15:19:49 +0100 |
commit | 1558b577907b613864e98f05862543557263e864 (patch) | |
tree | 5498d8d15f198341fe46a8badc7e7591611a09b5 /runtime/debugger.h | |
parent | 2cfdabd2bb4833d7092819d27ef08a9e1cdffead (diff) | |
download | art-1558b577907b613864e98f05862543557263e864.zip art-1558b577907b613864e98f05862543557263e864.tar.gz art-1558b577907b613864e98f05862543557263e864.tar.bz2 |
JDWP: allocate DebugInvokeReq only when requested
Only allocates thread-local DebugInvokeReq when the debugger requests
a thread to invoke a method. The JDWP thread allocates that structure
then attaches it to the target thread. When the thread is resumed, it
executes the method. Once the invocation completes, the thread
detaches the DebugInvokeReq, signals the JDWP thread then suspends.
Finally, the JDWP thread wakes up, prepares the reply with the invoke
result (or exception) and deallocates the DebugInvokeReq.
Also ensures GC safety for object returned by the invoke. We add the
object to the JDWP object registry right after the invoke. We now
reference that object with a JDWP ObjectID instead of an Object* in
the DebugInvokeReq struct. This prevent from accessing a stale
reference if the GC runs and moves the Object*.
This CL includes the following changes:
- Move former DebugInvokeReq::ready flag to
Thread::tls_32bit_sized_values::ready_for_debug_invoke. It's needed
to know whether a thread has been suspended by an event, thus ready
to invoke a method from the debugger.
- Remove DebugInvokeReq::invoke_needed: we now test if we attached a
DebugInvokeReq* to the thread.
- Rename misleading FinishMethod function to RequestMethod.
Bug: 19142632
Bug: 18166750
Change-Id: I351fb4eb94bfe69fcafb544d21d55ff35a033000
Diffstat (limited to 'runtime/debugger.h')
-rw-r--r-- | runtime/debugger.h | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/runtime/debugger.h b/runtime/debugger.h index 428ded7..0ac83f6 100644 --- a/runtime/debugger.h +++ b/runtime/debugger.h @@ -54,34 +54,28 @@ class ThrowLocation; * Invoke-during-breakpoint support. */ struct DebugInvokeReq { - DebugInvokeReq() - : ready(false), invoke_needed(false), - receiver(NULL), thread(NULL), klass(NULL), method(NULL), - arg_count(0), arg_values(NULL), options(0), error(JDWP::ERR_NONE), - result_tag(JDWP::JT_VOID), exception(0), + DebugInvokeReq(mirror::Object* invoke_receiver, mirror::Class* invoke_class, + mirror::ArtMethod* invoke_method, uint32_t invoke_options, + uint64_t* args, uint32_t args_count) + : receiver(invoke_receiver), klass(invoke_class), method(invoke_method), + arg_count(args_count), arg_values(args), options(invoke_options), + error(JDWP::ERR_NONE), result_tag(JDWP::JT_VOID), result_value(0), exception(0), lock("a DebugInvokeReq lock", kBreakpointInvokeLock), cond("a DebugInvokeReq condition variable", lock) { } - /* boolean; only set when we're in the tail end of an event handler */ - bool ready; - - /* boolean; set if the JDWP thread wants this thread to do work */ - bool invoke_needed; - /* request */ - mirror::Object* receiver; /* not used for ClassType.InvokeMethod */ - mirror::Object* thread; - mirror::Class* klass; - mirror::ArtMethod* method; - uint32_t arg_count; - uint64_t* arg_values; /* will be NULL if arg_count_ == 0 */ - uint32_t options; + GcRoot<mirror::Object> receiver; // not used for ClassType.InvokeMethod + GcRoot<mirror::Class> klass; + GcRoot<mirror::ArtMethod> method; + const uint32_t arg_count; + uint64_t* const arg_values; // will be NULL if arg_count_ == 0 + const uint32_t options; /* result */ JDWP::JdwpError error; JDWP::JdwpTag result_tag; - JValue result_value; + uint64_t result_value; // either a primitive value or an ObjectId JDWP::ObjectId exception; /* condition variable to wait on while the method executes */ @@ -91,8 +85,6 @@ struct DebugInvokeReq { void VisitRoots(RootCallback* callback, void* arg, const RootInfo& root_info) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - void Clear(); - private: DISALLOW_COPY_AND_ASSIGN(DebugInvokeReq); }; @@ -581,6 +573,8 @@ class Dbg { LOCKS_EXCLUDED(Locks::thread_list_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + // Invoke support for commands ClassType.InvokeMethod, ClassType.NewInstance and + // ObjectReference.InvokeMethod. static JDWP::JdwpError InvokeMethod(JDWP::ObjectId thread_id, JDWP::ObjectId object_id, JDWP::RefTypeId class_id, JDWP::MethodId method_id, uint32_t arg_count, uint64_t* arg_values, |