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

Option for removing PDB path information in PE #9814

Merged
merged 1 commit into from
Mar 16, 2016

Conversation

jaredpar
Copy link
Member

Related to #9813

@jaredpar
Copy link
Member Author

CC @dotnet/roslyn-compiler, @tmat

@@ -1776,6 +1776,18 @@ private static EmitResult ToEmitResultAndFree(DiagnosticBag diagnostics, bool su
bool emitPortablePdb = moduleBeingBuilt.EmitOptions.DebugInformationFormat == DebugInformationFormat.PortablePdb;
string pdbPath = (pdbStreamProvider != null) ? (moduleBeingBuilt.EmitOptions.PdbFilePath ?? FileNameUtilities.ChangeExtension(SourceModule.Name, "pdb")) : null;

// The PDB path is emitted in it's entirety into the PE. This makes it impossible to have deterministic
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be done in the command line compiler, not here. We should just use whatever was set in EmitOptions.

Copy link
Member

Choose a reason for hiding this comment

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

It could be done around https://github.com/dotnet/roslyn/blob/master/src/Compilers/Core/Portable/CommandLine/CommonCompiler.cs#L437 as @tmat suggests, but I think of this (i.e. the decision what bits should be placed into the PDB) more as a feature of the core compiler, not the command-line processor. So I like the code here.

Copy link
Member

Choose a reason for hiding this comment

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

From API point of view it's kind of weird that the caller explicitly sets a path they want to put into the PDB and we change that based on another option.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think this can be done in the command line compiler. There are two PDB paths we have to consider:

  1. The path where the PDB is emitted on disk.
  2. The path embedded in the PE.

If we did the work in the compiler it would effect both options. Doing the work here allows us to properly separate the concerns.

Copy link
Member

Choose a reason for hiding this comment

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

        /// <summary>
        /// The name of the PDB file to be embedded in the PE image, or null to use the default.
        /// </summary>
        /// <remarks>
        /// If not specified the file name of the source module with an extension changed to "pdb" is used.
        /// </remarks>
        public string PdbFilePath { get; private set; }

This is not the path that the PDB is saved to. Emit API is not concerned with saving into a file. It just writes to the stream. The command line compiler opens the file stream.

Copy link
Member Author

Choose a reason for hiding this comment

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

@tmat I don't see how EmitOptions.PdbFilePath can be a safe value to change. As shown above that path is definitely used in at least one case to control the file path written to disk. It seems that this is a bug or the documentation comment for that property is inaccurate.

Copy link
Member

Choose a reason for hiding this comment

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

Do you mean the fact that the path is passed to PdbWriter? PdbWriter always writes to a stream. It doesn't write to the specified path. It needs the path just because the native implementation is odd.

Copy link
Member

Choose a reason for hiding this comment

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

The doc comment is precise.

Copy link
Member

Choose a reason for hiding this comment

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

This comment is imprecise:

// The calls ISymUnmanagedWriter2.GetDebugInfo require a file name in order to succeed.  This is 
                    // frequently used during PDB writing.  Ensure a name is provided here in the case we were given
                    // only a Stream value.
                    nativePdbWriter = new Cci.PdbWriter(pdbPath, testSymWriterFactory, deterministic);

It should say "Ensure a name is provided here since we write to a stream."

Copy link
Member Author

Choose a reason for hiding this comment

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

@tmat

PdbWriter always writes to a stream. It doesn't write to the specified path. It needs the path just because the native implementation is odd.

That is indeed odd. If that's the case I'll try and find a better place for the work around.

@gafter
Copy link
Member

gafter commented Mar 16, 2016

👍

jaredpar added a commit that referenced this pull request Mar 16, 2016
Option for removing PDB path information in PE
@jaredpar jaredpar merged commit 41cbdd1 into dotnet:master Mar 16, 2016
@AlekseyTs
Copy link
Contributor

LGTM

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.

5 participants