Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit38f489a

Browse files
authored
Fix: Portable PDB MethodDebugInformation table size differs from MethodDef #3514 (#3553)
* Fix MethodDebugTable for portablePDBs* ensure that pdb gets a record for abstract methods* minimise diff
1 parent602daf8 commit38f489a

File tree

6 files changed

+46
-28
lines changed

6 files changed

+46
-28
lines changed

‎src/absil/ilread.fs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2903,7 +2903,6 @@ and seekReadMethodRVA ctxt (idx,nm,_internalcall,noinline,aggressiveinline,numty
29032903
try
29042904

29052905
letpdbm= pdbReaderGetMethod pdbr(uncodedToken TableNames.Method idx)
2906-
//let rootScope = pdbMethodGetRootScope pdbm
29072906
letsps= pdbMethodGetSequencePoints pdbm
29082907
(*dprintf "#sps for 0x%x = %d\n" (uncodedToken TableNames.Method idx) (Array.length sps)*)
29092908
(* let roota,rootb = pdbScopeGetOffsets rootScope in*)

‎src/absil/ilsupp.fs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,9 +1230,6 @@ let pdbMethodGetToken (meth:PdbMethod) : int32 =
12301230
lettoken= meth.symMethod.Token
12311231
token.GetToken()
12321232

1233-
letpdbMethodGetRootScope(meth:PdbMethod):PdbMethodScope=
1234-
{ symScope= meth.symMethod.RootScope}
1235-
12361233
letpdbMethodGetSequencePoints(meth:PdbMethod):PdbSequencePoint array=
12371234
letpSize= meth.symMethod.SequencePointCount
12381235
letoffsets= Array.zeroCreate pSize

‎src/absil/ilsupp.fsi‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ val pdbDocumentGetLanguageVendor: PdbDocument -> byte[] (* guid *)
7373
valpdbDocumentFindClosestLine:PdbDocument->int->int
7474

7575
valpdbMethodGetToken:PdbMethod->int32
76-
valpdbMethodGetRootScope:PdbMethod->PdbMethodScope
7776
valpdbMethodGetSequencePoints:PdbMethod->PdbSequencePoint array
7877

7978
valpdbScopeGetChildren:PdbMethodScope->PdbMethodScope array

‎src/absil/ilwrite.fs‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,7 @@ let GenMethodDefAsRow cenv env midx (md: ILMethodDef) =
25772577
MethName=md.Name
25782578
LocalSignatureToken=localToken
25792579
Params=[||](* REVIEW*)
2580-
RootScope= rootScope
2580+
RootScope=SomerootScope
25812581
Range=
25822582
match ilmbody.SourceMarkerwith
25832583
| Some mwhen cenv.generatePdb->
@@ -2592,9 +2592,20 @@ let GenMethodDefAsRow cenv env midx (md: ILMethodDef) =
25922592
Column=m.EndColumn})
25932593
|_-> None
25942594
SequencePoints=seqpoints}
2595-
25962595
cenv.AddCode code
2597-
addr
2596+
addr
2597+
| MethodBody.Abstract->
2598+
// Now record the PDB record for this method - we write this out later.
2599+
if cenv.generatePdbthen
2600+
cenv.pdbinfo.Add
2601+
{ MethToken= getUncodedToken TableNames.Method midx
2602+
MethName= md.Name
2603+
LocalSignatureToken=0x0// No locals it's abstract
2604+
Params=[||]
2605+
RootScope= None
2606+
Range= None
2607+
SequencePoints=[||]}
2608+
0x0000
25982609
| MethodBody.Native->
25992610
failwith"cannot write body of native method - Abstract IL cannot roundtrip mixed native/managed binaries"
26002611
|_->0x0000)

‎src/absil/ilwritepdb.fs‎

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ type PdbMethodData =
8181
MethName:string
8282
LocalSignatureToken:int32
8383
Params:PdbLocalVar array
84-
RootScope:PdbMethodScope
84+
RootScope:PdbMethodScope option
8585
Range:(PdbSourceLoc* PdbSourceLoc) option
8686
SequencePoints:PdbSequencePoint array}
8787

@@ -224,7 +224,7 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
224224
letexternalRowCounts= getRowCounts info.TableRowCounts
225225
letdocs=
226226
match info.Documentswith
227-
|null-> Array.empty<PdbDocumentData>
227+
|null-> Array.empty
228228
|_-> info.Documents
229229

230230
letmetadata= MetadataBuilder()
@@ -324,23 +324,28 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
324324
letdocHandle,sequencePointBlob=
325325
letsps=
326326
match minfo.SequencePointswith
327-
|null-> Array.empty<PdbSequencePoint>
327+
|null-> Array.empty
328328
|_->
329329
match minfo.Rangewith
330-
| None-> Array.empty<PdbSequencePoint>
330+
| None-> Array.empty
331331
| Some(_,_)-> minfo.SequencePoints
332332

333-
letgetDocumentHandle d=
334-
if docs.Length=0|| d<0|| d> docs.Lengththen
335-
Unchecked.defaultof<DocumentHandle>
336-
else
337-
match documentIndex.TryGetValue(docs.[d].File)with
338-
|false,_-> Unchecked.defaultof<DocumentHandle>
339-
|true, h-> h
333+
letbuilder=new BlobBuilder()
334+
builder.WriteCompressedInteger(minfo.LocalSignatureToken)
340335

341336
if sps.Length=0then
337+
builder.WriteCompressedInteger(0)
338+
builder.WriteCompressedInteger(0)
342339
Unchecked.defaultof<DocumentHandle>, Unchecked.defaultof<BlobHandle>
343340
else
341+
letgetDocumentHandle d=
342+
if docs.Length=0|| d<0|| d> docs.Lengththen
343+
Unchecked.defaultof<DocumentHandle>
344+
else
345+
match documentIndex.TryGetValue(docs.[d].File)with
346+
|false,_-> Unchecked.defaultof<DocumentHandle>
347+
|true, h-> h
348+
344349
// Return a document that the entire method body is declared within.
345350
// If part of the method body is in another document returns nil handle.
346351
lettryGetSingleDocumentIndex=
@@ -350,12 +355,8 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
350355
singleDocumentIndex<--1
351356
singleDocumentIndex
352357

353-
letbuilder=new BlobBuilder()
354-
builder.WriteCompressedInteger(minfo.LocalSignatureToken)
355-
356358
// Initial document: When sp's spread over more than one document we put the initial document here.
357359
letsingleDocumentIndex= tryGetSingleDocumentIndex
358-
359360
if singleDocumentIndex=-1then
360361
builder.WriteCompressedInteger( MetadataTokens.GetRowNumber(DocumentHandle.op_Implicit(getDocumentHandle(sps.[0].Document))))
361362

@@ -438,7 +439,10 @@ let generatePortablePdb (embedAllSource:bool) (embedSourceList:string list) (sou
438439
for localVariablein s.Localsdo
439440
lastLocalVariableHandle<- metadata.AddLocalVariable(LocalVariableAttributes.None, localVariable.Index, metadata.GetOrAddString(localVariable.Name))
440441
)
441-
writeMethodScope minfo.RootScope)
442+
443+
match minfo.RootScopewith
444+
| None->()
445+
| Some scope-> writeMethodScope scope)
442446

443447
letentryPoint=
444448
match info.EntryPointwith
@@ -564,7 +568,9 @@ let writePdbInfo showTimes f fpdb info cvChunk =
564568
sco.Children|> Array.iter(writePdbScope(if nestedthen Some scoelse parent))
565569
if nestedthen pdbCloseScope!pdbw sco.EndOffset
566570

567-
writePdbScope None minfo.RootScope
571+
match minfo.RootScopewith
572+
| None->()
573+
| Some rootscope-> writePdbScope None rootscope
568574
pdbCloseMethod!pdbw
569575
end)
570576
reportTime showTimes"PDB: Wrote methods"
@@ -674,7 +680,10 @@ let writeMdbInfo fmdb f info =
674680
for childin scope.Childrendo
675681
writeScope(child)
676682
wr?CloseScope(scope.EndOffset)
677-
writeScope(meth.RootScope)
683+
match meth.RootScopewith
684+
| None->()
685+
| Some rootscope-> writeScope(rootscope)
686+
678687

679688
// Finished generating debug information for the curretn method
680689
wr?CloseMethod()
@@ -721,5 +730,8 @@ let logDebugInfo (outfile:string) (info:PdbData) =
721730
if scope.Locals.Length>0then
722731
fprintfn sw"%s Locals:%A" offs[for pin scope.Locals-> sprintf"%d:%s" p.Index p.Name]
723732
for childin scope.Childrendo writeScope(offs+"") child
724-
writeScope"" meth.RootScope
733+
734+
match meth.RootScopewith
735+
| None->()
736+
| Some rootscope-> writeScope"" rootscope
725737
fprintfn sw""

‎src/absil/ilwritepdb.fsi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type PdbMethodData =
4444
MethName:string
4545
LocalSignatureToken:int32
4646
Params:PdbLocalVar array
47-
RootScope:PdbMethodScope
47+
RootScope:PdbMethodScope option
4848
Range:(PdbSourceLoc* PdbSourceLoc) option
4949
SequencePoints:PdbSequencePoint array}
5050

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp