7

Debuggers like the ones in Eclipse, NetBeans, Visual Studio etc

I am wondering because, debuggers work on the machine code while it is being executed... How they keep track of the line numbers in the source code?

Isn't it very difficult to keep track of line numbers since a high level instruction may have a bunch of machine language instructions and another might have no machine language instruction (probably because it is just supporting another high level instruction)?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Sam
  • 1,842
  • 3
  • 19
  • 33

1 Answers1

6

When you compile your code with debugging flags (e.g., gcc -g ...), the compiler inserts information about the source files and line numbers into the compiled binary so that the debugger can use this information during runtime. This answer discusses debugging symbols in more detail.

Community
  • 1
  • 1
larsks
  • 277,717
  • 41
  • 399
  • 399
  • Is that the difference between debug version and the release version? – Sam Jan 08 '13 at 18:42
  • 1
    No. That may be *a* difference between debug and release versions, but typically debugging builds will also include a variety of extra logging, console output, additional testing, and other code meant to ease the task of identifying errors in the code. Really, a "debug version" is whatever the author of the code wants it to be. – larsks Jan 08 '13 at 18:45