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

This takes Steffens repro and has a slightly different fix -- Fixes I1556 #1545

Merged
merged 7 commits into from
Sep 20, 2016
29 changes: 17 additions & 12 deletions src/absil/ilwritepdb.fs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ let writePdbInfo fixupOverlappingSequencePoints showTimes f fpdb info cvChunk =
match Map.tryFind k res with
| Some xsR -> xsR := sp :: !xsR; res
| None -> Map.add k (ref [sp]) res

let res = Array.fold add res sps
let res = Map.toList res // ordering may not be stable
List.map (fun (_,x) -> Array.ofList !x) res
Expand All @@ -502,22 +502,27 @@ let writePdbInfo fixupOverlappingSequencePoints showTimes f fpdb info cvChunk =
if spset.Length > 0 then
Array.sortInPlaceWith SequencePoint.orderByOffset spset
let sps =
spset |> Array.map (fun sp ->
// Ildiag.dprintf "token 0x%08lx has an sp at offset 0x%08x\n" minfo.MethToken sp.Offset
(sp.Offset, sp.Line, sp.Column,sp.EndLine, sp.EndColumn))
// Use of alloca in implementation of pdbDefineSequencePoints can give stack overflow here
spset |> Array.map (fun sp ->
// Ildiag.dprintf "token 0x%08lx has an sp at offset 0x%08x\n" minfo.MethToken sp.Offset
(sp.Offset, sp.Line, sp.Column,sp.EndLine, sp.EndColumn))
// Use of alloca in implementation of pdbDefineSequencePoints can give stack overflow here
if sps.Length < 5000 then
pdbDefineSequencePoints !pdbw (getDocument spset.[0].Document) sps)
pdbDefineSequencePoints !pdbw (getDocument spset.[0].Document) sps)

// Write the scopes
let rec writePdbScope top sco =
if top || sco.Locals.Length <> 0 || sco.Children.Length <> 0 then
pdbOpenScope !pdbw sco.StartOffset
let rec writePdbScope parent sco =
if parent = None || sco.Locals.Length <> 0 || sco.Children.Length <> 0 then
// Only nest scopes if the child scope is a different size from
let nested =
match parent with
| Some p -> sco.StartOffset <> p.StartOffset || sco.EndOffset <> p.EndOffset
| None -> true
if nested then pdbOpenScope !pdbw sco.StartOffset
sco.Locals |> Array.iter (fun v -> pdbDefineLocalVariable !pdbw v.Name v.Signature v.Index)
sco.Children |> Array.iter (writePdbScope false)
pdbCloseScope !pdbw sco.EndOffset
writePdbScope true minfo.RootScope
sco.Children |> Array.iter (writePdbScope (if nested then Some sco else parent))
if nested then pdbCloseScope !pdbw sco.EndOffset

writePdbScope None minfo.RootScope
pdbCloseMethod !pdbw
end)
reportTime showTimes "PDB: Wrote methods"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1720,21 +1720,19 @@
{
// Code size 14 (0xe)
.maxstack 3
.locals init ([0] string V_0,
[1] string greeting)
.line 12,12 : 9,31
.locals init ([0] string greeting,
[1] string V_1)
.line 12,12 : 9,31 ''
IL_0000: nop
IL_0001: call string ABC::get_greeting()
IL_0006: stloc.0
.line 22,22 : 13,35
.line 22,22 : 13,35 ''
IL_0007: call string ABC/ABC::get_greeting()
IL_000c: stloc.1
IL_000d: ret
} // end of method $ABC::.cctor

} // end of class '<StartupCode$TopLevelModule>'.$ABC


// =============================================================

// *********** DISASSEMBLY COMPLETE ***********************
Original file line number Diff line number Diff line change
Expand Up @@ -1692,18 +1692,17 @@
{
// Code size 14 (0xe)
.maxstack 3
.locals init ([0] string V_0,
[1] string greeting)
.line 12,12 : 9,31
.locals init ([0] string greeting,
[1] string V_1)
.line 12,12 : 9,31 ''
IL_0000: nop
IL_0001: call string ABC::get_greeting()
IL_0006: stloc.0
.line 22,22 : 13,35
.line 22,22 : 13,35 ''
IL_0007: call string ABC/ABC::get_greeting()
IL_000c: stloc.1
IL_000d: ret
} // end of method $ABC::.cctor

} // end of class '<StartupCode$ToplevelModuleP>'.$ABC


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2513,18 +2513,17 @@
{
// Code size 14 (0xe)
.maxstack 3
.locals init ([0] string V_0,
[1] string greeting)
.line 19,19 : 9,31
.locals init ([0] string greeting,
[1] string V_1)
.line 19,19 : 9,31 ''
IL_0000: nop
IL_0001: call string XYZ.ABC::get_greeting()
IL_0006: stloc.0
.line 29,29 : 13,35
.line 29,29 : 13,35 ''
IL_0007: call string XYZ.ABC/ABC::get_greeting()
IL_000c: stloc.1
IL_000d: ret
} // end of method $ToplevelNamespace::.cctor

} // end of class '<StartupCode$ToplevelNamespace>'.$ToplevelNamespace


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2471,18 +2471,17 @@
{
// Code size 14 (0xe)
.maxstack 3
.locals init ([0] string V_0,
[1] string greeting)
.line 19,19 : 9,31
.locals init ([0] string greeting,
[1] string V_1)
.line 19,19 : 9,31 ''
IL_0000: nop
IL_0001: call string XYZ.ABC::get_greeting()
IL_0006: stloc.0
.line 29,29 : 13,35
.line 29,29 : 13,35 ''
IL_0007: call string XYZ.ABC/ABC::get_greeting()
IL_000c: stloc.1
IL_000d: ret
} // end of method $ToplevelNamespace::.cctor

} // end of class '<StartupCode$ToplevelNamespaceP>'.$ToplevelNamespace


Expand Down
Loading