Search code examples
compiler-construction

Line number debug information in my compiler


I am trying to implement my own compiler.

As a result of compiler, I should receive assembler listing for NASM or FASM, that I will compile with that external assembler. But unfortunately, I did not find any way how to instruct NASM or FASM to generate line info in DWARF or STABS or in some other "source map" file where I will be able to read HighLevelSourceCodeLine_number->OffsetLengthInMachineCode". Currently the only solution I see - create assembler by hand that will be able to do this, but it is not easy and short task.

May be someone has other ideas?


Solution

  • I guess you are looking for NASM's %line directive. (To generate debugging info, you need to use the -g command line flag.)