Home | History | Annotate | Download | only in runtime

Lines Matching refs:Instrumentation

17 #include "instrumentation.h"
32 namespace instrumentation {
34 class TestInstrumentationListener FINAL : public instrumentation::InstrumentationListener {
148 // Unique keys used to test Instrumentation::ConfigureStubs.
152 void CheckConfigureStubs(const char* key, Instrumentation::InstrumentationLevel level) {
154 instrumentation::Instrumentation* instr = Runtime::Current()->GetInstrumentation();
159 ScopedSuspendAll ssa("Instrumentation::ConfigureStubs");
163 Instrumentation::InstrumentationLevel GetCurrentInstrumentationLevel() {
174 instrumentation::Instrumentation* instr = Runtime::Current()->GetInstrumentation();
178 ScopedSuspendAll ssa("Add instrumentation listener");
195 ScopedSuspendAll ssa("Remove instrumentation listener");
209 instrumentation::Instrumentation* instrumentation = runtime->GetInstrumentation();
216 instrumentation->EnableDeoptimization();
218 instrumentation->Deoptimize(method);
225 instrumentation::Instrumentation* instrumentation = runtime->GetInstrumentation();
231 instrumentation->Undeoptimize(method);
233 instrumentation->DisableDeoptimization(key);
240 instrumentation::Instrumentation* instrumentation = runtime->GetInstrumentation();
247 instrumentation->EnableDeoptimization();
249 instrumentation->DeoptimizeEverything(key);
255 instrumentation::Instrumentation* instrumentation = runtime->GetInstrumentation();
261 instrumentation->UndeoptimizeEverything(key);
263 instrumentation->DisableDeoptimization(key);
270 instrumentation::Instrumentation* instrumentation = runtime->GetInstrumentation();
276 instrumentation->EnableMethodTracing(key, needs_interpreter);
282 instrumentation::Instrumentation* instrumentation = runtime->GetInstrumentation();
288 instrumentation->DisableMethodTracing(key);
292 static bool HasEventListener(const instrumentation::Instrumentation* instr, uint32_t event_type)
295 case instrumentation::Instrumentation::kMethodEntered:
297 case instrumentation::Instrumentation::kMethodExited:
299 case instrumentation::Instrumentation::kMethodUnwind:
301 case instrumentation::Instrumentation::kDexPcMoved:
303 case instrumentation::Instrumentation::kFieldRead:
305 case instrumentation::Instrumentation::kFieldWritten:
307 case instrumentation::Instrumentation::kExceptionCaught:
309 case instrumentation::Instrumentation::kBranch:
311 case instrumentation::Instrumentation::kInvokeVirtualOrInterface:
314 LOG(FATAL) << "Unknown instrumentation event " << event_type;
319 static void ReportEvent(const instrumentation::Instrumentation* instr, uint32_t event_type,
324 case instrumentation::Instrumentation::kMethodEntered:
327 case instrumentation::Instrumentation::kMethodExited: {
332 case instrumentation::Instrumentation::kMethodUnwind:
335 case instrumentation::Instrumentation::kDexPcMoved:
338 case instrumentation::Instrumentation::kFieldRead:
341 case instrumentation::Instrumentation::kFieldWritten: {
346 case instrumentation::Instrumentation::kExceptionCaught: {
353 case instrumentation::Instrumentation::kBranch:
356 case instrumentation::Instrumentation::kInvokeVirtualOrInterface:
360 LOG(FATAL) << "Unknown instrumentation event " << event_type;
368 case instrumentation::Instrumentation::kMethodEntered:
370 case instrumentation::Instrumentation::kMethodExited:
372 case instrumentation::Instrumentation::kMethodUnwind:
374 case instrumentation::Instrumentation::kDexPcMoved:
376 case instrumentation::Instrumentation::kFieldRead:
378 case instrumentation::Instrumentation::kFieldWritten:
380 case instrumentation::Instrumentation::kExceptionCaught:
382 case instrumentation::Instrumentation::kBranch:
384 case instrumentation::Instrumentation::kInvokeVirtualOrInterface:
387 LOG(FATAL) << "Unknown instrumentation event " << event_type;
395 instrumentation::Instrumentation* instr = Runtime::Current()->GetInstrumentation();
404 EXPECT_EQ(instrumentation::kMainHandlerTable, instr->GetInterpreterHandlerTable());
416 // Test instrumentation listeners for each event.
418 TestEvent(instrumentation::Instrumentation::kMethodEntered);
422 TestEvent(instrumentation::Instrumentation::kMethodExited);
426 TestEvent(instrumentation::Instrumentation::kMethodUnwind);
430 TestEvent(instrumentation::Instrumentation::kDexPcMoved);
434 TestEvent(instrumentation::Instrumentation::kFieldRead);
438 TestEvent(instrumentation::Instrumentation::kFieldWritten);
442 TestEvent(instrumentation::Instrumentation::kExceptionCaught);
446 TestEvent(instrumentation::Instrumentation::kBranch);
450 TestEvent(instrumentation::Instrumentation::kInvokeVirtualOrInterface);
455 jobject class_loader = LoadDex("Instrumentation");
457 instrumentation::Instrumentation* instr = runtime->GetInstrumentation();
486 instrumentation::Instrumentation* instr = runtime->GetInstrumentation();
502 jobject class_loader = LoadDex("Instrumentation");
504 instrumentation::Instrumentation* instr = runtime->GetInstrumentation();
518 // Deoptimizing a method does not change instrumentation level.
519 EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentNothing,
527 EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter,
534 EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentNothing,
541 EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentNothing,
550 instrumentation::Instrumentation* instr = runtime->GetInstrumentation();
555 EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter,
561 EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentNothing,
569 instrumentation::Instrumentation* instr = runtime->GetInstrumentation();
574 EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
580 EXPECT_EQ(Instrumentation::InstrumentationLevel::kInstrumentNothing,
588 Instrumentation* const instr = Runtime::Current()->GetInstrumentation(); \
590 (_level == Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter); \
608 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
611 CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
612 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
616 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
618 // Check we can switch to instrumentation stubs
620 Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
621 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
624 // Check we can disable instrumentation.
625 CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
626 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
630 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
634 Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter);
635 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 1U);
637 // Check we can disable instrumentation.
638 CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
639 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
643 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
645 // Configure stubs with instrumentation stubs.
647 Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
648 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
653 Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter);
654 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 1U);
656 // Check we can disable instrumentation.
657 CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
658 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
662 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
666 Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter);
667 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 1U);
669 // Configure stubs with instrumentation stubs.
671 Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
672 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
675 // Check we can disable instrumentation.
676 CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
677 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
682 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
684 // Configure stubs with instrumentation stubs.
686 Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
687 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
692 Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter);
693 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 1U);
695 // Configure stubs with instrumentation stubs again.
697 Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
698 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
701 // Check we can disable instrumentation.
702 CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
703 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
707 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
710 CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
711 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
713 CheckConfigureStubs(kClientTwoKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
714 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
718 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
720 // Configure stubs with instrumentation stubs for 1st client.
722 Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
723 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
726 // Configure stubs with instrumentation stubs for 2nd client.
728 Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
729 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
732 // 1st client requests instrumentation deactivation but 2nd client still needs
733 // instrumentation stubs.
734 CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
735 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
738 // 2nd client requests instrumentation deactivation
739 CheckConfigureStubs(kClientTwoKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
740 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
744 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
748 Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter);
749 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 1U);
753 Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter);
754 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 2U);
756 // 1st client requests instrumentation deactivation but 2nd client still needs interpreter.
757 CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
758 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 1U);
760 // 2nd client requests instrumentation deactivation
761 CheckConfigureStubs(kClientTwoKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
762 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
766 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
768 // Configure stubs with instrumentation stubs for 1st client.
770 Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
771 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
776 Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter);
777 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 2U);
779 // 1st client requests instrumentation deactivation but 2nd client still needs interpreter.
780 CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
781 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 1U);
783 // 2nd client requests instrumentation deactivation
784 CheckConfigureStubs(kClientTwoKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
785 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
789 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
793 Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter);
794 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 1U);
796 // Configure stubs with instrumentation stubs for 2nd client.
798 Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs);
799 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter, 2U);
801 // 1st client requests instrumentation deactivation but 2nd client still needs
802 // instrumentation stubs.
803 CheckConfigureStubs(kClientOneKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
804 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentWithInstrumentationStubs,
807 // 2nd client requests instrumentation deactivation
808 CheckConfigureStubs(kClientTwoKey, Instrumentation::InstrumentationLevel::kInstrumentNothing);
809 CHECK_INSTRUMENTATION(Instrumentation::InstrumentationLevel::kInstrumentNothing, 0U);
812 } // namespace instrumentation