Revert GetFrameLocation() changes.
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Mon, 25 Oct 2021 16:55:51 +0000 (09:55 -0700)
committerAlexander Soldatov/Platform Lab /SRR/Staff Engineer/Samsung Electronics <soldatov.a@samsung.com>
Mon, 25 Oct 2021 19:39:44 +0000 (22:39 +0300)
Partially revert 0eb46078b47ba31a04269fcc8e19b42081cc0267.
Fix possible debugger hang at stack trace command.

src/debugger/manageddebugger.cpp
test-suite/MITestExceptionBreakpoint/Program.cs
test-suite/VSCodeTestExceptionBreakpoint/Program.cs
test-suite/VSCodeTestNoJMCExceptionBreakpoint/Program.cs

index 29bab0bee0db75e79738499388ba117c262cea31..eff637e549e7355e595f2ea990cb89e5e5415344 100644 (file)
@@ -852,19 +852,6 @@ HRESULT ManagedDebugger::GetFrameLocation(ICorDebugFrame *pFrame, ThreadId threa
 {
     HRESULT Status;
 
-    ToRelease<ICorDebugFunction> iCorFunction;
-    IfFailRet(pFrame->GetFunction(&iCorFunction));
-    ToRelease<ICorDebugFunction2> iCorFunction2;
-    IfFailRet(iCorFunction->QueryInterface(IID_ICorDebugFunction2, (LPVOID*) &iCorFunction2));
-    BOOL JMCStatus;
-    IfFailRet(iCorFunction2->GetJMCStatus(&JMCStatus));
-
-    if (JMCStatus == FALSE)
-    {
-        stackFrame = StackFrame(threadId, level, "[External Code]");
-        return S_OK;
-    }
-
     stackFrame = StackFrame(threadId, level, "");
 
     ULONG32 ilOffset;
@@ -881,8 +868,11 @@ HRESULT ManagedDebugger::GetFrameLocation(ICorDebugFrame *pFrame, ThreadId threa
     mdMethodDef methodToken;
     IfFailRet(pFrame->GetFunctionToken(&methodToken));
 
+    ToRelease<ICorDebugFunction> pFunc;
+    IfFailRet(pFrame->GetFunction(&pFunc));
+
     ToRelease<ICorDebugModule> pModule;
-    IfFailRet(iCorFunction->GetModule(&pModule));
+    IfFailRet(pFunc->GetModule(&pModule));
 
     ULONG32 nOffset = 0;
     ToRelease<ICorDebugNativeFrame> pNativeFrame;
index 3d965d4bfedf395ab11e21e05d7682d3e7abf835..ce34572dbd2bc85a2102c57ff4d63266e1888f85 100644 (file)
@@ -107,7 +107,7 @@ namespace NetcoreDbgTest.Script
             Assert.True(MIDebugger.IsEventReceived(filter), @"__FILE__:__LINE__"+"\n"+caller_trace);\r
         }\r
 \r
-        public void WasExceptionBreakpointHitInExternalCode(string caller_trace, string excCategory, string excStage, string excName)\r
+        public void WasExceptionBreakpointHitInExternalCode(string caller_trace, string excCategory, string excStage, string excName, string extFrame)\r
         {\r
             Func<MIOutOfBandRecord, bool> filter = (record) => {\r
                 if (!IsStoppedEvent(record)) {\r
@@ -130,7 +130,7 @@ namespace NetcoreDbgTest.Script
                 var frame = (MITuple)output["frame"];\r
                 var func = (MIConst)(frame["func"]);\r
 \r
-                if (func.CString == "[External Code]") {\r
+                if (func.CString == extFrame) {\r
                     return true;\r
                 }\r
 \r
@@ -398,11 +398,11 @@ namespace MITestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_2");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception", "MITestExceptionBreakpoint.outside_user_code.throw_Exception()");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_3");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception", "MITestExceptionBreakpoint.outside_user_code.throw_Exception_with_catch()");\r
 \r
                 Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "21");\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "throw", "System.NullReferenceException");\r
@@ -429,11 +429,11 @@ namespace MITestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_5");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.NullReferenceException");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.NullReferenceException", "MITestExceptionBreakpoint.outside_user_code.throw_Exception_NullReferenceException_with_catch()");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_6");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.NullReferenceException");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.NullReferenceException", "MITestExceptionBreakpoint.outside_user_code.throw_NullReferenceException()");\r
 \r
                 Context.DeleteExceptionBreakpoint(@"__FILE__:__LINE__", "22");\r
                 Context.AddExceptionBreakpoint(@"__FILE__:__LINE__", "user-unhandled", "*");\r
@@ -518,11 +518,11 @@ namespace MITestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_11");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception", "MITestExceptionBreakpoint.outside_user_code.throw_Exception()");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_12");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception", "MITestExceptionBreakpoint.outside_user_code.throw_Exception_with_catch()");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_13");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
@@ -532,7 +532,7 @@ namespace MITestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_14");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "clr", "throw", "System.Exception", "MITestExceptionBreakpoint.outside_user_code.throw_Exception()");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_15");\r
 \r
