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

Implement SourceLink for Windows PDBs #18539

Merged
merged 1 commit into from
May 9, 2017
Merged

Implement SourceLink for Windows PDBs #18539

merged 1 commit into from
May 9, 2017

Conversation

tmat
Copy link
Member

@tmat tmat commented Apr 7, 2017

Enables /sourcelink for Windows PDBs. Previously we only supported it for Portable PDBs.

  • Create package for Microsoft.DiaSymReader.Native, 1.6.0. The feature requires new diasymreader APIs.

@tmat
Copy link
Member Author

tmat commented Apr 8, 2017

@ctaggart FYI

@tmat
Copy link
Member Author

tmat commented Apr 8, 2017

@gregg-miskelly @caslan FYI

Copy link

@gregg-miskelly gregg-miskelly left a comment

Choose a reason for hiding this comment

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

Excellent.

@ctaggart
Copy link
Contributor

ctaggart commented Apr 8, 2017

@tmat Nice! I was wondering if ya'll were going to pursue this. Any ideas how to detect support when this ships? Currently I look for DebugType of portable or embedded. Should I look for the msbuild version, roslyn version, or something else?

<CompileDependsOn Condition="'$(SourceLinkCreate)' == 'true' and ($(DebugType) == 'portable' or $(DebugType) == 'embedded')">SourceLinkCreate;$(CompileDependsOn)</CompileDependsOn>

@tmat
Copy link
Member Author

tmat commented Apr 8, 2017

@ctaggart I don't think you need to check for anything. If one uses some version of SourceLink that doesn't have that check they should also use a compiler that supports it. If not an error will be reported by the compiler. So just mentioning it in SourceLink docs should be sufficient imo.

@tmat
Copy link
Member Author

tmat commented Apr 26, 2017

Requires changes in #18803.

@tmat
Copy link
Member Author

tmat commented Apr 26, 2017

@dotnet/roslyn-compiler Please review. Still need to update the dependencies to pass tests, but the code is ready for review (and tests pass on my box).

@tmat tmat requested review from jcouv and agocke April 26, 2017 18:40
@@ -31,6 +31,8 @@

using static Roslyn.Test.Utilities.SharedResourceHelpers;
using static Microsoft.CodeAnalysis.CommonDiagnosticAnalyzers;
using Roslyn.Test.PdbUtilities;
using Microsoft.DiaSymReader;
Copy link
Member

@jaredpar jaredpar Apr 27, 2017

Choose a reason for hiding this comment

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

Sort usings #Resolved

Copy link
Member Author

@tmat tmat Apr 27, 2017

Choose a reason for hiding this comment

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

Fixed. #Resolved

var stream = new TestStream(canSeek: false, backingStream: new MemoryStream(sourceArray));
stream.ReadByte();
Assert.Equal(new byte[] { 2, 3, 4 }, stream.ReadAllBytes());
}
Copy link
Member

@jaredpar jaredpar Apr 27, 2017

Choose a reason for hiding this comment

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

Add a test verifying behavior when stream is at the end. #Resolved

Copy link
Member Author

@tmat tmat Apr 27, 2017

Choose a reason for hiding this comment

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

Done. #Closed

@@ -23,7 +23,7 @@ public static class SymReaderFactory
[DllImport("Microsoft.DiaSymReader.Native.amd64.dll", EntryPoint = "CreateSymReader")]
private extern static void CreateSymReader64(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)]out object symReader);

private static ISymUnmanagedReader3 CreateNativeSymReader(Stream pdbStream, object metadataImporter)
private static ISymUnmanagedReader5 CreateNativeSymReader(Stream pdbStream, object metadataImporter)
Copy link
Member

@jaredpar jaredpar Apr 27, 2017

Choose a reason for hiding this comment

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

In the past there were cases where the compiler was installed without the specific version of native diasymreader that we needed. That meant it could be older. Is that the case anymore? If so do we have to worry about cases where ISymUnmanagedReader5 is not avialable? #Resolved

Copy link
Member Author

@tmat tmat Apr 27, 2017

Choose a reason for hiding this comment

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

The compiler doesn't use ISymUnmanagedReader, only ISymUnmanagedWriter. This helper only loads SymReader from DSRN where it always is the latest version. #ByDesign

fixed (byte* bufferPtr = buffer)
{
byte b = 0;
symWriter8.SetSourceLinkData((bufferPtr != null) ? bufferPtr : &b, buffer.Length);
Copy link
Member

@jaredpar jaredpar Apr 27, 2017

Choose a reason for hiding this comment

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

In what case is bufferPtr going to be null? #Closed

Copy link
Member Author

@tmat tmat Apr 27, 2017

Choose a reason for hiding this comment

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

When buffer is empty. #Closed

return null;
}

var buffer = new StringBuilder(256);
Copy link
Member

@jaredpar jaredpar Apr 27, 2017

Choose a reason for hiding this comment

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

Why 256? #Resolved

Copy link
Member Author

@tmat tmat Apr 27, 2017

Choose a reason for hiding this comment

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

Arbitrary max path. I'll remove the commit from this PR - I accidentally added it to this branch while investigating why tests fail on Jenkins and not on my box. #Resolved

