简体   繁体   中英

How do debuggers know the line numbers in the source code?

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)?

When you compile your code with debugging flags (eg, 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM