Skip to content

Commit 110670f

Browse files
authored
Update SourceBuiltSdkContainsNativeDebugSymbols for 'ilc'. (#41752)
1 parent 06574d2 commit 110670f

File tree

1 file changed

+3
-40
lines changed
  • src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests

1 file changed

+3
-40
lines changed

src/SourceBuild/content/test/Microsoft.DotNet.SourceBuild.SmokeTests/DebugTests.cs

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests;
1414

1515
public class DebugTests : SdkTests
1616
{
17-
private record ScanResult(string FileName, bool HasDebugInfo, bool HasDebugAbbrevs, bool HasFileSymbols, bool HasGnuDebugLink);
17+
private record ScanResult(string FileName, bool HasDebugInfo, bool HasDebugAbbrevs, bool HasGnuDebugLink);
1818

1919
public DebugTests(ITestOutputHelper outputHelper) : base(outputHelper) { }
2020

@@ -30,7 +30,7 @@ public void SourceBuiltSdkContainsNativeDebugSymbols()
3030
StringBuilder issueDetails = new();
3131
foreach (var fileName in fileNames)
3232
{
33-
if (!IsElfFile(fileName) || SkipFile(fileName))
33+
if (!IsElfFile(fileName))
3434
{
3535
continue;
3636
}
@@ -49,11 +49,6 @@ public void SourceBuiltSdkContainsNativeDebugSymbols()
4949
foundIssue = true;
5050
issueDetails.Append($"missing .debug_abbrev section in {fileName}{newLine}");
5151
}
52-
if (!result.HasFileSymbols)
53-
{
54-
foundIssue = true;
55-
issueDetails.Append($"missing FILE symbols in {fileName}{newLine}");
56-
}
5752
if (result.HasGnuDebugLink)
5853
{
5954
foundIssue = true;
@@ -70,14 +65,6 @@ private bool IsElfFile(string fileName)
7065
return Regex.IsMatch(fileStdOut, @"ELF 64-bit [LM]SB (?:pie )?(?:executable|shared object)");
7166
}
7267

73-
private static bool SkipFile(string path)
74-
{
75-
string fileName = Path.GetFileName(path);
76-
77-
// 'ilc' is a NativeAOT-built application which doesn't meet the expectations set by the test.
78-
return fileName == "ilc";
79-
}
80-
8168
private ScanResult ScanFile(string fileName)
8269
{
8370
string readelfSStdOut = ExecuteHelper.ExecuteProcessValidateExitCode("eu-readelf", $"-S {fileName}", OutputHelper);
@@ -96,35 +83,11 @@ private ScanResult ScanFile(string fileName)
9683

9784
string readelfsStdOut = ExecuteHelper.ExecuteProcessValidateExitCode("eu-readelf", $"-s {fileName}", OutputHelper);
9885

99-
// Test FILE symbols. These will most likely be removed by anyting that
100-
// manipulates symbol tables because it's generally useless. So a nice test
101-
// that nothing has messed with symbols.
102-
bool hasFileSymbols = readelfsStdOut.Split("\n").Where(ContainsFileSymbols).Any();
103-
10486
// Test that there are no .gnu_debuglink sections pointing to another
10587
// debuginfo file. There shouldn't be any debuginfo files, so the link makes
10688
// no sense either.
10789
bool hasGnuDebuglink = readelfsStdOut.Split("\n").Where(line => line.Contains("] .gnu_debuglink")).Any();
10890

109-
return new ScanResult(fileName, hasDebugInfo, hasDebugAbbrev, hasFileSymbols, hasGnuDebuglink);
110-
}
111-
112-
private bool ContainsFileSymbols(string line)
113-
{
114-
// Try matching against output like this:
115-
// 10: 0000000000000000 0 FILE LOCAL DEFAULT ABS coreclr_resolver.cpp
116-
// 779: 0000000000000000 0 FILE LOCAL DEFAULT ABS header.cpp
117-
118-
var parts = new Regex(@"[ \t\n\r]+").Split(line);
119-
int expectedNumberOfParts = 9;
120-
121-
if (parts.Length < expectedNumberOfParts)
122-
{
123-
return false;
124-
}
125-
126-
var fileNameRegex = new Regex(@"(.*/)?[-_a-zA-Z0-9]+\.(c|cc|cpp|cxx)");
127-
return (parts[3] == "0") && (parts[4] == "FILE") && (parts[5] == "LOCAL") && (parts[6] == "DEFAULT") &&
128-
(parts[7] == "ABS") && (fileNameRegex.IsMatch(parts[8]));
91+
return new ScanResult(fileName, hasDebugInfo, hasDebugAbbrev, hasGnuDebuglink);
12992
}
13093
}

0 commit comments

Comments
 (0)