-
Notifications
You must be signed in to change notification settings - Fork 789
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
Conversation
There was a problem hiding this 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
// printf "reduce %d\n" prod | ||
let redResult = reduction parseState | ||
valueStack.Push(ValueInfo(redResult, lhsPos.[0], lhsPos.[1])) | ||
try |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 :-(
src/absil/ilwritepdb.fs
Outdated
|
||
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
#6383 seems to have fixed it.
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.
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.
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.
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.