index 2b6df1de1933f3a43a4b530966bf1e9a1f2e3c3a..e9ea92f23df2e640debcec86cdd0d8029bdbe10a 100644 (file)
@@ -298,7 +298,7 @@ namespace NetcoreDbgTest.Script
             throw new ResultNotSuccessException(@"__FILE__:__LINE__"+"\n"+caller_trace);\r
         }\r
 \r
-        public void WasExceptionBreakpointHitInExternalCode(string caller_trace, string excCategory, string excMode, string excName)\r
+        public void WasExceptionBreakpointHitInExternalCode(string caller_trace, string excCategory, string excMode, string excName, string extFrame)\r
         {\r
             Func<string, bool> filter = (resJSON) => {\r
                 if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped")\r
@@ -321,7 +321,7 @@ namespace NetcoreDbgTest.Script
             StackTraceResponse stackTraceResponse =\r
                 JsonConvert.DeserializeObject<StackTraceResponse>(ret.ResponseStr);\r
 \r
-            if (stackTraceResponse.body.stackFrames[0].name == "[External Code]")\r
+            if (stackTraceResponse.body.stackFrames[0].name == extFrame)\r
             {\r
                 TestExceptionInfo(@"__FILE__:__LINE__"+"\n"+caller_trace, excCategory, excMode, excName);\r
                 return;\r
@@ -500,11 +500,11 @@ namespace VSCodeTestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_2");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.Exception");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.Exception", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_Exception()");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_3");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.Exception");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.Exception", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_Exception_with_catch()");\r
 \r
                 Context.ResetExceptionBreakpoints();\r
                 Context.AddExceptionBreakpointFilterAllWithOptions("");\r
@@ -523,11 +523,11 @@ namespace VSCodeTestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_2");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.Exception");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.Exception", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_Exception()");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_3");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.Exception");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.Exception", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_Exception_with_catch()");\r
 \r
                 Context.ResetExceptionBreakpoints();\r
                 Context.AddExceptionBreakpointFilterAllWithOptions("System.NullReferenceException");\r
@@ -558,11 +558,11 @@ namespace VSCodeTestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_5");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.NullReferenceException");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.NullReferenceException", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_Exception_NullReferenceException_with_catch()");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_6");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.NullReferenceException");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.NullReferenceException", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_NullReferenceException()");\r
 \r
                 Context.ResetExceptionBreakpoints();\r
                 Context.AddExceptionBreakpointFilterAllWithOptions("!System.Exception");\r
@@ -581,11 +581,11 @@ namespace VSCodeTestExceptionBreakpoint
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_5");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.NullReferenceException");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.NullReferenceException", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_Exception_NullReferenceException_with_catch()");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
                 Context.WasBreakpointHit(@"__FILE__:__LINE__", "bp_test_6");\r
                 Context.Continue(@"__FILE__:__LINE__");\r
-                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.NullReferenceException");\r
+                Context.WasExceptionBreakpointHitInExternalCode(@"__FILE__:__LINE__", "CLR", "always", "System.NullReferenceException", "VSCodeTestExceptionBreakpoint.outside_user_code.throw_NullReferenceException()");\r
 \r
                 Context.ResetExceptionBreakpoints();\r
                 Context.AddExceptionBreakpointFilterUserUnhandled();\r
index 77ed66f2dc918ea106b6a1de1876ddb369492d8b..7aeee4afa703f6c2240efa00a3cabdc1996e4cca 100644 (file)
@@ -298,38 +298,6 @@ namespace NetcoreDbgTest.Script
             throw new ResultNotSuccessException(@"__FILE__:__LINE__"+"\n"+caller_trace);\r
         }\r
 \r
-        public void WasExceptionBreakpointHitInExternalCode(string caller_trace, string excCategory, string excMode, string excName)\r
-        {\r
-            Func<string, bool> filter = (resJSON) => {\r
-                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped")\r
-                    && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "exception")) {\r
-                    threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId"));\r
-                    return true;\r
-                }\r
-                return false;\r
-            };\r
-\r
-            Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__"+"\n"+caller_trace);\r
-\r
-            StackTraceRequest stackTraceRequest = new StackTraceRequest();\r
-            stackTraceRequest.arguments.threadId = threadId;\r
-            stackTraceRequest.arguments.startFrame = 0;\r
-            stackTraceRequest.arguments.levels = 20;\r
-            var ret = VSCodeDebugger.Request(stackTraceRequest);\r
-            Assert.True(ret.Success, @"__FILE__:__LINE__"+"\n"+caller_trace);\r
-\r
-            StackTraceResponse stackTraceResponse =\r
-                JsonConvert.DeserializeObject<StackTraceResponse>(ret.ResponseStr);\r
-\r
-            if (stackTraceResponse.body.stackFrames[0].name == "[External Code]")\r
-            {\r
-                TestExceptionInfo(@"__FILE__:__LINE__"+"\n"+caller_trace, excCategory, excMode, excName);\r
-                return;\r
-            }\r
-\r
-            throw new ResultNotSuccessException(@"__FILE__:__LINE__"+"\n"+caller_trace);\r
-        }\r
-\r
         public Context(ControlInfo controlInfo, NetcoreDbgTestCore.DebuggerClient debuggerClient)\r
         {\r
             ControlInfo = controlInfo;\r