Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix portable pdb writing
  • Loading branch information
KevinRansom committed Mar 27, 2019
commit a60e099caeba1b157a898d8bba4256765a1a66be
46 changes: 30 additions & 16 deletions src/absil/ilwritepdb.fs
Original file line number Diff line number Diff line change
Expand Up @@ -371,34 +371,48 @@ let generatePortablePdb (embedAllSource: bool) (embedSourceList: string list) (s
else
// Sequence-point-record
let offsetDelta =
if i > 0 then sps.[i].Offset - sps.[i - 1].Offset // delta from previous offset
else sps.[i].Offset // delta IL offset
let offset = sps.[i].Offset
if offset > 0x20000000 then 0 //offset out of range
elif i > 0 then offset - sps.[i - 1].Offset // delta from previous offset
else offset // delta IL offset

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
Contributor 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.

let capColumn v = if v < 0 || v >= 0x10000 then true, 0 else false, v

let startLine = capLine sps.[i].Line
let endLine = capLine sps.[i].EndLine
let startColumnIsCapped, startColumn = capColumn sps.[i].Column
let endColumnIsCapped, endColumn = capColumn sps.[i].EndColumn

if startLine = 0xfeefee || endLine = 0xfeefee || // Hidden-sequence-point-record
startLine > endLine || (startColumn = 0 && endColumn = 0) ||
startColumnIsCapped || endColumnIsCapped
then
builder.WriteCompressedInteger(0)
builder.WriteCompressedInteger(0)
else // Non-hidden-sequence-point-record
let deltaLines = sps.[i].EndLine - sps.[i].Line // lines
let deltaLines = endLine - startLine // lines
builder.WriteCompressedInteger(deltaLines)

let deltaColumns = sps.[i].EndColumn - sps.[i].Column // Columns
if deltaLines = 0 then
builder.WriteCompressedInteger(deltaColumns)
else
builder.WriteCompressedSignedInteger(deltaColumns)

let deltaColumns = endColumn - startColumn // Columns
try
if deltaLines = 0 then
builder.WriteCompressedInteger(deltaColumns)
else
builder.WriteCompressedSignedInteger(deltaColumns)
with | _ -> System.Diagnostics.Debugger.Break()
if previousNonHiddenStartLine < 0 then // delta Start Line & Column:
builder.WriteCompressedInteger(sps.[i].Line)
builder.WriteCompressedInteger(sps.[i].Column)
builder.WriteCompressedInteger(startLine)
builder.WriteCompressedInteger(startColumn)
else
builder.WriteCompressedSignedInteger(sps.[i].Line - previousNonHiddenStartLine)
builder.WriteCompressedSignedInteger(sps.[i].Column - previousNonHiddenStartColumn)
builder.WriteCompressedSignedInteger(startLine - previousNonHiddenStartLine)
builder.WriteCompressedSignedInteger(startColumn - previousNonHiddenStartColumn)

previousNonHiddenStartLine <- sps.[i].Line
previousNonHiddenStartColumn <- sps.[i].Column
previousNonHiddenStartLine <- startLine
previousNonHiddenStartColumn <- startColumn

getDocumentHandle singleDocumentIndex, metadata.GetOrAddBlob(builder)

Expand Down
5 changes: 4 additions & 1 deletion src/fsharp/ast.fs
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,10 @@ and
/// Get the syntactic range of source code covered by this construct.
member e.Range =
match e with
| SynExpr.Paren (range=m)
| SynExpr.Paren (_,leftParenRange:range,rightParenRange:range option,r:range) ->
match rightParenRange with
| Some rightParenRange when leftParenRange.FileIndex <> rightParenRange.FileIndex -> leftParenRange
| _ -> r
| SynExpr.Quote (range=m)
| SynExpr.Const (range=m)
| SynExpr.Typed (range=m)
Expand Down
49 changes: 30 additions & 19 deletions src/utils/prim-parsing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -361,38 +361,49 @@ module internal Implementation =
#if DEBUG
if Flags.debug then Console.Write("reduce popping {0} values/states, lookahead {1}", n, report haveLookahead lookaheadToken)
#endif
for i = 0 to n - 1 do
// For every range to reduce merge it
for i = 0 to n - 1 do
if valueStack.IsEmpty then failwith "empty symbol stack"
let topVal = valueStack.Peep()
let topVal = valueStack.Peep() // Grab topVal
valueStack.Pop()
stateStack.Pop()
ruleValues.[(n-i)-1] <- topVal.value
ruleStartPoss.[(n-i)-1] <- topVal.startPos
ruleEndPoss.[(n-i)-1] <- topVal.endPos
if i = 0 then lhsPos.[1] <- topVal.endPos
if i = n - 1 then lhsPos.[0] <- topVal.startPos

// Use the lookahead token to populate the locations if the rhs is empty
if n = 0 then

let ruleIndex = (n-i)-1
ruleValues.[ruleIndex] <- topVal.value
ruleStartPoss.[ruleIndex] <- topVal.startPos
ruleEndPoss.[ruleIndex] <- topVal.endPos

if i = 0 then
// Initial range
lhsPos.[0] <- topVal.startPos
lhsPos.[1] <- topVal.endPos
elif topVal.startPos.FileIndex = lhsPos.[1].FileIndex && topVal.startPos.Line <= lhsPos.[1].Line then
// Reduce range if same file as the initial end point
lhsPos.[0] <- topVal.startPos

// Use the lookahead token to populate the locations if the rhs is empty
if n = 0 then
if haveLookahead then
lhsPos.[0] <- lookaheadStartPos
lhsPos.[1] <- lookaheadEndPos
lhsPos.[0] <- lookaheadStartPos
lhsPos.[1] <- lookaheadEndPos
else
lhsPos.[0] <- lexbuf.StartPos
lhsPos.[1] <- lexbuf.EndPos
try
// 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
Contributor 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 :-(

// printf "reduce %d\n" prod
let redResult = reduction parseState
let valueInfo = ValueInfo(redResult, lhsPos.[0], lhsPos.[1])
valueStack.Push(valueInfo)
let currState = stateStack.Peep()
let newGotoState = gotoTable.Read(int tables.productionToNonTerminalTable.[prod], currState)
stateStack.Push(newGotoState)

#if DEBUG
if Flags.debug then Console.WriteLine(" goto state {0}", newGotoState)
#endif
with
| Accept res ->
finished <- true
with
| Accept res ->
finished <- true
valueStack.Push(ValueInfo(res, lhsPos.[0], lhsPos.[1]))
| RecoverableParseError ->
#if DEBUG
Expand Down