Пример #1
0
        public static DebugCompilerContext CreateLocalsContext(DkmInspectionContext inspectionContext, DkmClrInstructionAddress address, bool argumentsOnly)
        {
            MemoryStream input;
            StreamReader reader;

            CreateInputStream(string.Empty, out input, out reader);

            InspectionSession session = InspectionSession.GetInstance(inspectionContext.InspectionSession);
            InspectionScope   scope   = session.GetScope(address);

            DebugCompilerContext context = new DebugCompilerContext(
                null /* null because the context doesn't own the lifetime of the session */,
                scope,
                input,
                reader,
                typeof(LocalVariablesTranslator),
                null /* Method name is not applicable because we create multiple methods for Locals. */,
                new List <DkmClrLocalVariableInfo>(),
                null /* Assignment L-Value only applies to assigments */,
                argumentsOnly);

            context.InitializeSymbols();

            return(context);
        }
Пример #2
0
        private static ImportedMethod TryGetCurrentMethod(DkmInspectionContext inspectionContext, DkmStackWalkFrame frame)
        {
            InspectionSession session = InspectionSession.GetInstance(inspectionContext.InspectionSession);
            InspectionScope   scope   = session.GetScope((DkmClrInstructionAddress)frame.InstructionAddress);

            return(scope.TryImportCurrentMethod());
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_reader != null)
                {
                    _reader.Dispose();
                    _reader = null;
                }

                if (_input != null)
                {
                    _input.Dispose();
                    _input = null;
                }

                if (_ownedSession != null)
                {
                    _ownedSession.Dispose();
                    _ownedSession = null;
                }
            }

            base.Dispose(disposing);
        }
Пример #4
0
        public static DebugCompilerContext CreateAssignmentContext(DkmEvaluationResult lValue, DkmClrInstructionAddress address, string expression)
        {
            MemoryStream input;
            StreamReader reader;

            CreateInputStream(expression, out input, out reader);

            InspectionSession session = InspectionSession.GetInstance(lValue.InspectionSession);
            InspectionScope   scope   = session.GetScope(address);

            DebugCompilerContext context = new DebugCompilerContext(
                null /* null because the context doesn't own the lifetime of the session */,
                scope,
                input,
                reader,
                typeof(AssignmentTranslator),
                "$.M1",
                null /* Generated locals is not applicable for assigments */,
                lValue.FullName,
                false /* "ArgumentsOnly" only applies to local variable query */);

            context.InitializeSymbols();

            return(context);
        }
Пример #5
0
        public static DebugCompilerContext CreateExpressionContext(DkmInspectionContext inspectionContext, DkmClrInstructionAddress address, string expression)
        {
            InspectionSession ownedSession = null;
            InspectionScope   scope;

            if (inspectionContext != null)
            {
                InspectionSession session = InspectionSession.GetInstance(inspectionContext.InspectionSession);
                scope = session.GetScope(address);
            }
            else
            {
                // There is no inspection context when compiling breakpoint conditions.  Create a
                // new temporary session.  The context will need to dispose of this new session
                // when it is disposed.
                ownedSession = new InspectionSession();
                scope        = ownedSession.GetScope(address);
            }

            MemoryStream input;
            StreamReader reader;

            CreateInputStream(expression, out input, out reader);

            DebugCompilerContext context = new DebugCompilerContext(
                ownedSession,
                scope,
                input,
                reader,
                typeof(ExpressionTranslator),
                "$.M1",
                null /* Generated locals is not applicable for compiling expressions */,
                null /* Assignment L-Value only applies to assigments */,
                false /* "ArgumentsOnly" only applies to local variable query */);

            context.InitializeSymbols();

            return(context);
        }
 public DebugCompilerContext(
     InspectionSession ownedSession,
     InspectionScope scope,
     MemoryStream input,
     StreamReader reader,
     Type translatorType,
     string methodName,
     List<DkmClrLocalVariableInfo> generatedLocals,
     string assignmentLValue,
     bool argumentsOnly)
     : this(scope.Session.Importer, reader, CompilationFlags.NoDebug | CompilationFlags.WriteDll)
 {
     _ownedSession = ownedSession;
     _input = input;
     _reader = reader;
     _translatorType = translatorType;
     Scope = scope;
     MethodName = methodName;
     ClassName = string.Format("$.C{0}", s_nextClass++);
     GeneratedLocals = generatedLocals;
     AssignmentLValue = assignmentLValue;
     ArgumentsOnly = argumentsOnly;
 }
 public DebugCompilerContext(
     InspectionSession ownedSession,
     InspectionScope scope,
     MemoryStream input,
     StreamReader reader,
     Type translatorType,
     string methodName,
     List <DkmClrLocalVariableInfo> generatedLocals,
     string assignmentLValue,
     bool argumentsOnly)
     : this(scope.Session.Importer, reader, CompilationFlags.NoDebug | CompilationFlags.WriteDll)
 {
     _ownedSession    = ownedSession;
     _input           = input;
     _reader          = reader;
     _translatorType  = translatorType;
     Scope            = scope;
     MethodName       = methodName;
     ClassName        = string.Format("$.C{0}", s_nextClass++);
     GeneratedLocals  = generatedLocals;
     AssignmentLValue = assignmentLValue;
     ArgumentsOnly    = argumentsOnly;
 }
        public static DebugCompilerContext CreateExpressionContext(DkmInspectionContext inspectionContext, DkmClrInstructionAddress address, string expression)
        {
            InspectionSession ownedSession = null;
            InspectionScope scope;
            if (inspectionContext != null)
            {
                InspectionSession session = InspectionSession.GetInstance(inspectionContext.InspectionSession);
                scope = session.GetScope(address);
            }
            else
            {
                // There is no inspection context when compiling breakpoint conditions.  Create a
                // new temporary session.  The context will need to dispose of this new session
                // when it is disposed.
                ownedSession = new InspectionSession();
                scope = ownedSession.GetScope(address);
            }

            MemoryStream input;
            StreamReader reader;
            CreateInputStream(expression, out input, out reader);

            DebugCompilerContext context = new DebugCompilerContext(
                ownedSession,
                scope,
                input,
                reader,
                typeof(ExpressionTranslator),
                "$.M1",
                null /* Generated locals is not applicable for compiling expressions */,
                null /* Assignment L-Value only applies to assigments */,
                false /* "ArgumentsOnly" only applies to local variable query */);
            context.InitializeSymbols();

            return context;
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_reader != null)
                {
                    _reader.Dispose();
                    _reader = null;
                }

                if (_input != null)
                {
                    _input.Dispose();
                    _input = null;
                }

                if (_ownedSession != null)
                {
                    _ownedSession.Dispose();
                    _ownedSession = null;
                }
            }

            base.Dispose(disposing);
        }