OSDN Git Service

JDWP: update thread synchronization
authorSebastien Hertz <shertz@google.com>
Fri, 9 Jan 2015 17:44:05 +0000 (18:44 +0100)
committerSebastien Hertz <shertz@google.com>
Fri, 6 Feb 2015 16:46:58 +0000 (17:46 +0100)
commit2bf93f48bbb417b358c9e3c77911ea6ec7307c15
tree4a3cbadecf70b370423418d80bd738fc326aa846
parentb991d334e294cb9fb75bd1c36e2435171c084cd1
JDWP: update thread synchronization

This CL ensures only one thread can do JDWP stuff at a time: either
processing a command coming from the debugger (JDWP thread) or
sending an event (breakpoint, class prepare, etc) to the debugger
before suspending.

The JDWP thread now uses AcquireJdwpTokenForCommand and
ReleaseJdwpTokenForCommand, respectively acquiring and releasing the
token used for synchronization. On the other hand, the event threads
now use AcquireJdwpTokenForEvent and ReleaseJdwpTokenForEvent.

During an invoke, the target thread needs to take the JDWP token to
execute the method while it's already held by the JDWP handler thread
waiting for the invocation to complete. To avoid both threads from
waiting for each other (deadlock), the JDWP thread releases the token
and acquires it again after the invocation is complete, so the target
thread can run safely and prevents other threads from sending events.

Bug: 19120467
Change-Id: Ie3208fb940a60573769d494128cf22f0fa30fa61
runtime/debugger.cc
runtime/jdwp/jdwp.h
runtime/jdwp/jdwp_event.cc
runtime/jdwp/jdwp_handler.cc
runtime/jdwp/jdwp_main.cc