-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Remove all kernel32.dll references and debug breakpoints #108647
Changes from 9 commits
cb10c4b
279b17c
5ca7365
27a7df8
2ff0273
182c58f
83f33f1
73d33ac
b0f5afd
a6f9b08
e5a4a46
f13f6f3
9b11da6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,8 +79,8 @@ private void LogWorker() | |
} | ||
catch (IOException e) | ||
{ | ||
ReliabilityFramework.MyDebugBreak(String.Format("LogWorker IOException:{0}", e.ToString())); | ||
//Disk may be full so simply stop logging | ||
throw new Exception("Fail to write message to log file: " + e.Message); | ||
} | ||
} | ||
|
||
|
@@ -120,7 +120,6 @@ private void LogWorker() | |
} | ||
catch (IOException e) | ||
{ | ||
ReliabilityFramework.MyDebugBreak(String.Format("LogWorker IOException:{0}", e.ToString())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably want to throw an exception here still after logging? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above: if debugger is present => break else, log and throw an exception. |
||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,6 +227,10 @@ public static int Main(string[] args) | |
{ | ||
rf.HandleOom(e, "Running tests"); | ||
} | ||
catch (TimeoutException e) | ||
{ | ||
throw e; | ||
} | ||
catch (Exception e) | ||
{ | ||
Exception eTemp = e.InnerException; | ||
|
@@ -274,24 +278,13 @@ public void HandleOom(Exception e, string message) | |
try | ||
{ | ||
_logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.Tests, String.Format("Exception while running tests: {0}", e)); | ||
if (_curTestSet.DebugBreakOnOutOfMemory) | ||
{ | ||
OomExceptionCausedDebugBreak(); | ||
} | ||
} | ||
catch (OutOfMemoryException) | ||
{ | ||
// hang and let someone debug if we can't even break in... | ||
Thread.CurrentThread.Join(); | ||
_logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.Tests, "Out of memory"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we throw here to pick up the dump on the scripts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same logic here - if debugger present => break. |
||
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private void OomExceptionCausedDebugBreak() | ||
{ | ||
MyDebugBreak("Harness"); | ||
} | ||
|
||
/// <summary> | ||
/// Runs the reliability tests. Called from Main with the name of the configuration file we should be using. | ||
/// All code in here runs in our starting app domain. | ||
|
@@ -506,15 +499,6 @@ public int RunReliabilityTests(string testConfig, bool doReplay) | |
return (99); | ||
} | ||
|
||
[DllImport("kernel32.dll")] | ||
private extern static void DebugBreak(); | ||
|
||
[DllImport("kernel32.dll")] | ||
private extern static bool IsDebuggerPresent(); | ||
|
||
[DllImport("kernel32.dll")] | ||
private extern static void OutputDebugString(string debugStr); | ||
|
||
/// <summary> | ||
/// Checks to see if we should block all execution due to a fatal error | ||
/// (when DebugBreak is not available on win9x or running outside the debugger). | ||
|
@@ -533,27 +517,6 @@ private static void NoExitPoll() | |
} | ||
} | ||
} | ||
internal static void MyDebugBreak(string extraData) | ||
{ | ||
if (IsDebuggerPresent()) | ||
{ | ||
Console.WriteLine(string.Format("DebugBreak: {0}", extraData)); | ||
DebugBreak(); | ||
} | ||
{ | ||
// We need to stop the process now, | ||
// but all the threads are still running | ||
try | ||
{ | ||
Console.WriteLine("MyDebugBreak called, stopping process... {0}", extraData); | ||
} | ||
finally | ||
{ | ||
s_fNoExit = true; | ||
Thread.CurrentThread.Join(); | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Calculates the total number of tests to be run based upon the maximum | ||
|
@@ -780,7 +743,7 @@ private void TestStarter() | |
Thread.Sleep(250); // give the CPU a bit of a rest if we don't need to start a new test. | ||
if (_curTestSet.DebugBreakOnMissingTest && DateTime.Now.Subtract(_startTime) > minTimeToStartTest) | ||
{ | ||
NewTestsNotStartingDebugBreak(); | ||
_logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.TestStarter, String.Format("New tests not starting")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add debug break conditional functionality. |
||
} | ||
} | ||
} | ||
|
@@ -799,12 +762,6 @@ private void TestStarter() | |
TestSetShutdown(totalTestsToRun); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private void NewTestsNotStartingDebugBreak() | ||
{ | ||
MyDebugBreak("Tests haven't been started in a long time!"); | ||
} | ||
|
||
/// <summary> | ||
/// Shuts down the current test set, waiting for tests to finish, etc... | ||
/// </summary> | ||
|
@@ -882,20 +839,20 @@ private void TestSetShutdown(int totalTestsToRun) | |
|
||
if (_curTestSet.DebugBreakOnTestHang) | ||
{ | ||
TestIsHungDebugBreak(); | ||
string msg = "Test hang because of timeout"; | ||
Console.WriteLine(msg); | ||
_logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.StartupShutdown, msg); | ||
Debugger.Break(); | ||
} | ||
else | ||
{ | ||
string msg = "Throw exception because of timeout"; | ||
_logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.StartupShutdown, msg); | ||
throw new TimeoutException("Time limit reached."); | ||
} | ||
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private void TestIsHungDebugBreak() | ||
{ | ||
string msg = String.Format("break"); | ||
_logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.StartupShutdown, msg); | ||
|
||
MyDebugBreak("TestHang"); | ||
} | ||
|
||
/// <summary> | ||
/// Starts the test passed. The test should already be loaded into an app domain. | ||
/// </summary> | ||
|
@@ -1050,7 +1007,7 @@ private void StartTestWorker(object test) | |
{ | ||
if (_curTestSet.DebugBreakOnPathTooLong) | ||
{ | ||
MyDebugBreak("Path too long"); | ||
_logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.Tests, "Path too long"); | ||
} | ||
} | ||
catch (OutOfMemoryException e) | ||
|
@@ -1196,12 +1153,6 @@ private void StartTestWorker(object test) | |
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private void UnexpectedThreadAbortDebugBreak() | ||
{ | ||
MyDebugBreak("Unexpected Thread Abort"); | ||
} | ||
|
||
/// <summary> | ||
/// Called after a test has finished executing. | ||
/// </summary> | ||
|
@@ -1313,10 +1264,6 @@ private void TestPreLoader(ReliabilityTest test, string[] paths) | |
_logger.WriteToInstrumentationLog(_curTestSet, LoggingLevels.Tests, msg); | ||
test.ConcurrentCopies = 0; | ||
test.TestLoadFailed = true; | ||
if (_curTestSet.DebugBreakOnBadTest) | ||
{ | ||
BadTestDebugBreak(msg); | ||
} | ||
|
||
// crash on exceptions when running as a unit test. | ||
if (IsRunningAsUnitTest) | ||
|
@@ -1325,11 +1272,6 @@ private void TestPreLoader(ReliabilityTest test, string[] paths) | |
Interlocked.Decrement(ref LoadingCount); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private void BadTestDebugBreak(string msg) | ||
{ | ||
MyDebugBreak(msg); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
WeakReference UnloadAssemblyLoadContextInner(ReliabilityTest test) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's throw the exception here so that we can take a dump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the debugger break is set to true, we should set a debug break point here and if not, log and throw an exception.