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

Extract the pdb path #45

Merged
merged 5 commits into from
May 1, 2016
Merged
Show file tree
Hide file tree
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
27 changes: 26 additions & 1 deletion GoogleTestAdapter/DiaResolver.Tests/DiaResolverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,37 @@ public void GetFunctions_X64_NonMatchingFilter_NoResults()
DoResolveTest(X64ExternallyLinkedTests, "ThisFunctionDoesNotExist", 0, 0);
}

[TestMethod]
public void ExtractPDB_X64()
{
NativeMethods.PDBPathExtractor extractor = new NativeMethods.PDBPathExtractor(X64StaticallyLinkedTests, new List<string>());

string pdb = extractor.pdbPath;
string executableName = System.IO.Path.GetFileNameWithoutExtension(X64StaticallyLinkedTests);
string pdbName = System.IO.Path.GetFileNameWithoutExtension(pdb);

Assert.AreEqual(executableName, pdbName);
}

[TestMethod]
public void ExtractPDB_X86()
{
NativeMethods.PDBPathExtractor extractor = new NativeMethods.PDBPathExtractor(X86StaticallyLinkedTests, new List<string>());

string pdb = extractor.pdbPath;
string executableName = System.IO.Path.GetFileNameWithoutExtension(X86StaticallyLinkedTests);
string pdbName = System.IO.Path.GetFileNameWithoutExtension(pdb);

Assert.AreEqual(executableName, pdbName);
}


private void DoResolveTest(string executable, string filter, int expectedLocations, int expectedErrorMessages, bool disposeResolver = true)
{
List<SourceFileLocation> locations = new List<SourceFileLocation>();
FakeLogger fakeLogger = new FakeLogger();

IDiaResolver resolver = DefaultDiaResolverFactory.Instance.Create(executable, "", fakeLogger);
IDiaResolver resolver = DefaultDiaResolverFactory.Instance.Create(executable, "", fakeLogger);
locations.AddRange(resolver.GetFunctions(filter));

if (disposeResolver)
Expand Down
11 changes: 8 additions & 3 deletions GoogleTestAdapter/DiaResolver/DiaResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,15 @@ public IEnumerable<SourceFileLocation> GetFunctions(string symbolFilterString)
return GetSymbolNamesAndAddresses(diaSymbols).Select(ToSourceFileLocation);
}


private string FindPdbFile(string binary, string pathExtension)
{
string pdb = Path.ChangeExtension(binary, ".pdb");
NativeMethods.PDBPathExtractor pdbExtractor =
new NativeMethods.PDBPathExtractor(binary, new List<String>());
string pdb = pdbExtractor.pdbPath;
if (pdb != null && File.Exists(pdb))
return pdb;

pdb = Path.ChangeExtension(binary, ".pdb");
if (File.Exists(pdb))
return pdb;

Expand Down Expand Up @@ -182,4 +187,4 @@ private IDiaEnumLineNumbers GetLineNumbers(uint addressSection, uint addressOffs

}

}
}
Loading