1

Background to my question:

  • I have a third-party library which I want to debug, it has IgnoreSymbolStoreSequencePoints flag for the DebuggableAttribute. It can be assumed that there were compile-time code optimizations, i.e. /optimize and the DebuggableAttribute bitmask is release standard ( 01 00 02 00 00 00 00 00 ).
  • Via ILSpy or some other tool I could generate pdb file for it that will presumably hold sequence points so I can debug more easily line-by-line (explicit sequence points)

But to my question: is this pdb file pointless in terms of providing a smooth debugging experience while its sequence points are to be ignored due to the flag and the optimization of MSIL code presumably does not allow for much in terms of implicit sequence points (nops)?

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
tinmanjk
  • 301
  • 1
  • 9

1 Answers1

0

With IgnoreSymbolStoreSequencePoints, the debugger only uses implicit sequence points. Those occur:

  • for nop instructions
  • whenever the IL stack is empty
  • directly following call instructions

ILSpy will try to create a .pdb with sequence points in the same locations as the implicit sequence points (PR 1967). Effectively, the generated .pdb associates source code lines with the implicit sequence points.

This allows some limited stepping through the decompiled code, as there are often enough implicit sequence points. But you're right that the debugging experience won't always be smooth.

Daniel
  • 15,944
  • 2
  • 54
  • 60
  • thanks for the anwer. It sheds some light on the pdb generation from ILSpy. However, IgnoreSymbolStoreSequencePoints as you stated suppresses completely any pdb explicit sequence points. So in effect, we are still using the implicit sequence points and not the ones in pdb, or am I wrong? – tinmanjk Jul 02 '21 at 09:46
  • `IgnoreSymbolStoreSequencePoints` means the .pdb is ignored by the JIT. The generated machine code will only be able to properly stop at the implicit sequence points. However the debugger doesn't care for that attribute, and will still look at the .pdb file. – Daniel Jul 02 '21 at 10:03
  • In which ways is the debugger then assisted by the explicit sequence points in the pdb file which the JIT compiler ignores? – tinmanjk Jul 02 '21 at 16:21
  • The debugger uses the pdb sequence points to map IL offsets to line numbers. – Daniel Jul 02 '21 at 17:05
  • So, the explicit sequence points provide the actual mapping between source code lines and IL offsets which are used by the debugger. And the implicit sequence points generated by the JIT compiler provide the mapping between IL offsets and machine code. So, in effect the ILSpy explicit sequence points serve as a way to facilitate as best as possible the (real/no brackets) code line - machine code offset mapping. ILSpy follows the implicit sequence points rules to generate the explicit sequence points. Is that correct? – tinmanjk Jul 04 '21 at 11:55