Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Portable PDB debugging in FSharp.Private.Compiler.dll #6383

Merged
merged 5 commits into from
Mar 29, 2019

Conversation

KevinRansom
Copy link
Member

  1. Whilst Portable PDB's seem to work well for most projects. The FSharp.Private.Compiler project, and I expect the FSharp.Compiler.Service dll have an abysmal portable pdb debugging experience.

  2. Fsi on the coreclr can AV when generating code under certain circumstances when generating exception stacks for generated code, due to errors in the portable pdb file.

  3. The F# build generates Desktop PDBs for FSharp.Private.Compiler.dll rather than creating portable pdbs and converting to desktop pdbs because the pdb converter


The underlying cause of all of these issues is that during the reduction phase of parsing the compiler merges ranges to compute the source code range for a reduced expression.

It turns out that parser presents a stack of expressions for reductions that may exist in different source files. The merge took no account that the range could exist over multiple files.

Part of the fix here is to pin the end of the range and to discard source ranges in other files here:

https://github.com/Microsoft/visualfsharp/compare/master...KevinRansom:symbols?expand=1#diff-b328b19055c7a49c80ee3f8ae4c8c536R376.

A separate but related issue is that SynExpr.Paren can have a value for leftParenRange, and rightParenRange in different files. The fix here is to change the Range calculation such that if they are in different files, it uses the leftParenRange as Range.

  • The above applies to Desktop PDBs as well as portable PDBs. However, it seems that the Desktop PDB loading code in VS, is much more resilient to rubbish sequence points than the Portable PDB reader.

Additionally this PR improves the value validation when creating the Portable PDB file, to match limits in the portable PDB specs.


And re-enable portable pdb generation.

@dsyme, Please take a look at this, and let me know if there is a better approach.

@KevinRansom KevinRansom requested review from brettfo and dsyme March 27, 2019 20:06
Copy link
Contributor

@dsyme dsyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll approve, but added various comments which should likely be dealt with

src/fsharp/ast.fs Outdated Show resolved Hide resolved
// printf "reduce %d\n" prod
let redResult = reduction parseState
valueStack.Push(ValueInfo(redResult, lhsPos.[0], lhsPos.[1]))
try
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff could be made minimal, though it's no big deal, the other changes are an improvement

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but my OCD doesn't work that way :-(


if i < 1 || offsetDelta <> 0 then // ILOffset must not be 0
builder.WriteCompressedInteger(offsetDelta)

if sps.[i].Line = 0xfeefee && sps.[i].EndLine = 0xfeefee then // Hidden-sequence-point-record
let capLine v = if v < 0 || v >= 0x20000000 then 0xfeefee else v
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of 0xfeefee here is very odd. FEEFEE has a special meaning for a hidden sequence point https://blogs.msdn.microsoft.com/jmstall/2005/06/19/line-hidden-and-0xfeefee-sequence-points/. I think this should be something else.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the data is invalid, I can throw the sequence point away instead of writing a hidden sequence point.

Lets see what that looks like.

@KevinRansom KevinRansom merged commit 165b736 into dotnet:master Mar 29, 2019
@KevinRansom KevinRansom deleted the symbols branch March 29, 2019 17:35
brettfo added a commit that referenced this pull request Mar 30, 2019
#6383 seems to have fixed it.
KevinRansom pushed a commit that referenced this pull request Mar 30, 2019
#6383 seems to have fixed it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants