It seems to me that emitting DWARF line number information using .loc directives is currently broken. CellSPU is currently the only in tree target that sets HasDotLocAndDotFile in its MCAsmInfo and I can't get it to produce any line number information.
Is this a known issue? I understand that there are lots of changes going on in this area. Any idea what it would take to fix?
Richard Osborne wrote:
It seems to me that emitting DWARF line number information using .loc directives is currently broken. CellSPU is currently the only in tree target that sets HasDotLocAndDotFile in its MCAsmInfo and I can't get it to produce any line number information.
I think I understand why this is happening. Since HasDotLocAndDotFile is set the DwarfDebug class doesn't emit the line number table as a series of bytes:
// If the target is using .loc/.file, the assembler will be emitting the
// .debug_line table automatically.
if (MAI->hasDotLocAndDotFile())
return;
Previously .loc directives are printed by selecting ISD::DEBUG_LOC nodes to pseudo instructions which print as the directive. For example:
def DWARF_LOC : Pseudo<(outs), (ins i32imm:$line, i32imm:$col, i32imm:$file),
".loc $file, $line, $col",
[(dwarf_loc (i32 imm:$line), (i32 imm:$col), (i32 imm:$file))]>;
ISD::DEBUG_LOC nodes are produced when debug stoppoints are expanded. However debug stoppoints are no longer produced by the frontend since debug info is now encoded using metadata. Therefore there are no .loc directives in the output and no line number information.
It looks like AsmPrinter::processDebugLoc function should be updated to check whether HasDotLocAndDotFile is set and if it is emit the .loc directive.
Does this make sense?
Hi Richard,
Richard Osborne wrote:
It seems to me that emitting DWARF line number information using .loc
directives is currently broken. CellSPU is currently the only in tree
target that sets HasDotLocAndDotFile in its MCAsmInfo and I can't get it
to produce any line number information.
I think I understand why this is happening. Since HasDotLocAndDotFile is
set the DwarfDebug class doesn't emit the line number table as a series
of bytes:
// If the target is using .loc/.file, the assembler will be emitting the
// .debug_line table automatically.
if (MAI->hasDotLocAndDotFile())
return;
Previously .loc directives are printed by selecting ISD::DEBUG_LOC nodes
to pseudo instructions which print as the directive. For example:
def DWARF_LOC : Pseudo<(outs), (ins i32imm:$line, i32imm:$col,
i32imm:$file),
".loc $file, $line, $col",
[(dwarf_loc (i32 imm:$line), (i32 imm:$col), (i32 imm:$file))]>;
ISD::DEBUG_LOC nodes are produced when debug stoppoints are expanded.
However debug stoppoints are no longer produced by the frontend since
debug info is now encoded using metadata. Therefore there are no .loc
directives in the output and no line number information.
It looks like AsmPrinter::processDebugLoc function should be updated to
check whether HasDotLocAndDotFile is set and if it is emit the .loc
directive.
Does this make sense?
Yes, it makes sense to emit .loc in processDebugLoc if the DebugLoc has changed.