Rename instrumentation ExceptionCaught to ExceptionThrown
The instrumentation ExceptionCaught event was badly named since it is
actually sent at the time the exception is thrown and is sent even if
the exception is never actually caught. Rename it and associated
methods/fields to ExceptionThrown to more accurately reflect the
event's semantics.
Test: ./test.py --host -j50
Change-Id: I1e9c401ab619259b25928dbf19f62d3fa9573d47
diff --git a/openjdkjvmti/events.cc b/openjdkjvmti/events.cc
index 2944a45..73e6881 100644
--- a/openjdkjvmti/events.cc
+++ b/openjdkjvmti/events.cc
@@ -538,8 +538,8 @@
}
}
- // Call-back when an exception is caught.
- void ExceptionCaught(art::Thread* self ATTRIBUTE_UNUSED,
+ // Call-back when an exception is thrown.
+ void ExceptionThrown(art::Thread* self ATTRIBUTE_UNUSED,
art::Handle<art::mirror::Throwable> exception_object ATTRIBUTE_UNUSED)
REQUIRES_SHARED(art::Locks::mutator_lock_) OVERRIDE {
return;
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 0b7af4e..fe0bad2 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -238,7 +238,7 @@
Dbg::PostFieldModificationEvent(method, dex_pc, this_object.Get(), field, &field_value);
}
- void ExceptionCaught(Thread* thread ATTRIBUTE_UNUSED,
+ void ExceptionThrown(Thread* thread ATTRIBUTE_UNUSED,
Handle<mirror::Throwable> exception_object)
OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_) {
Dbg::PostException(exception_object.Get());
@@ -3145,7 +3145,7 @@
return &field_read_event_ref_count_;
case instrumentation::Instrumentation::kFieldWritten:
return &field_write_event_ref_count_;
- case instrumentation::Instrumentation::kExceptionCaught:
+ case instrumentation::Instrumentation::kExceptionThrown:
return &exception_catch_event_ref_count_;
default:
return nullptr;
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index a8cf59b..758c9e4 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -104,7 +104,7 @@
have_dex_pc_listeners_(false),
have_field_read_listeners_(false),
have_field_write_listeners_(false),
- have_exception_caught_listeners_(false),
+ have_exception_thrown_listeners_(false),
have_branch_listeners_(false),
have_invoke_virtual_or_interface_listeners_(false),
deoptimized_methods_lock_("deoptimized methods lock", kDeoptimizedMethodsLock),
@@ -499,11 +499,11 @@
field_write_listeners_,
listener,
&have_field_write_listeners_);
- PotentiallyAddListenerTo(kExceptionCaught,
+ PotentiallyAddListenerTo(kExceptionThrown,
events,
- exception_caught_listeners_,
+ exception_thrown_listeners_,
listener,
- &have_exception_caught_listeners_);
+ &have_exception_thrown_listeners_);
UpdateInterpreterHandlerTable();
}
@@ -576,11 +576,11 @@
field_write_listeners_,
listener,
&have_field_write_listeners_);
- PotentiallyRemoveListenerFrom(kExceptionCaught,
+ PotentiallyRemoveListenerFrom(kExceptionThrown,
events,
- exception_caught_listeners_,
+ exception_thrown_listeners_,
listener,
- &have_exception_caught_listeners_);
+ &have_exception_thrown_listeners_);
UpdateInterpreterHandlerTable();
}
@@ -1082,17 +1082,17 @@
}
}
-void Instrumentation::ExceptionCaughtEvent(Thread* thread,
+void Instrumentation::ExceptionThrownEvent(Thread* thread,
mirror::Throwable* exception_object) const {
Thread* self = Thread::Current();
StackHandleScope<1> hs(self);
Handle<mirror::Throwable> h_exception(hs.NewHandle(exception_object));
- if (HasExceptionCaughtListeners()) {
+ if (HasExceptionThrownListeners()) {
DCHECK_EQ(thread->GetException(), h_exception.Get());
thread->ClearException();
- for (InstrumentationListener* listener : exception_caught_listeners_) {
+ for (InstrumentationListener* listener : exception_thrown_listeners_) {
if (listener != nullptr) {
- listener->ExceptionCaught(thread, h_exception);
+ listener->ExceptionThrown(thread, h_exception);
}
}
thread->SetException(h_exception.Get());
diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h
index 9969489..f6efb5f 100644
--- a/runtime/instrumentation.h
+++ b/runtime/instrumentation.h
@@ -124,8 +124,8 @@
const JValue& field_value)
REQUIRES_SHARED(Locks::mutator_lock_) = 0;
- // Call-back when an exception is caught.
- virtual void ExceptionCaught(Thread* thread,
+ // Call-back when an exception is thrown.
+ virtual void ExceptionThrown(Thread* thread,
Handle<mirror::Throwable> exception_object)
REQUIRES_SHARED(Locks::mutator_lock_) = 0;
@@ -158,7 +158,7 @@
kDexPcMoved = 0x8,
kFieldRead = 0x10,
kFieldWritten = 0x20,
- kExceptionCaught = 0x40,
+ kExceptionThrown = 0x40,
kBranch = 0x80,
kInvokeVirtualOrInterface = 0x100,
};
@@ -322,8 +322,8 @@
return have_field_write_listeners_;
}
- bool HasExceptionCaughtListeners() const REQUIRES_SHARED(Locks::mutator_lock_) {
- return have_exception_caught_listeners_;
+ bool HasExceptionThrownListeners() const REQUIRES_SHARED(Locks::mutator_lock_) {
+ return have_exception_thrown_listeners_;
}
bool HasBranchListeners() const REQUIRES_SHARED(Locks::mutator_lock_) {
@@ -337,7 +337,7 @@
bool IsActive() const REQUIRES_SHARED(Locks::mutator_lock_) {
return have_dex_pc_listeners_ || have_method_entry_listeners_ || have_method_exit_listeners_ ||
have_field_read_listeners_ || have_field_write_listeners_ ||
- have_exception_caught_listeners_ || have_method_unwind_listeners_ ||
+ have_exception_thrown_listeners_ || have_method_unwind_listeners_ ||
have_branch_listeners_ || have_invoke_virtual_or_interface_listeners_;
}
@@ -345,7 +345,7 @@
bool NonJitProfilingActive() const REQUIRES_SHARED(Locks::mutator_lock_) {
return have_dex_pc_listeners_ || have_method_exit_listeners_ ||
have_field_read_listeners_ || have_field_write_listeners_ ||
- have_exception_caught_listeners_ || have_method_unwind_listeners_ ||
+ have_exception_thrown_listeners_ || have_method_unwind_listeners_ ||
have_branch_listeners_;
}
@@ -424,8 +424,8 @@
}
}
- // Inform listeners that an exception was caught.
- void ExceptionCaughtEvent(Thread* thread, mirror::Throwable* exception_object) const
+ // Inform listeners that an exception was thrown.
+ void ExceptionThrownEvent(Thread* thread, mirror::Throwable* exception_object) const
REQUIRES_SHARED(Locks::mutator_lock_);
// Called when an instrumented method is entered. The intended link register (lr) is saved so
@@ -599,8 +599,8 @@
// instrumentation_lock_.
bool have_field_write_listeners_ GUARDED_BY(Locks::mutator_lock_);
- // Do we have any exception caught listeners? Short-cut to avoid taking the instrumentation_lock_.
- bool have_exception_caught_listeners_ GUARDED_BY(Locks::mutator_lock_);
+ // Do we have any exception thrown listeners? Short-cut to avoid taking the instrumentation_lock_.
+ bool have_exception_thrown_listeners_ GUARDED_BY(Locks::mutator_lock_);
// Do we have any branch listeners? Short-cut to avoid taking the instrumentation_lock_.
bool have_branch_listeners_ GUARDED_BY(Locks::mutator_lock_);
@@ -632,7 +632,7 @@
std::list<InstrumentationListener*> dex_pc_listeners_ GUARDED_BY(Locks::mutator_lock_);
std::list<InstrumentationListener*> field_read_listeners_ GUARDED_BY(Locks::mutator_lock_);
std::list<InstrumentationListener*> field_write_listeners_ GUARDED_BY(Locks::mutator_lock_);
- std::list<InstrumentationListener*> exception_caught_listeners_ GUARDED_BY(Locks::mutator_lock_);
+ std::list<InstrumentationListener*> exception_thrown_listeners_ GUARDED_BY(Locks::mutator_lock_);
// The set of methods being deoptimized (by the debugger) which must be executed with interpreter
// only.
diff --git a/runtime/instrumentation_test.cc b/runtime/instrumentation_test.cc
index d25655f..19ce299 100644
--- a/runtime/instrumentation_test.cc
+++ b/runtime/instrumentation_test.cc
@@ -46,7 +46,7 @@
received_field_read_event(false),
received_field_written_event(false),
received_field_written_object_event(false),
- received_exception_caught_event(false),
+ received_exception_thrown_event(false),
received_branch_event(false),
received_invoke_virtual_or_interface_event(false) {}
@@ -123,10 +123,10 @@
received_field_written_event = true;
}
- void ExceptionCaught(Thread* thread ATTRIBUTE_UNUSED,
+ void ExceptionThrown(Thread* thread ATTRIBUTE_UNUSED,
Handle<mirror::Throwable> exception_object ATTRIBUTE_UNUSED)
OVERRIDE REQUIRES_SHARED(Locks::mutator_lock_) {
- received_exception_caught_event = true;
+ received_exception_thrown_event = true;
}
void Branch(Thread* thread ATTRIBUTE_UNUSED,
@@ -155,7 +155,7 @@
received_field_read_event = false;
received_field_written_event = false;
received_field_written_object_event = false;
- received_exception_caught_event = false;
+ received_exception_thrown_event = false;
received_branch_event = false;
received_invoke_virtual_or_interface_event = false;
}
@@ -168,7 +168,7 @@
bool received_field_read_event;
bool received_field_written_event;
bool received_field_written_object_event;
- bool received_exception_caught_event;
+ bool received_exception_thrown_event;
bool received_branch_event;
bool received_invoke_virtual_or_interface_event;
@@ -355,8 +355,8 @@
return instr->HasFieldReadListeners();
case instrumentation::Instrumentation::kFieldWritten:
return instr->HasFieldWriteListeners();
- case instrumentation::Instrumentation::kExceptionCaught:
- return instr->HasExceptionCaughtListeners();
+ case instrumentation::Instrumentation::kExceptionThrown:
+ return instr->HasExceptionThrownListeners();
case instrumentation::Instrumentation::kBranch:
return instr->HasBranchListeners();
case instrumentation::Instrumentation::kInvokeVirtualOrInterface:
@@ -398,10 +398,10 @@
instr->FieldWriteEvent(self, obj, method, dex_pc, field, value);
break;
}
- case instrumentation::Instrumentation::kExceptionCaught: {
+ case instrumentation::Instrumentation::kExceptionThrown: {
ThrowArithmeticExceptionDivideByZero();
mirror::Throwable* event_exception = self->GetException();
- instr->ExceptionCaughtEvent(self, event_exception);
+ instr->ExceptionThrownEvent(self, event_exception);
self->ClearException();
break;
}
@@ -435,8 +435,8 @@
case instrumentation::Instrumentation::kFieldWritten:
return (!with_object && listener.received_field_written_event) ||
(with_object && listener.received_field_written_object_event);
- case instrumentation::Instrumentation::kExceptionCaught:
- return listener.received_exception_caught_event;
+ case instrumentation::Instrumentation::kExceptionThrown:
+ return listener.received_exception_thrown_event;
case instrumentation::Instrumentation::kBranch:
return listener.received_branch_event;
case instrumentation::Instrumentation::kInvokeVirtualOrInterface:
@@ -463,7 +463,7 @@
// Check there is no registered listener.
EXPECT_FALSE(instr->HasDexPcListeners());
- EXPECT_FALSE(instr->HasExceptionCaughtListeners());
+ EXPECT_FALSE(instr->HasExceptionThrownListeners());
EXPECT_FALSE(instr->HasFieldReadListeners());
EXPECT_FALSE(instr->HasFieldWriteListeners());
EXPECT_FALSE(instr->HasMethodEntryListeners());
@@ -563,8 +563,8 @@
/*with_object*/ false);
}
-TEST_F(InstrumentationTest, ExceptionCaughtEvent) {
- TestEvent(instrumentation::Instrumentation::kExceptionCaught);
+TEST_F(InstrumentationTest, ExceptionThrownEvent) {
+ TestEvent(instrumentation::Instrumentation::kExceptionThrown);
}
TEST_F(InstrumentationTest, BranchEvent) {
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index f8cb243..8c825f3 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -423,9 +423,9 @@
self->VerifyStack();
StackHandleScope<2> hs(self);
Handle<mirror::Throwable> exception(hs.NewHandle(self->GetException()));
- if (instrumentation != nullptr && instrumentation->HasExceptionCaughtListeners()
+ if (instrumentation != nullptr && instrumentation->HasExceptionThrownListeners()
&& self->IsExceptionThrownByCurrentMethod(exception.Get())) {
- instrumentation->ExceptionCaughtEvent(self, exception.Get());
+ instrumentation->ExceptionThrownEvent(self, exception.Get());
}
bool clear_exception = false;
uint32_t found_dex_pc = shadow_frame.GetMethod()->FindCatchBlock(
diff --git a/runtime/jdwp/jdwp_event.cc b/runtime/jdwp/jdwp_event.cc
index 4ab3d69..41cb642 100644
--- a/runtime/jdwp/jdwp_event.cc
+++ b/runtime/jdwp/jdwp_event.cc
@@ -164,7 +164,7 @@
return instrumentation::Instrumentation::kDexPcMoved;
case EK_EXCEPTION:
case EK_EXCEPTION_CATCH:
- return instrumentation::Instrumentation::kExceptionCaught;
+ return instrumentation::Instrumentation::kExceptionThrown;
case EK_METHOD_ENTRY:
return instrumentation::Instrumentation::kMethodEntered;
case EK_METHOD_EXIT:
diff --git a/runtime/thread.cc b/runtime/thread.cc
index cdbb908..3f23926 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -3069,12 +3069,12 @@
// This is a real exception: let the instrumentation know about it.
instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
- if (instrumentation->HasExceptionCaughtListeners() &&
+ if (instrumentation->HasExceptionThrownListeners() &&
IsExceptionThrownByCurrentMethod(exception)) {
// Instrumentation may cause GC so keep the exception object safe.
StackHandleScope<1> hs(this);
HandleWrapperObjPtr<mirror::Throwable> h_exception(hs.NewHandleWrapper(&exception));
- instrumentation->ExceptionCaughtEvent(this, exception.Ptr());
+ instrumentation->ExceptionThrownEvent(this, exception.Ptr());
}
// Does instrumentation need to deoptimize the stack?
// Note: we do this *after* reporting the exception to instrumentation in case it
diff --git a/runtime/trace.cc b/runtime/trace.cc
index 36532c6..d7673f3 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -805,10 +805,10 @@
thread_clock_diff, wall_clock_diff);
}
-void Trace::ExceptionCaught(Thread* thread ATTRIBUTE_UNUSED,
+void Trace::ExceptionThrown(Thread* thread ATTRIBUTE_UNUSED,
Handle<mirror::Throwable> exception_object ATTRIBUTE_UNUSED)
REQUIRES_SHARED(Locks::mutator_lock_) {
- LOG(ERROR) << "Unexpected exception caught event in tracing";
+ LOG(ERROR) << "Unexpected exception thrown event in tracing";
}
void Trace::Branch(Thread* /*thread*/, ArtMethod* method,
diff --git a/runtime/trace.h b/runtime/trace.h
index ad10250..8b0931d 100644
--- a/runtime/trace.h
+++ b/runtime/trace.h
@@ -178,7 +178,7 @@
ArtField* field,
const JValue& field_value)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!*unique_methods_lock_) OVERRIDE;
- void ExceptionCaught(Thread* thread,
+ void ExceptionThrown(Thread* thread,
Handle<mirror::Throwable> exception_object)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!*unique_methods_lock_) OVERRIDE;
void Branch(Thread* thread,