CodeView and "line 0" ?

I've been playing with Fred Riss's "line 0" patch for DWARF
(https://reviews.llvm.org/D16569) but in adapting it for current trunk,
I find the DwarfDebug stuff has been refactored to allow either DWARF
or CodeView. That's all good, but the question is whether the "line 0"
patch should be DWARF-specific or common. The DWARF spec explicitly
states that code not associated with any particular source location
should be associated with line number 0. I don't know what CodeView
(or debuggers that consume CodeView) would think of seeing "line 0" show
up in the debug info.

Does anybody know?
Thanks,
--paulr

Note that clang is also assigning line 0 to code that doesn't have a corresponding source location. So CodeView needs to deal with this already, though I don't know how it currently handles this.

-- adrian

I mean, we just skip over instructions without a DebugLoc:

void CodeViewDebug::beginInstruction(const MachineInstr *MI) {
DebugHandlerBase::beginInstruction(MI);

// Ignore DBG_VALUE locations and function prologue.
if (!Asm || !CurFn || MI->isDebugValue() ||
MI->getFlag(MachineInstr::FrameSetup))
return;
DebugLoc DL = MI->getDebugLoc();
if (DL == PrevInstLoc || !DL)
return;
maybeRecordLocation(DL, Asm->MF);
}

Seems reasonable to extend the condition with ’ || DL->getLine() == 0’. I’m not aware of a good way to say “this instruction is not associated with any line” in CodeView.

I mean, we just skip over instructions without a DebugLoc:

void CodeViewDebug::beginInstruction(const MachineInstr *MI) {
  DebugHandlerBase::beginInstruction(MI);

  // Ignore DBG_VALUE locations and function prologue.
  if (!Asm || !CurFn || MI->isDebugValue() ||
      MI->getFlag(MachineInstr::FrameSetup))
    return;
  DebugLoc DL = MI->getDebugLoc();
  if (DL == PrevInstLoc || !DL)
    return;
  maybeRecordLocation(DL, Asm->MF);
}

Seems reasonable to extend the condition with ' || DL->getLine() == 0'.
I'm not aware of a good way to say "this instruction is not associated with
any line" in CodeView.

Perhaps we could set emit line 0 as line number 0xfeefee
(AlwaysStepIntoLineNumber).

Fred’s patch does some bookkeeping to identify instructions that aren’t properly attributed anywhere, and turn that into a line-0 record for DWARF in beginInstruction(). Given that CodeView has a “nothing to see here” line number, which happens to be different from DWARF’s, I’m now inclined to put the bookkeeping into the base class and let the DWARF and CodeView subclasses use it as appropriate.

Thanks guys!

–paulr