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

Use symbolGenerator to raise diagnostic identity key level #4924

Merged
merged 1 commit into from
Sep 12, 2024
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
55 changes: 36 additions & 19 deletions src/Microsoft.SymbolManifestGenerator/SymbolManifestGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public static class SymbolManifestGenerator
{
private const int TargetDebugLevel = 0x154 | 0x1 | 0x500; // Private | Binary | SourceIndexed

private static readonly JsonSerializerOptions s_serializeOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true
};

public static bool GenerateManifest(ITracer tracer, DirectoryInfo dir, string manifestFileName, bool specialFilesRequireAdjacentRuntime = true)
{
ManifestDataV1 manifestData = new();
Expand Down Expand Up @@ -58,25 +64,39 @@ public static bool GenerateManifest(ITracer tracer, DirectoryInfo dir, string ma
return false;
}

ManifestDataEntry manifestDataEntry = new()
// This is the special module for the runtime in runtimeCorrelatedKey that's under the special index.
manifestData.Entries.Add(new()
{
BasedirRelativePath = basedirRelativePath,
SymbolKey = runtimeCorrelatedKey.Index,
Sha512 = fileHash,
DebugInformationLevel = TargetDebugLevel
};
});

using FileStream fs = correlatedFile.OpenRead();
SymbolStoreFile specialDiagnosticFile = new(fs, correlatedFile.FullName);
FileKeyGenerator correlatedGenerator = new(tracer, specialDiagnosticFile);

if (!correlatedGenerator.IsValid())
{
tracer.Error("Unable to get a key generator for special diagnostic file '{0}' of runtime '{1}'", file.FullName, correlatedFile.FullName);
return false;
}

manifestData.Entries.Add(manifestDataEntry);
SymbolStoreKey diagnosticFileIdentityKey = correlatedGenerator.GetKeys(KeyTypeFlags.IdentityKey).Single();
// This is the special module for the runtime in runtimeCorrelatedKey that's under its own identity key
// with the upgraded debug information level.
manifestData.Entries.Add(new()
{
BasedirRelativePath = basedirRelativePath,
SymbolKey = diagnosticFileIdentityKey.Index,
Sha512 = fileHash,
DebugInformationLevel = TargetDebugLevel
});
}
}

JsonSerializerOptions serializeOptions = new()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true
};

string manifestDataContent = JsonSerializer.Serialize(manifestData, serializeOptions);
string manifestDataContent = JsonSerializer.Serialize(manifestData, s_serializeOptions);
File.WriteAllText(manifestFileName, manifestDataContent);

return true;
Expand Down Expand Up @@ -120,20 +140,17 @@ private static string CalculateSHA512(FileInfo file)
return BitConverter.ToString(hashValueBytes).Replace("-", "");
}

private class ManifestFileVersion
private interface IManifestFile
{
public string Version { get; set; }
string Version { get; }
}

private class ManifestDataV1 : ManifestFileVersion
private sealed class ManifestDataV1 : IManifestFile
{
public List<ManifestDataEntry> Entries { get; set; }
public List<ManifestDataEntry> Entries { get; } = [];

public ManifestDataV1()
{
Version = "1";
Entries = new List<ManifestDataEntry>();
}
[JsonInclude]
public string Version => "1";
}

private class ManifestDataEntry
Expand Down