提交 a2c4623b 编写于 作者: J Jared Parsons

Merge pull request #5600 from TyOverby/5534-debug-portable

Add PDB format option to /debug flag
......@@ -59,6 +59,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
bool concurrentBuild = true;
bool deterministic = false; // TODO(5431): Enable deterministic mode by default
bool emitPdb = false;
DebugInformationFormat debugInformationFormat = DebugInformationFormat.Pdb;
bool debugPlus = false;
string pdbPath = null;
bool noStdLib = false;
......@@ -516,11 +517,22 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
if (value.IsEmpty())
{
AddDiagnostic(diagnostics, ErrorCode.ERR_SwitchNeedsString, MessageID.IDS_Text.Localize(), name);
continue;
}
else if (!string.Equals(value, "full", StringComparison.OrdinalIgnoreCase) &&
!string.Equals(value, "pdbonly", StringComparison.OrdinalIgnoreCase))
{
AddDiagnostic(diagnostics, ErrorCode.ERR_BadDebugType, value);
switch (value.ToLower()) {
case "full":
case "pdbonly":
debugInformationFormat = DebugInformationFormat.Pdb;
break;
case "portable":
debugInformationFormat = DebugInformationFormat.PortablePdb;
break;
case "embedded":
debugInformationFormat = DebugInformationFormat.Embedded;
break;
default:
AddDiagnostic(diagnostics, ErrorCode.ERR_BadDebugType, value);
break;
}
}
continue;
......@@ -1053,21 +1065,6 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
var parsedFeatures = CompilerOptionParseUtilities.ParseFeatures(features);
var debugInfoFormat = DebugInformationFormat.Pdb;
string pdbFormatStr;
if (emitPdb && parsedFeatures.TryGetValue("pdb", out pdbFormatStr))
{
if (pdbFormatStr == "portable")
{
debugInfoFormat = DebugInformationFormat.PortablePdb;
}
else if (pdbFormatStr == "embedded")
{
debugInfoFormat = DebugInformationFormat.Embedded;
emitPdb = false;
}
}
string compilationName;
GetCompilationAndModuleNames(diagnostics, outputKind, sourceFiles, sourceFilesSpecified, moduleAssemblyName, ref outputFileName, ref moduleName, out compilationName);
......@@ -1116,7 +1113,7 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
var emitOptions = new EmitOptions
(
metadataOnly: false,
debugInformationFormat: debugInfoFormat,
debugInformationFormat: debugInformationFormat,
pdbFilePath: null, // to be determined later
outputNameOverride: null, // to be determined later
baseAddress: baseAddress,
......
......@@ -1177,42 +1177,62 @@ public void Debug()
var parsedArgs = DefaultParse(new[] { "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(false, parsedArgs.CompilationOptions.DebugPlusMode);
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb);
parsedArgs = DefaultParse(new[] { "/debug-", "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(false, parsedArgs.CompilationOptions.DebugPlusMode);
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb);
parsedArgs = DefaultParse(new[] { "/debug", "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(false, parsedArgs.CompilationOptions.DebugPlusMode);
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb);
parsedArgs = DefaultParse(new[] { "/debug+", "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(true, parsedArgs.CompilationOptions.DebugPlusMode);
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb);
parsedArgs = DefaultParse(new[] { "/debug+", "/debug-", "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(false, parsedArgs.CompilationOptions.DebugPlusMode);
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb);
parsedArgs = DefaultParse(new[] { "/debug:full", "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(false, parsedArgs.CompilationOptions.DebugPlusMode);
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb);
parsedArgs = DefaultParse(new[] { "/debug:FULL", "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(false, parsedArgs.CompilationOptions.DebugPlusMode);
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb);
parsedArgs = DefaultParse(new[] { "/debug:pdbonly", "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(false, parsedArgs.CompilationOptions.DebugPlusMode);
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb);
parsedArgs = DefaultParse(new[] { "/debug:portable", "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(false, parsedArgs.CompilationOptions.DebugPlusMode);
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.PortablePdb);
parsedArgs = DefaultParse(new[] { "/debug:embedded", "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(false, parsedArgs.CompilationOptions.DebugPlusMode);
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Embedded);
parsedArgs = DefaultParse(new[] { "/debug:PDBONLY", "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(false, parsedArgs.CompilationOptions.DebugPlusMode);
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb);
parsedArgs = DefaultParse(new[] { "/debug:full", "/debug:pdbonly", "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
Assert.Equal(false, parsedArgs.CompilationOptions.DebugPlusMode);
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb);
parsedArgs = DefaultParse(new[] { "/debug:pdbonly", "/debug:full", "a.cs" }, _baseDirectory);
parsedArgs.Errors.Verify();
......
......@@ -90,6 +90,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim concurrentBuild As Boolean = True
Dim deterministic As Boolean = False
Dim emitPdb As Boolean
Dim debugInformationFormat As DebugInformationFormat = DebugInformationFormat.Pdb
Dim noStdLib As Boolean = False
Dim utf8output As Boolean = False
Dim outputFileName As String = Nothing
......@@ -581,16 +582,19 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Continue For
Case "debug"
' parse only for backwards compat
value = RemoveQuotesAndSlashes(value)
If value IsNot Nothing Then
If String.IsNullOrEmpty(value) Then
AddDiagnostic(diagnostics, ERRID.ERR_ArgumentRequired, "debug", ":pdbonly|full")
ElseIf Not String.Equals(value, "full", StringComparison.OrdinalIgnoreCase) AndAlso
Not String.Equals(value, "pdbonly", StringComparison.OrdinalIgnoreCase) Then
AddDiagnostic(diagnostics, ERRID.ERR_InvalidSwitchValue, "debug", value)
End If
Select Case value.ToLower()
Case "full", "pdbonly"
debugInformationFormat = DebugInformationFormat.Pdb
Case "portable"
debugInformationFormat = DebugInformationFormat.PortablePdb
Case "embedded"
debugInformationFormat = DebugInformationFormat.Embedded
Case Else
AddDiagnostic(diagnostics, ERRID.ERR_InvalidSwitchValue, "debug", value)
End Select
End If
emitPdb = True
......@@ -1160,17 +1164,6 @@ lVbRuntimePlus:
Dim parsedFeatures = CompilerOptionParseUtilities.ParseFeatures(features)
Dim debugInfoFormat = DebugInformationFormat.Pdb
Dim pdbFormatStr As String = Nothing
If emitPdb AndAlso parsedFeatures.TryGetValue("pdb", pdbFormatStr) Then
If StringComparer.Ordinal.Equals(pdbFormatStr, "portable") Then
debugInfoFormat = DebugInformationFormat.PortablePdb
ElseIf StringComparer.Ordinal.Equals(pdbFormatStr, "embedded") Then
debugInfoFormat = DebugInformationFormat.Embedded
emitPdb = False
End If
End If
Dim compilationName As String = Nothing
GetCompilationAndModuleNames(diagnostics, outputKind, sourceFiles, moduleAssemblyName, outputFileName, moduleName, compilationName)
......@@ -1223,7 +1216,7 @@ lVbRuntimePlus:
Dim emitOptions = New EmitOptions(
metadataOnly:=False,
debugInformationFormat:=debugInfoFormat,
debugInformationFormat:=debugInformationFormat,
pdbFilePath:=Nothing, ' to be determined later
outputNameOverride:=Nothing, ' to be determined later
fileAlignment:=fileAlignment,
......
......@@ -2199,30 +2199,47 @@ a.vb
parsedArgs = DefaultParse({"/debug-", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify()
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb)
parsedArgs = DefaultParse({"/debug", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify()
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb)
parsedArgs = DefaultParse({"/debug+", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify()
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb)
parsedArgs = DefaultParse({"/debug+", "/debug-", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify()
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb)
parsedArgs = DefaultParse({"/debug:full", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify()
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb)
parsedArgs = DefaultParse({"/debug:FULL", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify()
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb)
parsedArgs = DefaultParse({"/debug:pdbonly", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify()
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb)
parsedArgs = DefaultParse({"/debug:portable", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify()
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.PortablePdb)
parsedArgs = DefaultParse({"/debug:embedded", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify()
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Embedded)
parsedArgs = DefaultParse({"/debug:PDBONLY", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify()
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb)
parsedArgs = DefaultParse({"/debug:full", "/debug:pdbonly", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify()
Assert.Equal(parsedArgs.EmitOptions.DebugInformationFormat, DebugInformationFormat.Pdb)
parsedArgs = DefaultParse({"/debug:pdbonly", "/debug:full", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify()
......@@ -2245,7 +2262,7 @@ a.vb
Assert.Equal(DebugInformationFormat.Pdb, parsedArgs.EmitOptions.DebugInformationFormat)
parsedArgs = DefaultParse({"/debug:", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_ArgumentRequired).WithArguments("debug", ":pdbonly|full"))
parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments("debug", ""))
parsedArgs = DefaultParse({"/debug:+", "a.vb"}, _baseDirectory)
parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_InvalidSwitchValue).WithArguments("debug", "+"))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册