diff --git a/ddprof-lib/src/main/cpp/counters.h b/ddprof-lib/src/main/cpp/counters.h index e9c8f9de9..226191936 100644 --- a/ddprof-lib/src/main/cpp/counters.h +++ b/ddprof-lib/src/main/cpp/counters.h @@ -55,7 +55,9 @@ X(CODECACHE_RUNTIME_STUBS_SIZE_BYTES, "codecache_runtime_stubs_size_bytes") \ X(AGCT_NOT_REGISTERED_IN_TLS, "agct_not_registered_in_tls") \ X(AGCT_NOT_JAVA, "agct_not_java") \ - X(AGCT_NATIVE_NO_JAVA_CONTEXT, "agct_native_no_java_context") + X(AGCT_NATIVE_NO_JAVA_CONTEXT, "agct_native_no_java_context") \ + X(HANDLED_SIGSEGV_SAFEFETCH, "handled_sigsegv_safefetch") \ + X(HANDLED_SIGSEGV_WALKVM, "handled_sigsegv_walkvm") #define X_ENUM(a, b) a, typedef enum CounterId : int { DD_COUNTER_TABLE(X_ENUM) DD_NUM_COUNTERS diff --git a/ddprof-lib/src/main/cpp/profiler.cpp b/ddprof-lib/src/main/cpp/profiler.cpp index 156461393..13c38b5ea 100644 --- a/ddprof-lib/src/main/cpp/profiler.cpp +++ b/ddprof-lib/src/main/cpp/profiler.cpp @@ -849,6 +849,7 @@ void Profiler::segvHandler(int signo, siginfo_t* siginfo, void* ucontext) { // Skip the fault instruction, as if it successfully loaded NULL frame.pc() += length; frame.retval() = 0; + Counters::increment(HANDLED_SIGSEGV_SAFEFETCH); return; } @@ -857,6 +858,7 @@ void Profiler::segvHandler(int signo, siginfo_t* siginfo, void* ucontext) { // Act as if the load returned default_value argument frame.pc() += length; frame.retval() = frame.arg1(); + Counters::increment(HANDLED_SIGSEGV_SAFEFETCH); return; } diff --git a/ddprof-lib/src/main/cpp/stackWalker.cpp b/ddprof-lib/src/main/cpp/stackWalker.cpp index d7623060b..4b33bbc6d 100644 --- a/ddprof-lib/src/main/cpp/stackWalker.cpp +++ b/ddprof-lib/src/main/cpp/stackWalker.cpp @@ -424,6 +424,7 @@ int StackWalker::walkVM(void* ucontext, ASGCT_CallFrame* frames, int max_depth) void StackWalker::checkFault() { VMThread* vm_thread = VMThread::current(); if (vm_thread != NULL && sameStack(vm_thread->exception(), &vm_thread)) { + Counters::increment(HANDLED_SIGSEGV_WALKVM); longjmp(*(jmp_buf*)vm_thread->exception(), 1); } }