I have learned programming for a couple of years, and used debug frequently.But I still don't understand the core principle of debug, how it works?How does singe line debugging(step into) implement?
take the java language for example.
What does CPU do for debug implementation?
what does JVM do for debug implementation?
what does eclipse do for debug implementation?
May be the three stuff I listed above have nothing to do with debug. I only guessed it.I have googled for some time and gained nothing useful for me(of course,debug itself is complicated), I hope more simple interpretation.
Thanks.
Each processor has its own design of debugging mechanism.
For the case of x86 CPU, the processor has 6 debug registers which store the debug break-points and break-conditions. Have a brief look at this article for Intel x86 CPU debugging mechanism: http://en.wikipedia.org/wiki/X86_debug_register
For the case of Java debugging mechanism, see: http://docs.oracle.com/javase/7/docs/technotes/guides/jpda/architecture.html as pointed out by Mukul Goel in the comment stream under the question.
In order to facilitate debugging (using break points and such), the compiler inserts certain additional information into the complied output it generates (i.e. the binary file or the JVM bytecode file in case of Java). This extra information allows mapping each line of the compiled output to the corresponding source file.
I haven't answered all parts of your question, but hopefully enough to help you get started. Check out these resources:
http://en.wikipedia.org/wiki/Debug_symbol
How does a debugger work?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With