17

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.

liam xu
  • 2,892
  • 10
  • 42
  • 65
  • 3
    For reference : http://docs.oracle.com/javase/1.4.2/docs/guide/jpda/architecture.html Reading about `JPDA` should answer what does JVM do for Debug implementation. – Mukul Goel Oct 29 '12 at 07:46

3 Answers3

11

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.

Afshin Moazami
  • 2,092
  • 5
  • 33
  • 55
jondinham
  • 8,271
  • 17
  • 80
  • 137
1

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?

Community
  • 1
  • 1
Himanshu P
  • 9,586
  • 6
  • 37
  • 46
0

plz check this it gives a summary on what is debugging

http://www.indiastudychannel.com/resources/102306-Debugging-Software-Engineering.aspx

gurusai
  • 153
  • 4
  • 16