summaryrefslogtreecommitdiffstats
path: root/runtime/instrumentation.cc
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2014-04-04 17:50:18 +0200
committerSebastien Hertz <shertz@google.com>2014-04-15 08:39:18 +0200
commit3f52eafe5577b8489f90dc8ed5981b3455206147 (patch)
tree7155df948d345c8a5a2d801c23b396af76527ba0 /runtime/instrumentation.cc
parent9b417e4f0f87da6bfe8dc5f02c987acfcb6dca31 (diff)
downloadart-3f52eafe5577b8489f90dc8ed5981b3455206147.tar.gz
art-3f52eafe5577b8489f90dc8ed5981b3455206147.tar.bz2
art-3f52eafe5577b8489f90dc8ed5981b3455206147.zip
Prepare field watchpoint support
Adds field read/write events in the instrumentation. The debugger now registers as a listener for these events so JDWP field access and field modification events can be reported. This CL will be followed by another one to report these events from the interpreter. Therefore no JDWP field access and field modification events can be sent for now. Bug: 8267708 Change-Id: If2a93eb590805567d69015c83cce9cd2ab712cbd
Diffstat (limited to 'runtime/instrumentation.cc')
-rw-r--r--runtime/instrumentation.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index 525e2b30df..bcde9e5a2e 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -63,6 +63,7 @@ Instrumentation::Instrumentation()
interpret_only_(false), forced_interpret_only_(false),
have_method_entry_listeners_(false), have_method_exit_listeners_(false),
have_method_unwind_listeners_(false), have_dex_pc_listeners_(false),
+ have_field_read_listeners_(false), have_field_write_listeners_(false),
have_exception_caught_listeners_(false),
deoptimized_methods_lock_("deoptimized methods lock"),
deoptimization_enabled_(false),
@@ -373,6 +374,14 @@ void Instrumentation::AddListener(InstrumentationListener* listener, uint32_t ev
dex_pc_listeners_.push_back(listener);
have_dex_pc_listeners_ = true;
}
+ if ((events & kFieldRead) != 0) {
+ field_read_listeners_.push_back(listener);
+ have_field_read_listeners_ = true;
+ }
+ if ((events & kFieldWritten) != 0) {
+ field_write_listeners_.push_back(listener);
+ have_field_write_listeners_ = true;
+ }
if ((events & kExceptionCaught) != 0) {
exception_caught_listeners_.push_back(listener);
have_exception_caught_listeners_ = true;
@@ -410,6 +419,22 @@ void Instrumentation::RemoveListener(InstrumentationListener* listener, uint32_t
}
have_dex_pc_listeners_ = dex_pc_listeners_.size() > 0;
}
+ if ((events & kFieldRead) != 0) {
+ bool contains = std::find(field_read_listeners_.begin(), field_read_listeners_.end(),
+ listener) != field_read_listeners_.end();
+ if (contains) {
+ field_read_listeners_.remove(listener);
+ }
+ have_field_read_listeners_ = field_read_listeners_.size() > 0;
+ }
+ if ((events & kFieldWritten) != 0) {
+ bool contains = std::find(field_write_listeners_.begin(), field_write_listeners_.end(),
+ listener) != field_write_listeners_.end();
+ if (contains) {
+ field_write_listeners_.remove(listener);
+ }
+ have_field_write_listeners_ = field_write_listeners_.size() > 0;
+ }
if ((events & kExceptionCaught) != 0) {
exception_caught_listeners_.remove(listener);
have_exception_caught_listeners_ = exception_caught_listeners_.size() > 0;
@@ -743,6 +768,30 @@ void Instrumentation::DexPcMovedEventImpl(Thread* thread, mirror::Object* this_o
}
}
+void Instrumentation::FieldReadEventImpl(Thread* thread, mirror::Object* this_object,
+ mirror::ArtMethod* method, uint32_t dex_pc,
+ mirror::ArtField* field) const {
+ if (have_field_read_listeners_) {
+ // TODO: same comment than DexPcMovedEventImpl.
+ std::list<InstrumentationListener*> copy(field_read_listeners_);
+ for (InstrumentationListener* listener : copy) {
+ listener->FieldRead(thread, this_object, method, dex_pc, field);
+ }
+ }
+}
+
+void Instrumentation::FieldWriteEventImpl(Thread* thread, mirror::Object* this_object,
+ mirror::ArtMethod* method, uint32_t dex_pc,
+ mirror::ArtField* field, const JValue& field_value) const {
+ if (have_field_write_listeners_) {
+ // TODO: same comment than DexPcMovedEventImpl.
+ std::list<InstrumentationListener*> copy(field_write_listeners_);
+ for (InstrumentationListener* listener : copy) {
+ listener->FieldWritten(thread, this_object, method, dex_pc, field, field_value);
+ }
+ }
+}
+
void Instrumentation::ExceptionCaughtEvent(Thread* thread, const ThrowLocation& throw_location,
mirror::ArtMethod* catch_method,
uint32_t catch_dex_pc,