Next: , Previous: , Up: Grade modifiers   [Contents][Index]


3.4.9 Grade modifiers for target language debugging

Mercury programs are intended to be debugged using mdb, the Mercury debugger. However, mdb treats non-Mercury code as a black box, and cannot give any insights into its behavior.

.target_debug

Compiling programs in a grade that includes the .target_debug grade modifier generates executables that are intended to be debuggable with usual debuggers for the target language selected by the base grade.

This grade modifier is intended mainly to help the implementors of Mercury itself debug interactions between compiler-generated target code and the Mercury runtime system. However, in certain rare cases, it may also be useful to other users in debugging interactions between compiler-generated target code and the contents of foreign_proc and/or foreign_code pragmas.

This grade modifier could be applicable to all base grades, but is intentionally restricted to MLDS grades. This is because in LLDS grades, the assembler-like C code generated by mmc will probably confuse debuggers such as gdb, and it will definitely confuse any Mercury programmer who is not a Mercury implementor. The more idiomatic target language code that mmc generates in MLDS grades is still far from trivial for non-implementors to understand, but at least they have a fighting chance.