Here we will explain the steps that is required for debug setup in dev environment
Step 1: Add the Remote Debugging JVM Parameter
To use remote debugging, you must start AEM with this JVM parameter: -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
You can add the parameter by doing any of the following:
Add it to your crx-quickstart/bin/start script CQ_JVM_OPTS environment variable (so your server always starts in debug mode).
Include it as a parameter when starting AEM with java -jar directly. For example, java -Xmx512m -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n -jar cq-author-4502.jar
Step 2: Start a remote debugging session
To start a remote debugging session from Eclipse, do the following:
Choose Run > Debug Configurations.
Right-click Remote Java Applications and select New.
Select your AEM project under Project.
Type in the port from the "address" configuration of the jvm parameter defined above. In the example, it is port 8000 (and the hostname of the machine you are connecting to, most likely localhost)
To start a debugging session, double-click your new configuration in the Debug Configurations screen after saving it.
That's it you have a debug setup in your dev environment. Now you can run debug in IDE and start your AEM instance in debug mode, then you will be able to start the debugging. For other IDE you might have to add different setup like in Intelij you might need to add debug from add configuration and adding remote app in it.