Open WhiteSmoogy opened 3 years ago
i had try many EvaluateExpression pattern code,now this work: var rootExpr = (DkmRootVisualizedExpression)visualizedExpression; var ParentInspectionContext = visualizedExpression.InspectionContext; using (var expression = DkmLanguageExpression.Create(ParentInspectionContext.Language, DkmEvaluationFlags.DesignTime, $"sizeof({rootExpr.FullName})", null)) { var worklist = DkmWorkList.Create(null); ParentInspectionContext.EvaluateExpression(worklist, expression, rootExpr.StackFrame, asyncResult => { if (asyncResult.ResultObject is DkmSuccessEvaluationResult succResult) { Debug.Fail(succResult.Value); } if (asyncResult.ResultObject is DkmFailedEvaluationResult failResult) { Debug.Fail(failResult.ErrorMessage); } }); worklist.Execute(); }
but when i capture some var in callback,the evaluate failed,Examplae Code: var size = 0; var worklist = DkmWorkList.Create(null); ParentInspectionContext.EvaluateExpression(worklist, expression, rootExpr.StackFrame, asyncResult => { if (asyncResult.ResultObject is DkmSuccessEvaluationResult succResult) { if(int.TryParse(succResult.Value,out size); } if (asyncResult.ResultObject is DkmFailedEvaluationResult failResult) { Debug.Fail(failResult.ErrorMessage); //go there } }); the log output : RETURN ERROR: IDkmMemoryOperation.ReadMemory (hr = 0x92330010, ThreadId=21736, TickCount=703159171) RETURN ERROR: IDkmMemoryOperation.ReadMemory (hr = 0x92330010, ThreadId=5032, TickCount=703159171) RETURN ERROR: IDkmCustomVisualizer.EvaluateVisualizedExpression (hr = 0x92330010, ThreadId=5032, TickCount=703159187)
Example Code: class VisualizerComponent : IDkmCustomVisualizer{ IDkmCustomVisualizer.EvaluateVisualizedExpression(DkmVisualizedExpression visualizedExpression){ using (var LanguageExpression = DkmLanguageExpression.Create( ParentInspectionContext.Language, DkmEvaluationFlags.DesignTime | DkmEvaluationFlags.TreatAsExpression, $"sizeof({rootExpr.FullName})", null )) { //Evaluate it } } } but evaluate this failed. but evaluate "sizeof" work in immediate window,what should i do