Add notice about MSFT Symbol Server EULA (#85)
Also, eliminate some unused code.
This commit is contained in:
Родитель
f52fec166a
Коммит
adce0871c7
|
@ -1,20 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License - see LICENSE file in this repo.
|
||||
namespace Microsoft.SqlServer.Utils.Misc.SQLCallStackResolver {
|
||||
internal class PdbInfo {
|
||||
internal string Path;
|
||||
internal Guid Guid;
|
||||
internal int Age;
|
||||
}
|
||||
|
||||
internal class PEHelper {
|
||||
internal static List<PdbInfo> ReadPdbs(PEReader reader) {
|
||||
var debugDirectories = reader.ReadDebugDirectory();
|
||||
return new List<PdbInfo>(debugDirectories.Where(entry => entry.Type == DebugDirectoryEntryType.CodeView)
|
||||
.Select(entry => reader.ReadCodeViewDebugDirectoryData(entry))
|
||||
.Select(data => new PdbInfo() { Path = data.Path, Guid = data.Guid, Age = data.Age }));
|
||||
}
|
||||
|
||||
public static int RvaToOffset(int virtualAddress, ImmutableArray<SectionHeader> sections) {
|
||||
var section = sections.Where(s => s.VirtualAddress <= virtualAddress && virtualAddress < s.VirtualAddress + s.VirtualSize);
|
||||
return section.Any() ? section.First().PointerToRawData + virtualAddress - section.First().VirtualAddress : -1;
|
||||
|
|
|
@ -52,27 +52,5 @@ namespace Microsoft.SqlServer.Utils.Misc.SQLCallStackResolver {
|
|||
fs.Close();
|
||||
File.WriteAllText(jsonFile, File.ReadAllText(jsonFile, Encoding.UTF8).Replace(@"\/", "/"));
|
||||
}
|
||||
|
||||
public static string GetDownloadScriptPowerShell(SQLBuildInfo bld, bool includeMarkdown) {
|
||||
Contract.Requires(bld != null);
|
||||
var symcmds = new StringBuilder();
|
||||
if (null != bld.SymbolDetails && bld.SymbolDetails.Where(s => s.DownloadVerified).Any()) {
|
||||
if (includeMarkdown) {
|
||||
symcmds.AppendLine($"# {bld}");
|
||||
symcmds.AppendLine("``` powershell");
|
||||
}
|
||||
symcmds.AppendLine($"# {bld}");
|
||||
symcmds.AppendLine($"$outputFolder = 'c:\\sqlsyms\\{bld.BuildNumber}\\{bld.MachineType}' # <<change this output folder if needed>>'");
|
||||
symcmds.AppendLine($"mkdir -f $outputFolder");
|
||||
foreach (var sym in bld.SymbolDetails.Where(s => s.DownloadVerified)) {
|
||||
symcmds.AppendLine($"if (-not (Test-Path \"$outputFolder\\{sym.PDBName}.pdb\")) {{ Invoke-WebRequest -uri '{sym.DownloadURL}' -OutFile \"$outputFolder\\{sym.PDBName}.pdb\" }} # File version {sym.FileVersion}");
|
||||
}
|
||||
|
||||
if (includeMarkdown) symcmds.AppendLine("```");
|
||||
symcmds.AppendLine();
|
||||
}
|
||||
|
||||
return symcmds.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -550,47 +550,6 @@ namespace Microsoft.SqlServer.Utils.Misc.SQLCallStackResolver {
|
|||
});
|
||||
}
|
||||
|
||||
static readonly string[] wellKnownModuleNames = new string[] { "ntdll", "kernel32", "kernelbase", "ntoskrnl", "sqldk", "sqlmin", "sqllang", "sqltses", "sqlaccess", "qds", "hkruntime", "hkengine", "hkcompile", "sqlos", "sqlservr", "SqlServerSpatial", "SqlServerSpatial110", "SqlServerSpatial120", "SqlServerSpatial130", "SqlServerSpatial140", "SqlServerSpatial150", "SqlServerSpatial160" };
|
||||
|
||||
/// <summary>
|
||||
/// This method generates a PowerShell script to automate download of matched PDBs from the public symbol server.
|
||||
/// </summary>
|
||||
public static async Task<List<Symbol>> GetSymbolDetailsForBinaries(List<string> dllPaths, bool recurse, List<Symbol> existingSymbols = null) {
|
||||
if (dllPaths == null || dllPaths.Count == 0) return new List<Symbol>();
|
||||
|
||||
var symbolsFound = new List<Symbol>();
|
||||
foreach (var currentModule in wellKnownModuleNames) {
|
||||
if (null != existingSymbols) {
|
||||
var syms = existingSymbols.Where(s => string.Equals(s.PDBName, currentModule, StringComparison.InvariantCultureIgnoreCase));
|
||||
if (syms.Any()) {
|
||||
symbolsFound.Add(syms.First());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
var search = dllPaths.Where(p => Directory.Exists(p)).SelectMany(currPath => Directory.EnumerateFiles(currPath, currentModule + ".*", recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly))
|
||||
.Where(f => f.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) || f.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase));
|
||||
if (search.Any()) {
|
||||
using var dllFileStream = new FileStream(search.First(), FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
using var reader = new PEReader(dllFileStream);
|
||||
var lastPdbInfo = PEHelper.ReadPdbs(reader).Last();
|
||||
var internalPDBName = lastPdbInfo.Path;
|
||||
var pdbGuid = lastPdbInfo.Guid;
|
||||
var pdbAge = lastPdbInfo.Age;
|
||||
var usablePDBName = Path.GetFileNameWithoutExtension(internalPDBName);
|
||||
var fileVer = FileVersionInfo.GetVersionInfo(search.First()).FileVersion;
|
||||
var newSymbol = new Symbol() {
|
||||
PDBName = usablePDBName, InternalPDBName = internalPDBName,
|
||||
DownloadURL = string.Format(CultureInfo.CurrentCulture, @"https://msdl.microsoft.com/download/symbols/{0}.pdb/{1}/{0}.pdb",
|
||||
usablePDBName, pdbGuid.ToString("N", CultureInfo.CurrentCulture) + pdbAge.ToString(CultureInfo.CurrentCulture)), FileVersion = fileVer
|
||||
};
|
||||
newSymbol.DownloadVerified = await Symbol.IsURLValid(new Uri(newSymbol.DownloadURL));
|
||||
symbolsFound.Add(newSymbol);
|
||||
}
|
||||
}
|
||||
|
||||
return symbolsFound;
|
||||
}
|
||||
|
||||
private bool disposedValue = false;
|
||||
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<add key="SQLBuildInfoUpdateURLs" value="https://raw.githubusercontent.com/microsoft/SQLCallStackResolver/main/lastupdated.txt;https://raw.githubusercontent.com/arvindshmicrosoft/SQLCallStackResolver/main/lastupdated.txt" />
|
||||
<add key="SQLBuildInfoURLs" value="https://raw.githubusercontent.com/microsoft/SQLCallStackResolver/main/sqlbuildinfo.json;https://raw.githubusercontent.com/arvindshmicrosoft/SQLCallStackResolver/main/sqlbuildinfo.json" />
|
||||
<add key="LatestReleaseURLs" value="https://raw.githubusercontent.com/microsoft/SQLCallStackResolver/main/latestrelease.txt" />
|
||||
<add key="PatternsToTreatAsMultiline" value="BEGIN STACK DUMP|Short Stack Dump"/>
|
||||
<add key="PatternsToTreatAsMultiline" value="BEGIN STACK DUMP|Short Stack Dump" />
|
||||
</appSettings>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
namespace Microsoft.SqlServer.Utils.Misc.SQLCallStackResolver {
|
||||
public partial class MainForm : Form {
|
||||
public MainForm() {
|
||||
MessageBox.Show("Copyright (c) 2022 Microsoft Corporation. All rights reserved.\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.", "SQLCallStackResolver - Legal Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
MessageBox.Show("Copyright (c) 2022 Microsoft Corporation. All rights reserved.\r\n\r\nTHIS SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n\r\nUSAGE OF THE MICROSOFT SYMBOL SERVER IS COVERED BY THE LICENSE TERMS PUBLISHED AT https://docs.microsoft.com/legal/windows-sdk/microsoft-symbol-server-license-terms.", "SQLCallStackResolver - Legal Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
|
|
@ -202,16 +202,6 @@ namespace Microsoft.SqlServer.Utils.Misc.SQLCallStackResolver {
|
|||
Assert.AreEqual(expectedSymbol, ret.Trim());
|
||||
}
|
||||
|
||||
/// Check whether symbol details for a given binary are correct.
|
||||
[TestMethod][TestCategory("Unit")] public async Task GetSymDetails() {
|
||||
var dllPaths = new List<string> { @"..\..\..\Tests\TestCases\TestOrdinal" };
|
||||
var ret = await StackResolver.GetSymbolDetailsForBinaries(dllPaths, true);
|
||||
Assert.AreEqual(1, ret.Count);
|
||||
Assert.AreEqual("https://msdl.microsoft.com/download/symbols/sqldk.pdb/6a1934433512464b8b8ed905ad930ee62/sqldk.pdb", ret[0].DownloadURL);
|
||||
Assert.IsTrue(ret[0].DownloadVerified);
|
||||
Assert.AreEqual("2015.0130.4560.00 ((SQL16_SP1_QFE-CU).190312-0204)", ret[0].FileVersion);
|
||||
}
|
||||
|
||||
/// Make sure that caching PDB files is working. To do this we must use XEL input to trigger multiple worker threads.
|
||||
[TestMethod][TestCategory("Unit")] public async Task SymbolFileCaching() {
|
||||
using var csr = new StackResolver();
|
||||
|
|
Загрузка…
Ссылка в новой задаче