@@ -118,5 +118,33 @@ public void PrematureEndOfStream()
var expected = new byte[] { 1, 2, 3, 4, 0, 0 };
Assert.Equal(expected, destArray);
}

[Fact]
public void ReadAllBytes_Seakable()
Copy link
Member

@cston cston Apr 27, 2017

Choose a reason for hiding this comment

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

Typo: Seekable #Resolved

stream.ReadByte();
stream.ReadByte();
Assert.Equal(new byte[0], stream.ReadAllBytes());
}
Copy link
Member

@cston cston Apr 27, 2017

Choose a reason for hiding this comment

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

Consider testing ReadAllBytes() when TestStream.Length > backingStream.Length (the Array.Resize case). #Resolved

@cston
Copy link
Member

cston commented Apr 27, 2017

LGTM

";
var sourceLinkBlob = Encoding.UTF8.GetBytes(@"
{
""documents"": {
Copy link
Member

@jcouv jcouv Apr 27, 2017

Choose a reason for hiding this comment

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

Nit: open brace on new line #WontFix

Copy link
Member Author

@tmat tmat Apr 27, 2017

Choose a reason for hiding this comment

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

This is not C# ;) #WontFix


var pdbStream = new MemoryStream();
c.EmitToArray(EmitOptions.Default.WithDebugInformationFormat(format), pdbStream: pdbStream, sourceLinkStream: new MemoryStream(sourceLinkBlob));
pdbStream.Position = 0;
Copy link
Member

@jcouv jcouv Apr 27, 2017

Choose a reason for hiding this comment

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

Is this position reset necessary? Maybe GetSourceLinkData should handle the reset, if it doesn't already. #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to GetSourceLinkData.


In reply to: 113743925 [](ancestors = 113743925)

}
}
";
var sourceLinkStream = new TestStream(canRead: true, readFunc: (_, __, ___) => { throw new Exception("Error!"); });
Copy link
Member

@jcouv jcouv Apr 27, 2017

Choose a reason for hiding this comment

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

Hopefully, discards will be supported in lambdas soon ;-) #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

+1


In reply to: 113744881 [](ancestors = 113744881)

@@ -1193,12 +1193,9 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
keyFileSetting = ParseGenericPathToFile(keyFileSetting, diagnostics, baseDirectory);
}

if (sourceLink != null)
if (sourceLink != null && !emitPdb)
Copy link
Member

@jcouv jcouv Apr 27, 2017

Choose a reason for hiding this comment

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

Should the VB command-line parser have a similar change? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, forgot about that.


In reply to: 113746766 [](ancestors = 113746766)

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

You'll also want to update the command-line documentation file: https://github.com/dotnet/roslyn/blob/master/docs/compilers/CSharp/CommandLine.md

(and its VB counter-part if applicable)
Thanks

@tmat
Copy link
Member Author

tmat commented Apr 27, 2017

@jcouv Updated documentation of the command line args for both VB and C#. Please check if it looks good.

@@ -1,6 +1,6 @@
{
"dependencies": {
"Microsoft.DiaSymReader.Native": "1.5.0"
"Microsoft.DiaSymReader.Native": "1.6.0-beta2-25219"
Copy link
Member

Choose a reason for hiding this comment

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

I'm assuming that we will not ship dev15.3 with a reference to beta package. Can you file a follow-up issue to fix this reference once a release package is available?
It's probably also good to think about timeline to make this happen.

Copy link
Member Author

@tmat tmat Apr 27, 2017

Choose a reason for hiding this comment

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

We produce RTM packages once the final VS RTM build is available. I don't think a work item is needed as this is a common step taken during Roslyn nuget package publishing.

Copy link
Member Author

@tmat tmat Apr 27, 2017

Choose a reason for hiding this comment

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

I should probably clarify. The flow for this package is documented here: https://github.com/dotnet/roslyn-debug/tree/master/src/Microsoft.DiaSymReader.Native. To get RTM binaries we need to wait until VS RTM build is produced by the lab.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Sounds like this step is already covered by standard release process.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM

@jaredpar
Copy link
Member

jaredpar commented May 2, 2017

@tmat looks like we have two sign offs but unfortunately this ended up conflicting with my SDK change. Can we rebase this and get it merged soon?

Bar for compiler layer starts going up next week. Want to get this in while it still meets the bar.

@tmat
Copy link
Member Author

tmat commented May 2, 2017

@jaredpar Waiting for a fixed build of DSRN. Should be available on Wed.

@tmat tmat force-pushed the DSRN16 branch 3 times, most recently from d2d3a92 to 6fa0bc7 Compare May 9, 2017 00:26
@tmat
Copy link
Member Author

tmat commented May 9, 2017

test windows_release_vs-integration_prtest please

@tmat tmat merged commit 3986cdb into dotnet:master May 9, 2017
@tmat tmat deleted the DSRN16 branch May 9, 2017 17:39
@kzu
Copy link
Contributor

kzu commented Jun 1, 2017

Is there a tentative milestone where this will ship? 15.[something]?

@jaredpar
Copy link
Member

jaredpar commented Jun 1, 2017

@kzu this will ship in 15.3

@tmat tmat added this to the 15.3 milestone Jun 1, 2017
@kzu
Copy link
Contributor

kzu commented Jun 1, 2017

Should it be in the current preview then? or will it make it to preview 2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants