Skip to content
Merged
Changes from all commits
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
15 changes: 11 additions & 4 deletions src/fsharp/absil/ilwritepdb.fs
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,25 @@ let checkSum (url: string) (checksumAlgorithm: HashAlgorithm) =
//---------------------------------------------------------------------
// Portable PDB Writer
//---------------------------------------------------------------------

let b0 n = (n &&& 0xFF)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can open Internal.Utilities.Library.Extras.Bits

Copy link
Contributor

Choose a reason for hiding this comment

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

i32AsBytes could be moved from il.fs into lib.fs too, there are a few duplications of these

Copy link
Contributor Author

@uweigand uweigand Sep 2, 2021

Choose a reason for hiding this comment

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

I see. Just to clarify, that module seems to contain the b0 .. b3 functions, but not i32AsBytes, so the latter would have to remain, right? EDIT: sorry, missed your update. I'll look into that.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's actually OK, this is not the only duplication, we can clean that up later I think

Copy link
Contributor

Choose a reason for hiding this comment

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

I merged - if you'd like to submit a PR consolidating b0 etc that would be cool

let b1 n = ((n >>> 8) &&& 0xFF)
let b2 n = ((n >>> 16) &&& 0xFF)
let b3 n = ((n >>> 24) &&& 0xFF)
let i32AsBytes i = [| byte (b0 i); byte (b1 i); byte (b2 i); byte (b3 i) |]

let cvMagicNumber = 0x53445352L
let pdbGetCvDebugInfo (mvid: byte[]) (timestamp: int32) (filepath: string) (cvChunk: BinaryChunk) =
let iddCvBuffer =
// Debug directory entry
let path = (Encoding.UTF8.GetBytes filepath)
let buffer = Array.zeroCreate (sizeof<int32> + mvid.Length + sizeof<int32> + path.Length + 1)
let offset, size = (0, sizeof<int32>) // Magic Number RSDS dword: 0x53445352L
Buffer.BlockCopy(BitConverter.GetBytes cvMagicNumber, 0, buffer, offset, size)
Buffer.BlockCopy(i32AsBytes (int cvMagicNumber), 0, buffer, offset, size)
let offset, size = (offset + size, mvid.Length) // mvid Guid
Buffer.BlockCopy(mvid, 0, buffer, offset, size)
let offset, size = (offset + size, sizeof<int32>) // # of pdb files generated (1)
Buffer.BlockCopy(BitConverter.GetBytes 1, 0, buffer, offset, size)
Buffer.BlockCopy(i32AsBytes 1, 0, buffer, offset, size)
let offset, size = (offset + size, path.Length) // Path to pdb string
Buffer.BlockCopy(path, 0, buffer, offset, size)
buffer
Expand All @@ -200,9 +207,9 @@ let pdbGetEmbeddedPdbDebugInfo (embeddedPdbChunk: BinaryChunk) (uncompressedLeng
let iddPdbBuffer =
let buffer = Array.zeroCreate (sizeof<int32> + sizeof<int32> + int(stream.Length))
let offset, size = (0, sizeof<int32>) // Magic Number dword: 0x4244504dL
Buffer.BlockCopy(BitConverter.GetBytes pdbMagicNumber, 0, buffer, offset, size)
Buffer.BlockCopy(i32AsBytes (int pdbMagicNumber), 0, buffer, offset, size)
let offset, size = (offset + size, sizeof<int32>) // Uncompressed size
Buffer.BlockCopy(BitConverter.GetBytes (int uncompressedLength), 0, buffer, offset, size)
Buffer.BlockCopy(i32AsBytes (int uncompressedLength), 0, buffer, offset, size)
let offset, size = (offset + size, int(stream.Length)) // Uncompressed size
Buffer.BlockCopy(stream.ToArray(), 0, buffer, offset, size)
buffer
Expand Down