How to debug Gradle Test task?

I am working on code coverage with jacoco offline instrumentation. I am trying to add custom data to jacoco.exec file in the afterTest part, but unable to get the jacocoAgent object. seems like test execution and afterTest does not share the same JVM. so I wanted to debug the test execution flow.

I am using IntelliJ to debug. In the frames section, I could see the debugger stops at the debug point(in class org.gradle.api.tasks.testing.Test) but the class is not showing up.